Issue with persistent data
Posted: Tuesday 09 January 2018 1:59
Hi,
I have been struggling to get persistent data to work without success.
I am running RPI3, Raspian Stretch Lite 2017-11-29 updated and upgraded recently with domoticz V3.8799
What I am trying to accomplish is to increase a lamp to 100% if there is a motion detected and once the motion is off again, revert to the level the lamp had before, in this case 33%
The script is really simple, but I get 'nil' when I am trying to run it.
Any ideas?
I have been struggling to get persistent data to work without success.
I am running RPI3, Raspian Stretch Lite 2017-11-29 updated and upgraded recently with domoticz V3.8799
What I am trying to accomplish is to increase a lamp to 100% if there is a motion detected and once the motion is off again, revert to the level the lamp had before, in this case 33%
The script is really simple, but I get 'nil' when I am trying to run it.
Any ideas?
Code: Select all
return {
active = true,
on = {
devices = { 'Trapphus Innerdörr' },
timer = {},
variables = {}
},
data = { OldLevel = {initial=0} },
logger = {},
execute = function(domoticz, device, info)
-- code
if (device.state == 'Open') then
OldLevel = domoticz.devices('Kök Fönsterlampa').level
domoticz.log('Level at ON = ' .. tostring(OldLevel), domoticz.LOG_INFO)
domoticz.devices('Kök Fönsterlampa').dimTo(100)
else
domoticz.devices('Kök Fönsterlampa').dimTo(OldLevel)
domoticz.log('Level at OFF = ' .. tostring(OldLevel), domoticz.LOG_INFO)
end
end
}
Code: Select all
2018-01-09 01:44:20.487 dzVents: Info: Handling events for: "Trapphus Innerdörr", value: "Open"
2018-01-09 01:44:20.487 dzVents: Info: ------ Start internal script: Test: Device: "Trapphus Innerdörr (Zwave)", Index: 318
2018-01-09 01:44:20.488 dzVents: Info: Level at ON = 33
2018-01-09 01:44:20.489 dzVents: Info: ------ Finished Test
2018-01-09 01:44:20.490 EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2018-01-09 01:44:25.132 dzVents: Info: Handling events for: "Trapphus Innerdörr", value: "Closed"
2018-01-09 01:44:25.133 dzVents: Info: ------ Start internal script: Test: Device: "Trapphus Innerdörr (Zwave)", Index: 318
2018-01-09 01:44:25.134 dzVents: Info: Level at OFF = nil
2018-01-09 01:44:25.134 dzVents: Info: ------ Finished Test
2018-01-09 01:44:25.135 EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua