Hi,
I have a Soil Moisture device using Mysensors Arduino code, this shows up in Domoticz as a soil moisture sensor with no issues (see JSON output below).
I've been trying to read the sValue in a separate script using LUA to export this value to a txt file for another purpose. Unfortunately the code will return a 'nil' value using this line of code:
sSoilmoist = otherdevices_svalues[soilmoist_dv]
(soilmoist_dv is declared as my soil moisture device name).
I notice in the devices 'show current state' this device has no sValue so i assume this is the issue. Is there another way to extract the value or get better still get the sValue populated? Can anyone help please?
{
"ActTime" : 1515016367,
"ServerTime" : "2018-01-03 21:52:47",
"Sunrise" : "08:04",
"Sunset" : "16:07",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 84,
"CustomImage" : 0,
"Data" : "135 cb",
"Desc" : "dangerously dry",
"Description" : "",
"Favorite" : 0,
"HardwareID" : 93,
"HardwareName" : "MySensors MQTT",
"HardwareType" : "MySensors Gateway with MQTT interface",
"HardwareTypeVal" : 92,
"HaveTimeout" : false,
"ID" : "00000501",
"LastUpdate" : "2018-01-03 21:51:41",
"Name" : "Soil Moisture",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "Soil Moisture",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "General",
"TypeImg" : "moisture",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "2160"
}
],
"status" : "OK",
"title" : "Devices"
}
No Svalue in Soil Moisture
Moderator: leecollings
-
- Posts: 3
- Joined: Saturday 12 December 2015 9:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: Worthing, UK
- Contact:
No Svalue in Soil Moisture
Raspberry Pi B+, RFXCOM RFXtrx433E, Z-Wave, Lightwave RF door switches, OWL power meter, Android Mobile, Davis Weather Station, Wunderground Weather
-
- Posts: 81
- Joined: Sunday 04 January 2015 0:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest-1
- Location: /dev/null
- Contact:
Re: No Svalue in Soil Moisture
Something like this? (Don't forget the ' ' )
sSoilmoist = math.floor(tonumber(otherdevices_svalues['soilmoist_dv']))
sSoilmoist = math.floor(tonumber(otherdevices_svalues['soilmoist_dv']))
-
- Posts: 3
- Joined: Saturday 12 December 2015 9:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: Worthing, UK
- Contact:
Re: No Svalue in Soil Moisture
thanks - just tried that and the script returns much the same as before;
2018-01-04 23:54:45.133 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_wxexport.lua: /home/pi/domoticz/scripts/lua/script_device_wxexport.lua:56: bad argument #1 to 'floor' (number expected, got nil)
Seems that sValue is null or blank. I may have to change the device to 'humidity' to get around this.
2018-01-04 23:54:45.133 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_wxexport.lua: /home/pi/domoticz/scripts/lua/script_device_wxexport.lua:56: bad argument #1 to 'floor' (number expected, got nil)
Seems that sValue is null or blank. I may have to change the device to 'humidity' to get around this.
Raspberry Pi B+, RFXCOM RFXtrx433E, Z-Wave, Lightwave RF door switches, OWL power meter, Android Mobile, Davis Weather Station, Wunderground Weather
Who is online
Users browsing this forum: No registered users and 1 guest