Script1:
Code: Select all
return {
on = {
timer = {'every minute'}
},
execute = function(domoticz, dummy)
local thermostat = domoticz.devices('SRT323')
print('pile=' .. thermostat.batteryLevel)
domoticz.devices('Pile Thermostat').updatePercentage(thermostat.batteryLevel)
end
}With the API JSON:
Code: Select all
http://192.168.0.4:8080/json.htm?type=devices&rid=96BatteryLevel 17
Confirmed with the Email notification:
Battery Low: SRT323 (Level: 17 %)
Is my coding of the above script wrong or is this a dzvent bug?
Here is another dzvent script (my old script) with no .batterylevel usage:
Script2:
Code: Select all
return {
on = {
timer = {'every minute'},
httpResponses = {'thermostat' }
},
execute = function(domoticz, item)
if (item.isTimer) then
print('http envoi thermostat')
domoticz.openURL({
url = 'http://192.168.0.4:8080/json.htm?type=devices&rid=96',
callback = 'thermostat'
})
end
if (item.isHTTPResponse and item.ok) then
local pile =item.json.result[1]['BatteryLevel']
print('http response thermostat: ' .. pile)
end
end
}If you are interest in my SRT323 parameter to have an idea of the battery life time:
1. Temperature sensor reading:enabled
2. Temperature Scale: Celcius
3. Delta T: Temperature change: 5 (=0.5°C)
2000. Wake-up Interval: (Seconds) 500
But the SRT323 battery life time depends on the number of switching too: in my case: no switching during summer=less battery usage.
Note 2 (edit):
17% is 1.22V for on battery
96% is 1.58V for one battery