Switching a device without triggering  [Solved]

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

Moderator: leecollings

Post Reply
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Switching a device without triggering

Post by rgroothuis »

I've two switches in one room to switch on/off two sets of lights. When one of the two switches is pushed, can I switches the other one without triggering an event so that the system is going into a never ending switch on/off loop? Thanks.
User avatar
erem
Posts: 230
Joined: Tuesday 27 March 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Amsterdam/netherlands
Contact:

Re: Switching a device without triggering  [Solved]

Post by erem »

from dzVents docs: https://www.domoticz.com/wiki/DzVents:_ ... _scripting

silent(): Function. No follow-up events will be triggered: mySwitch.switchOff().silent().
Regards,

Rob
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

erem wrote: Monday 22 March 2021 15:13 from dzVents docs: https://www.domoticz.com/wiki/DzVents:_ ... _scripting

silent(): Function. No follow-up events will be triggered: mySwitch.switchOff().silent().
Excellent, thanks, that is what I was looking for. Going to test it right now.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

Unfortunately it doesn't work, I'm ending up into a loop where lights are continuously being switch on and off. This is my script:

Code: Select all

return {
 	logging = {
 		level = domoticz.LOG_ERROR,
 		marker = 'ControlLightSwitches'
 	},
	on = {
		devices = {
			'Badkamer1ste-Spiegel Lamp',
			'Badkamer1ste-Bad Lamp'
			
		}
	},
	execute = function(domoticz, device)
        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
        domoticz.log('Device ' .. device.name .. ' was changed. Level is: ' .. device.level .. '.', domoticz.LOG_DEBUG)
	    
    	if (device.name == 'Badkamer1ste-Spiegel Lamp') and (device.state == 'On') then
            domoticz.devices('Badkamer1ste-Bad Lamp').switchOn().silent()
    	elseif (device.name == 'Badkamer1ste-Spiegel Lamp') and (device.state == 'Off') then
            domoticz.devices('Badkamer1ste-Bad Lamp').switchOff().silent()
    	elseif (device.name == 'Badkamer1ste-Bad Lamp') and (device.state == 'On') then
            domoticz.devices('Badkamer1ste-Spiegel Lamp').switchOn().silent()
    	elseif (device.name == 'Badkamer1ste-Bad Lamp') and (device.state == 'Off') then
            domoticz.devices('Badkamer1ste-Spiegel Lamp').switchOff().silent()
   	    end


        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
	end
}
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

I'm using "Qubino (Goap)" devices in this room, what I noticed is when I push the button to switch on (or off) then the button in Domoticz is switch on again (after it was off for a second) and the after one or two second the button is switch off. I guess because of this behaviour I end up with this endless loop situation. Not sure how to solve this.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Switching a device without triggering

Post by AllesVanZelf »

If you make the condition as:

Code: Select all

if spiegellamp == off and badlamp == On then
    badlamp.switchOff().silent()
elseif spiegellamp == On and badlamp == Off then
   badlamp.switchOn().silent()
elseif badlamp == On and spiegellamp == Off then
  spiegellamp.switchOn().silent()
elseif badlamp == Off and spiegellamp == On then
  spiegellamp.switchOff().silent()

Off course you should change it to match it in your script. Won't that work?

I should have used a 'local' line like:

Code: Select all

local spiegellamp = dz.devices('Badkamer1ste-Spiegel Lamp')
to make code easier.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

AllesVanZelf wrote: Monday 22 March 2021 15:53 If you make the condition as:

Code: Select all

if spiegellamp == off and badlamp == On then
    badlamp.switchOff().silent()
elseif spiegellamp == On and badlamp == Off then
   badlamp.switchOn().silent()
elseif badlamp == On and spiegellamp == Off then
  spiegellamp.switchOn().silent()
elseif badlamp == Off and spiegellamp == On then
  spiegellamp.switchOff().silent()

Off course you should change it to match it in your script. Won't that work?

I should have used a 'local' line like:

Code: Select all

