I'm having problems reading the data from my weatherstation, I can see the device and with a json command from the browser it gives my all the data I need but getting it from lua is not working.
Can someone please help me?
Kind regards,
Patrick
The error I'm getting is: EventSystem: in Tuindata: [string "local Tuin_Temperatuur_idx = 251 ..."]:14: attempt to index a nil value (field 'Tuindata')
The device is: 236 RFXLink 2301 0 Tuindata Temp + Humidity WTGR800 10.3 C, 68 %
local Tuin_Temperatuur_idx = 251
local Tuin_Vochtigheid_idx = 252
commandArray = {}
time = os.date("*t")
if((time.min % 1)==0)then
function round(num, idp) -- Credits go to Martin Rourke, I used his function.
local mult = 10^(idp or 1)
return math.floor(num * mult + 0.5) / mult
end
-- Split data
sWeatherTemp, sWeatherHumidity = otherdevices_svalues['Tuindata']:match("([^;]+);([^;]+)")
your weatherstation sends the data to an "real" domoticz device over RFXcom and your aim is to split the data and write it in two dummy devices... Is this right?
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)
So that's the same error as you wrote in your first post. That's spooky....
Can you post an screenshot form the device in state-table? (Under events, first index tab)
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)
Sorry for the stupid question: Are you trying this in the domoticz event editor?
I've tried in all ways. The runtime error you posted above isn't shown there. If i try over CLI i'll get the error. Imho Domoticz doesn't offer the variables to the native lua instance...
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)
Ok - there's the problem. Give me just an second. I'll post an script for you.
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)
Here's an script for you. In the domoticz event editor just make an new lua script with device as type of trigger, insert my lines and i guess it works.
-- Script for seperating temperature and humidity in several dummy-devices
-- Devices:
WheaterStation = 'Tuindata'
Dummy_Temperature = 'Tuin Temperatuur'
Dummy_Humidity = 'Tuin Vochtigheid'
-- Nothing to change after this line... :-)
commandArray = {}
if devicechanged[WheaterStation] then
-- Split data
Temperature, Humidity = otherdevices_svalues[WheaterStation]:match("([^;]+);([^;]+)")
-- Update Temperature-Device
if Temperature ~= otherdevices_svalues[Dummy_Temperature] then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Dummy_Temperature]..'|0|'..Temperature}
end
-- Update Humidity-Device
if Humidity ~= otherdevices[Dummy_Humidity] then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Dummy_Humidity]..'|'..tonumber(Humidity)..'|0'}
end
end
return commandArray
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)
Individual projects:
Domoticz on a Intel Xeon Server | AeonLabs Z-Wave Gen.5 | RFXCOM RFXtrx433E USB | ESP-Wifi-Modules | Shellys
Wall-mounted 22" Touch Control Display (self construct) | LUA wind monitor| LUA heating control | and many many more :)