Page 1 of 1
trigger also when something is off
Posted: Monday 25 September 2017 15:07
by poudenes
Hi all,
wamt convert my blocky into dzvents.
Can you also to a Off = trigger instead of on = ?
I have lot of blocky based on if device = on and device2 = off and device3 = off then ....
dzvent.jpg
Re: trigger also when something is off
Posted: Monday 25 September 2017 15:51
by emme
ON does is not meant as a state, but a condition:
ON device ==> whenever the device changes its value
then in the execute section you will trigger the right condition
Code: Select all
return {
active = true,
on = {
devices = {
'myDevice'
}
},
execute = function(domoticz, device)
-- device is the triggered device as stated in the ON section
if device.state == 'Off' then
--do stuff
end
end
}
Re: trigger also when something is off
Posted: Monday 25 September 2017 16:37
by poudenes
ok and how can i translate that to make my blocky let work. Because i have many AND if device(x) is on or off then do this.
(sorry im not a programmer but learn to do and try with some help)
Re: trigger also when something is off
Posted: Monday 25 September 2017 16:41
by emme
well it misses the first condition (only the else if is shown)
put the complete blockly and we will see
ciao
M
edit
the portion you shown above looks like
Code: Select all
return {
active = true,
on = {
devices = {
'Full Handmatige Modus',
'Harmony All Off',
'Ziggo',
'Scene Mipow Color',
'Kodi',
'Scene Movie',
'Scene TV',
'Scene Goodnight',
'Sensor iPhone Kay',
'Sensor iPhone Peter'
},
timer = { 'at nighttime' },
},
execute = function(domoticz, switch)
if domoticz.devices('Full Handmatige Modus').state == 'Off' and
domoticz.devices('Harmony All Off').state == 'On' and
domoticz.devices('Scene Goodnight').state == 'Off' and
domoticz.devices('Ziggo').state == 'Off' and
domoticz.devices('Scene Mipow Color').state == 'Off' and
domoticz.devices('Kodi').state == 'Off' and
(domoticz.devices('Scene Movie').state == 'On' or domoticz.devices('Scene TV').state == 'On') and
(domoticz.devices('Scene iPhone Kay').state == 'On' or domoticz.devices('Sensor iPhone Peter').state == 'On')
then
domoticz.devices('Scene Evening').switchOn()
domoticz.log('--==<[SCENES - REGEL 5 - TV/MOVIE UIT NAAR', domoticz.LOG_FORCE)
domoticz.notify('Scenes - Regel 5','Your message body goes here', domoticz.PRIORITY_NORMAL)
end
end
}
Re: trigger also when something is off
Posted: Monday 25 September 2017 21:32
by poudenes
This part is on its own. I have lot of different scenes With lot else if.
Thanks already to show how it has to be. Now i have to find out how i do the else if thing
Screen Shot 2017-09-25 at 21.30.55.jpg
emme wrote: Monday 25 September 2017 16:41
well it misses the first condition (only the else if is shown)
put the complete blockly and we will see
ciao
M
edit
the portion you shown above looks like
Code: Select all
return {
active = true,
on = {
devices = {
'Full Handmatige Modus',
'Harmony All Off',
'Ziggo',
'Scene Mipow Color',
'Kodi',
'Scene Movie',
'Scene TV',
'Scene Goodnight',
'Sensor iPhone Kay',
'Sensor iPhone Peter'
},
timer = { 'at nighttime' },
},
execute = function(domoticz, switch)
if domoticz.devices('Full Handmatige Modus').state == 'Off' and
domoticz.devices('Harmony All Off').state == 'On' and
domoticz.devices('Scene Goodnight').state == 'Off' and
domoticz.devices('Ziggo').state == 'Off' and
domoticz.devices('Scene Mipow Color').state == 'Off' and
domoticz.devices('Kodi').state == 'Off' and
(domoticz.devices('Scene Movie').state == 'On' or domoticz.devices('Scene TV').state == 'On') and
(domoticz.devices('Scene iPhone Kay').state == 'On' or domoticz.devices('Sensor iPhone Peter').state == 'On')
then
domoticz.devices('Scene Evening').switchOn()
domoticz.log('--==<[SCENES - REGEL 5 - TV/MOVIE UIT NAAR', domoticz.LOG_FORCE)
domoticz.notify('Scenes - Regel 5','Your message body goes here', domoticz.PRIORITY_NORMAL)
end
end
}