local spiegellamp = dz.devices('Badkamer1ste-Spiegel Lamp')
to make code easier.
Good suggestion, will give this a try as well to optimise it. Thanks.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Switching a device without triggering

Post by AllesVanZelf »

No, I'm sorry. The first two and the last two are basically the same. That would be a conflict.

Code: Select all

if spiegellamp == Off and badlamp == On then
    badlamp.switchOff().silent()
elseif spiegellamp == On and badlamp == Off then
   badlamp.switchOn().silent()

elseif spiegellamp == Off and badlamp == On then
  spiegellamp.switchOn().silent()
elseif spiegellamp == On and badlamp == Off then
  spiegellamp.switchOff().silent()
Somehow your script depends on the device that is triggered in the first place.

My simple trial and error would be to split the script.

Code: Select all

If spiegellamp is triggered On and badlamp is Off then switch badlamp On
elseif spiegellamp is triggered Off and badlamp is On then switch badlamp Off
and the other script:

Code: Select all

If badlamp is triggered On and spiegellamp is Off then switch spiegellamp On.
If badlamp is triggered Off and spiegellamp is On then switch spiegellamp Off.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switching a device without triggering

Post by waaren »

rgroothuis wrote: Monday 22 March 2021 15:07 I've two switches in one room to switch on/off two sets of lights. When one of the two switches is pushed, can I switches the other one without triggering an event so that the system is going into a never ending switch on/off loop? Thanks.
Please share the log together with the script creating the loglines. Share the line from some seconds before the start of the script until some seconds after the script finished. It might help determining what happens when the script executes on your system.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Switching a device without triggering

Post by AllesVanZelf »

maybe like this:

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Badkamer1ste-Spiegel Lamp',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
    },
    
       execute = function(dz)
        local spiegellamp = dz.devices('Badkamer1ste-Spiegel Lamp')
        local badlamp = dz.devices('Badkamer1ste-Bad Lamp')

      dz.log('State of spiegellamp is '  .. spiegellamp.state, dz.LOG_DEBUG)
      dz.log('State of badlamp is '  .. badlamp.state, dz.LOG_DEBUG)

        if spiegellamp.state == 'On' and badlamp.state == 'Off' then
            badlamp.switchOn()
        elseif spiegellamp.state == 'Off' and badlamp.state == 'On' then
            badlamp.switchOff()

        end
    end
}

Code: Select all

