Page 1 of 1

No Svalue in Soil Moisture

Posted: Thursday 04 January 2018 11:23
by Trippy1969
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"
}

Re: No Svalue in Soil Moisture

Posted: Thursday 04 January 2018 22:54
by gerardvs
Something like this? (Don't forget the ' ' )
sSoilmoist = math.floor(tonumber(otherdevices_svalues['soilmoist_dv']))

Re: No Svalue in Soil Moisture

Posted: Friday 05 January 2018 0:58
by Trippy1969
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.