Hi!
I’m sorry I haven’t answered here earlier.
I haven’t used my Popp Z-Rain 700168 for two years now since I couldn’t solve the problem that the device get tripped when it’s raining. But I still have the code in my Vera.
I use PLEG to manage logic, dataMine for statistics over time and MultiString for storing values.
Devices:
MultiString:
Rain Levels - 187
Rain Statistics - 188
Rain Strings - 192
Popp Z-Rain - 189 (now uninstalled)
PLEG:
Properties
pRainLast5Minutes - Rain Statistics[188], Variable1
pRainLast20Minutes - Rain Strings[192], Variable3
Schedules
sEveryMinute - Interval 01:00
sEvery5Minutes - Interval 5:00
sEvery20Minutes - Interval 20:00
sEveryHour - Interval 01:00:00
sMidnight - Day of Week 00:00:00, On Days 1,2,3,4,5,6,7 - Day of Week 00:02:00, On Days 1,2,3,4,5,6,7
sFirstOfWeek - Day of Week 00:00:00, On Days 1
sFirstOfMonth - Day of Month, On Days 1
Conditions
cRainCopy - sEveryMinute
cRain5MinutesLevel - Repeats, sEvery5Minutes
cRain20MinutesLevel - sEvery20Minutes
cRainHourLevel - Repeats, sEveryHour
cRainDayLevel - sMidnight
cRainWeekLevel - sFirstOfWeek
cRainMonthLevel - sFirstOfMonth
cRaining - pRainLast20Minutes > 0
Action: cRainCopy
LUA:
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
lastLevel = tonumber(lastLevel)
local level = luup.variable_get(“urn:micasaverde-com:serviceId:GenericSensor1”, “CurrentLevel”, 189)
level = tonumber(level)
if lastLevel < level / 1000 then
– Fix power of 1000 problem
level = level / 1000
end
if lastLevel < level and lastLevel > level / 2 then
– Update pRainLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName1”, “RainLevel”, 192)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, level, 192)
end
Action: cRain5MinutesLevel
LUA:
– Calculate rain of last 5 minutes
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 187)
local level = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
– Update pRain5MinutesLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName1”, “5MinutesLevel”, 187)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, level, 187)
– Update pRainLast5Minutes
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName1”, “Last5Minutes”, 188)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, level - lastLevel, 188)
Action: cRain20MinutesLevel
LUA:
– Calculate rain of last 20 minutes
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable2”, 192)
local level = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
– Update pRain20MinutesLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName2”, “20MinutesLevel”, 192)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable2”, level, 192)
– Update pRainLast20Minutes
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName3”, “Last20Minutes”, 192)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable3”, level - lastLevel, 192)
Action: cRainHourLevel
LUA:
– Calculate rain of last hour
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable2”, 187)
local level = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
– Update pRainHourLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName2”, “HourLevel”, 187)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable2”, level, 187)
– Update pRainLastHour
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName2”, “LastHour”, 188)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable2”, level - lastLevel, 188)
– Reset Can’t Detect Device
local commfailure = luup.variable_get(“urn:micasaverde-com:serviceId:HaDevice1”, “CommFailure”, 189)
if (commfailure == “1”) then
luup.call_delay( ‘reset_ComFail’, 120)
function reset_ComFail()
luup.variable_set(“urn:micasaverde-com:serviceId:HaDevice1”, “CommFailure”, “0”, 189)
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “Reload”, {}, 0)
end
end
Action: cRainWeekLevel
LUA:
– Calculate rain of last week
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 187)
local level = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
– Update pRainWeekLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName4”, “WeekLevel”, 187)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, level, 187)
– Update pRainLastWeek
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName4”, “LastWeek”, 188)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, level - lastLevel, 188)
Action: cRainMonthLevel
LUA:
– Calculate rain of last month
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable5”, 187)
local level = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
– Update pRainMonthLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName5”, “MonthLevel”, 187)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable5”, level, 187)
– Update pRainLastMonth
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName5”, “LastMonth”, 188)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable5”, level - lastLevel, 188)
Action: cRainDayLevel
LUA:
– Calculate rain of last day
local lastLevel = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable3”, 187)
local level = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable1”, 192)
– Update pRainDayLevel
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName3”, “DayLevel”, 187)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable3”, level, 187)
– Update pRainLastDay
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “VariableName3”, “LastDay”, 188)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”, “Variable3”, level - lastLevel, 188)
Please let me know if you solve ”the tripped problem”.
Best regards
Mårten