return
{
    on =
    {
        devices =
        {
			'Badkamer1ste-Bad Lamp'
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
    },
    
    execute = function(dz)
        local spiegellamp = dz.devices('Badkamer1ste-Spiegel Lamp')
        local badlamp = dz.devices('Badkamer1ste-Bad Lamp')

     dz.log('State of spiegellamp is '  .. spiegellamp.state, dz.LOG_DEBUG)
      dz.log('State of badlamp is '  .. badlamp.state, dz.LOG_DEBUG)

        if badlamp.state == 'On' and spiegellamp.state == 'Off' then
            spiegellamp.switchOn()
        elseif badlamp.state == 'Off' and spiegellamp.state == 'On' then
            spiegellamp.switchOff()

        end
    end
}
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

@waaren, this is the script and the log. It is still not working, the two lamps are going on and off sequentially.

Code: Select all

return {
 	logging = {
 		level = domoticz.LOG_DEBUG,  -- switch to domoticz.LOG_ERROR when all OK
 		marker = 'ControlLightSwitches'
 	},
	on = {
		devices = {
			'HueLichtKnop',
			'Badkamer1ste-Spiegel Lamp',
			'Badkamer1ste-Bad Lamp'
			
		}
	},
	execute = function(domoticz, device)
        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
        domoticz.log('Device ' .. device.name .. ' was changed. Level is: ' .. device.level .. ', sate is: ' .. device.state .. '.', domoticz.LOG_DEBUG)
	    
		local BedKastReneDorien = domoticz.devices('BedKastReneDorien')
		local badLamp = domoticz.devices('Badkamer1ste-Bad Lamp')
		local spiegelLamp = domoticz.devices('Badkamer1ste-Spiegel Lamp')

		if (device.name == 'HueLichtKnop') and ((device.level == 10) or (device.level == 20)) then
            domoticz.log('Button level ' .. device.level .. ' was pressed.', domoticz.LOG_DEBUG)

            BedKastReneDorien.switchOn()
		elseif (device.name == 'HueLichtKnop') and (device.level == 40) then
            domoticz.log('Button level ' .. device.level .. ' was pressed.', domoticz.LOG_DEBUG)

			--local BedKastReneDorien = domoticz.devices('BedKastReneDorien')
            --BedKastReneDorien.switchOff()
    	elseif (device.name == 'Badkamer1ste-Spiegel Lamp') and (device.state == 'On') and (badLamp.state == 'Off') then
            domoticz.log('Button: ' .. device.name .. ' was pressed and device state is ' .. device.state .. '.', domoticz.LOG_DEBUG)

            badLamp.switchOn().silent()
    	elseif (device.name == 'Badkamer1ste-Spiegel Lamp') and (device.state == 'Off') and (badLamp.state == 'On') then
            domoticz.log('Button: ' .. device.name .. ' was pressed and device state is ' .. device.state .. '.', domoticz.LOG_DEBUG)

            badLamp.switchOff().silent()
    	elseif (device.name == 'Badkamer1ste-Bad Lamp') and (device.state == 'On') and (spiegelLamp.state == 'Off') then
            domoticz.log('Button: ' .. device.name .. ' was pressed and device state is ' .. device.state .. '.', domoticz.LOG_DEBUG)

            spiegelLamp.switchOn().silent()
    	elseif (device.name == 'Badkamer1ste-Bad Lamp') and (device.state == 'Off') and (spiegelLamp.state == 'On') then
            domoticz.log('Button: ' .. device.name .. ' was pressed and device state is ' .. device.state .. '.', domoticz.LOG_DEBUG)

            spiegelLamp.switchOff().silent()
   	    end


        domoticz.log('============================================================================================', domoticz.LOG_DEBUG)
	end
}
and this is the log:

Code: Select all

2021-03-22 16:45:29.614 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Spiegel Lamp was changed. Level is: 100, sate is: On.
2021-03-22 16:45:29.615 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:29.616 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Bad Lamp: Switch device adapter
2021-03-22 16:45:29.616 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Spiegel Lamp was pressed and device state is On.
2021-03-22 16:45:29.616 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:29.616 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:29.616 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:29.617 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:29.618 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:29.833 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:29.833 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:29.833 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:29.834 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:29.834 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:29.834 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is Off.
2021-03-22 16:45:29.834 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:29.834 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:29.834 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:29.835 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:29.837 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:34.847 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:34.847 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:34.847 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 100, sate is: On.
2021-03-22 16:45:34.848 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:34.849 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:34.849 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is On.
2021-03-22 16:45:34.849 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:34.849 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:34.849 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:34.849 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:34.851 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:35.235 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Spiegel Lamp (HoekHuisZwave)", Index: 21
2021-03-22 16:45:35.235 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:35.235 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Spiegel Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:35.236 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:35.236 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Bad Lamp: Switch device adapter
2021-03-22 16:45:35.236 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Spiegel Lamp was pressed and device state is Off.
2021-03-22 16:45:35.236 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:35.236 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:35.236 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:35.237 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:35.237 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:35.415 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:35.415 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:35.415 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 100, sate is: On.
2021-03-22 16:45:35.416 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:35.416 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:35.417 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is On.
2021-03-22 16:45:35.417 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:35.417 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:35.417 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:35.417 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:35.418 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:40.564 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:40.565 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:40.565 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:40.565 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:40.566 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:40.566 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is Off.
2021-03-22 16:45:40.566 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:40.566 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:40.566 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:40.567 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:40.567 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:41.047 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Spiegel Lamp (HoekHuisZwave)", Index: 21
2021-03-22 16:45:41.047 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:41.047 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Spiegel Lamp was changed. Level is: 100, sate is: On.
2021-03-22 16:45:41.048 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:41.048 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Bad Lamp: Switch device adapter
2021-03-22 16:45:41.048 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Spiegel Lamp was pressed and device state is On.
2021-03-22 16:45:41.048 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:41.048 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:41.048 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:41.049 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:41.050 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:41.369 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:41.369 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:41.369 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:41.370 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:41.370 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:41.370 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is Off.
2021-03-22 16:45:41.370 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:41.370 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:41.371 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:41.371 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:41.372 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:43.586 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:43.587 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:43.587 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 70, sate is: On.
2021-03-22 16:45:43.588 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:43.589 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:43.589 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is On.
2021-03-22 16:45:43.589 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:43.589 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:43.589 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:43.590 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:43.591 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:43.936 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Spiegel Lamp (HoekHuisZwave)", Index: 21
2021-03-22 16:45:43.936 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:43.936 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Spiegel Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:43.937 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:43.937 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Bad Lamp: Switch device adapter
2021-03-22 16:45:43.937 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Spiegel Lamp was pressed and device state is Off.
2021-03-22 16:45:43.937 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:43.937 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:43.938 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:43.938 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:43.939 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:44.095 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:44.095 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:44.095 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 70, sate is: On.
2021-03-22 16:45:44.096 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:44.096 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:44.096 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is On.
2021-03-22 16:45:44.096 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:44.096 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:44.096 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:44.097 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:44.098 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:44.577 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Spiegel Lamp (HoekHuisZwave)", Index: 21
2021-03-22 16:45:44.577 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:44.577 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Spiegel Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:44.578 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:44.579 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Bad Lamp: Switch device adapter
2021-03-22 16:45:44.579 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Spiegel Lamp was pressed and device state is Off.
2021-03-22 16:45:44.579 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:44.579 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:44.579 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:44.580 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:44.581 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:44.825 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:44.826 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:44.826 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 87, sate is: On.
2021-03-22 16:45:44.826 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:44.827 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:44.827 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is On.
2021-03-22 16:45:44.827 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:44.827 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:44.827 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:44.828 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:44.829 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:49.545 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Bad Lamp (HoekHuisZwave)", Index: 8
2021-03-22 16:45:49.545 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:49.545 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Bad Lamp was changed. Level is: 0, sate is: Off.
2021-03-22 16:45:49.546 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:49.547 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Spiegel Lamp: Switch device adapter
2021-03-22 16:45:49.547 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Bad Lamp was pressed and device state is Off.
2021-03-22 16:45:49.547 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off
2021-03-22 16:45:49.548 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: Off NOTRIGGER
2021-03-22 16:45:49.548 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:49.548 Status: dzVents: Info: ControlLightSwitches: ------ Finished ControlLightSwitches
2021-03-22 16:45:49.550 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-03-22 16:45:49.962 Status: dzVents: Info: ControlLightSwitches: ------ Start internal script: ControlLightSwitches: Device: "Badkamer1ste-Spiegel Lamp (HoekHuisZwave)", Index: 21
2021-03-22 16:45:49.962 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
2021-03-22 16:45:49.962 Status: dzVents: Debug: ControlLightSwitches: Device Badkamer1ste-Spiegel Lamp was changed. Level is: 100, sate is: On.
2021-03-22 16:45:49.963 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for BedKastReneDorien: Switch device adapter
2021-03-22 16:45:49.963 Status: dzVents: Debug: ControlLightSwitches: Processing device-adapter for Badkamer1ste-Bad Lamp: Switch device adapter
2021-03-22 16:45:49.963 Status: dzVents: Debug: ControlLightSwitches: Button: Badkamer1ste-Spiegel Lamp was pressed and device state is On.
2021-03-22 16:45:49.963 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On
2021-03-22 16:45:49.963 Status: dzVents: Debug: ControlLightSwitches: Constructed timed-command: On NOTRIGGER
2021-03-22 16:45:49.963 Status: dzVents: Debug: ControlLightSwitches: ============================================================================================
I really believe this is because of the strange behaviour of the Qubino (Goap) ZMNHHDx Mini Dimmer device. Again when I press the device in Domoticz, the state goes off, then the state goes automatically on again and follwed by going off again. This is the only device I'm experiencing this behaviour with. All my other devices are Fibaro's and when I switch off the device in Domoticz the device is immediately off.
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

When searching for Qubino (Goap) ZMNHHDx domoticz I found the following:

xxx.silent doesn't work on Zwave devices: viewtopic.php?f=6&t=27607&start=20
Qubino Flush Dim State issue viewtopic.php?f=24&t=29715&start=20

So there are some more issue around the Qubino and status updates as well as ZWave and Silent function.

I'm running the following Domoticz version:

Version: 2020.2
Build Hash: b63341bc0
Compile Date: 2020-04-26 13:47:55
dzVents Version: 3.0.2
Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switching a device without triggering

Post by waaren »

rgroothuis wrote: Monday 22 March 2021 16:52 @waaren, this is the script and the log. It is still not working, the two lamps are going on and off sequentially.

I really believe this is because of the strange behaviour of the Qubino (Goap) ZMNHHDx Mini Dimmer device. Again when I press the device in Domoticz, the state goes off, then the state goes automatically on again and follwed by going off again. This is the only device I'm experiencing this behaviour with. All my other devices are Fibaro's and when I switch off the device in Domoticz the device is immediately off.
Could well be.

Can you try this one?

Code: Select all

local spiegellamp = 'Badkamer1ste-Spiegel Lamp'
local badlamp = 'Badkamer1ste-Bad Lamp'
local hueButton = 'HueLichtKnop'

return
{
    on =
    {
        devices =
        {
            hueButton,
            badlamp,
            spiegellamp,
        },
    },

    data =
    {
        switched =
        {
            initial = 0,
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,  -- switch to domoticz.LOG_ERROR when all OK
        marker = 'ControlLightSwitches'
    },

    execute = function(dz, item)
        dz.log('============================================================================================', dz.LOG_DEBUG)
        dz.log('item ' .. item.name .. ' was changed. Level is: ' .. item.level .. ', state is: ' .. item.state .. '.', dz.LOG_DEBUG)


        local BedKastReneDorien = dz.devices('BedKastReneDorien')
        local badlamp = dz.devices(badlamp)
        local spiegellamp = dz.devices(spiegellamp)
        local hueButton = dz.devices(hueButton)

        local lampPairs =
        {
            [badlamp.name] = spiegellamp,
            [spiegellamp.name] = badlamp,
        }

        if item == hueButton then
            dz.log('Button level ' .. item.level .. ' was pressed.', dz.LOG_DEBUG)
            if item.level == 10 or item.level == 20 then
                BedKastReneDorien.switchOn()
            elseif item.level == 40 then
            --local BedKastReneDorien = dz.devices('BedKastReneDorien')
            --BedKastReneDorien.switchOff()
            end
            return
        end

        if os.time() < ( dz.data.switched + 3 ) then
            dz.log('Too soon, No action now!', dz.LOG_DEBUG)
            return
        end

        dz.log('Button: ' .. item.name .. ' was pressed and item state is ' .. item.state .. '.', dz.LOG_DEBUG)
        if item.state == 'On' then
            lampPairs[item.name].switchOn().checkFirst().silent()
        else
            lampPairs[item.name].switchOff().checkFirst().silent()
        end
        dz.data.switched = os.time()

        dz.log('============================================================================================', dz.LOG_DEBUG)
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Switching a device without triggering

Post by rgroothuis »

Excellent! Wauw, that script is working!

Still need to understand the logic on what you have changed. Is it about checking the time (if os.time() < ( dz.data.switched + 3) )?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Switching a device without triggering

Post by waaren »

rgroothuis wrote: Monday 22 March 2021 17:53 Excellent! Wauw, that script is working!

Still need to understand the logic on what you have changed. Is it about checking the time (if os.time() < ( dz.data.switched + 3) )?
Yes. Together with storing the last switched time in dzVents persistent data, that is the essential part of why this works.
Some hardware do ignore the silent() method and generate an event regardless. This script checks if the last switch occurred within 3 seconds and if so, it will not do the device actions.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest