For anyone finding this thread:
device.rain provides the actual rain of today (not the counter)
to get the counter, you have to retrieve this from the sValue of the device with
Code: Select all
local f_rainValTable = domoticz.utils.stringSplit(rain_sensor.sValue,';')
local actual_rain = f_rainValTable[2]
(First value is rain-rate, second value is the counter value)
A complete dzVents example which increments the counter via a door-sensor is provided below:
Code: Select all
return {
on = {
devices = {
'RegenSensorSwitch'
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'rain-zigbee',
},
execute = function(domoticz, device)
--domoticz.log('Device ' .. device.name .. ' was changed: ' .. device.state, domoticz.LOG_INFO)
if (device.state == 'Closed') then
local rain_sensor = domoticz.devices("RainZigbee")
local f_rainValTable = domoticz.utils.stringSplit(rain_sensor.sValue,';')
local actual_rain = f_rainValTable[2]
--domoticz.log('total rain: ' .. actual_rain, domoticz.LOG_INFO)
local rain2add = 0.30303
local new_rain = domoticz.utils.round((rain2add + actual_rain),2)
--domoticz.log('new_rain: ' .. new_rain, domoticz.LOG_INFO)
rain_sensor.updateRain(0, new_rain)
end
end
}