trigger also when something is off

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

trigger also when something is off

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: trigger also when something is off

Post 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
}
The most dangerous phrase in any language is:
"We always done this way"
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: trigger also when something is off

Post 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)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: trigger also when something is off

Post 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
}
The most dangerous phrase in any language is:
"We always done this way"
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: trigger also when something is off

Post 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
}
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest