C# developer here and kind of new to the whole scripting thing in Domoticz.
First I tried Blockly, which is nice, but I like more control.
So then I found Lua and tried some little things, which works ok.
Then I found dzVents, which I like more than Lua, so sticking with that for now.
Now I'm running into the following;
I'd like to change a dimmer level when watching a movie or watching TV, both are Logitech Harmony activities (Harmony Elite/Hub).
So I set up 4 events; both a On and Off event for both activities. The On event looks like this:
Code: Select all
return {
active = true,
on = {
devices = {
'TV kijken',
}
},
execute = function(domoticz, device)
local light = domoticz.devices('LED spots')
if (device.state == 'On') then
domoticz.globalData.LEDSpotsLevel = light.level
light.dimTo(40)
end
end
}
Code: Select all
return {
active = true,
on = {
devices = {
'TV kijken',
}
},
execute = function(domoticz, device)
local light = domoticz.devices('LED spots')
if (device.state == 'Off') then
light.dimTo(domoticz.globalData.LEDSpotsLevel)
end
end
}
Question: How can I prevent the 2nd instruction from being ignored, or how can I prevent the 'restore' instruction from being sent at all when there's a follow-up event?2018-02-19 20:04:34.976 Harmony Hub: Changing activity
2018-02-19 20:04:42.558 Harmony Hub: Finished changing activity
2018-02-19 20:04:42.633 dzVents: Info: Handling events for: "Film kijken", value: "Off"
2018-02-19 20:04:42.633 dzVents: Info: ------ Start internal script: Film kijken start: Device: "Film kijken (Harmony)", Index: 10
2018-02-19 20:04:42.641 dzVents: Info: ------ Finished Film kijken start
2018-02-19 20:04:42.641 dzVents: Info: ------ Start internal script: Film kijken stop: Device: "Film kijken (Harmony)", Index: 10
2018-02-19 20:04:42.642 dzVents: Off
2018-02-19 20:04:42.642 dzVents: Info: ------ Finished Film kijken stop
2018-02-19 20:04:42.643 EventSystem: Script event triggered: /usr/local/domoticz/var/scripts/dzVents/runtime/dzVents.lua
2018-02-19 20:04:42.720 dzVents: Info: Handling events for: "TV kijken", value: "On"
2018-02-19 20:04:42.721 dzVents: Info: ------ Start internal script: TV kijken start: Device: "TV kijken (Harmony)", Index: 9
2018-02-19 20:04:42.722 dzVents: Info: ------ Finished TV kijken start
2018-02-19 20:04:42.722 dzVents: Info: ------ Start internal script: TV kijken stop: Device: "TV kijken (Harmony)", Index: 9
2018-02-19 20:04:42.723 dzVents: Info: ------ Finished TV kijken stop
2018-02-19 20:04:42.723 EventSystem: Script event triggered: /usr/local/domoticz/var/scripts/dzVents/runtime/dzVents.lua