Trigger a switch using the "On/off action" of another switch

Moderator: leecollings

Post Reply
DwaynePeeters
Posts: 3
Joined: Wednesday 19 February 2020 15:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Trigger a switch using the "On/off action" of another switch

Post by DwaynePeeters »

Hi,

Does anyone know if the following is possible:
I have an automated rolling garagedoor which I added to domoticz using a double fibaro relay.
In domoticz I now have two switches, on to open the door, one to close it.
This looks messy and I would like to combine them together.
To make it even more neat, I would like to use the "blinds" switch type, so that the animation looks like the garagedoor.
This could all be made possible if I hide both of the switches using a "$-sign", and then create a virtual switch and set the "On action" to trigger the hidden open switch, and set the "off action" to trigger the hidden close switch.
I am very weak at creating scripts and was wondering if anyone could give me a lead.

Kind regards and thanks in advance for any help, :D

Dwayne
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Trigger a switch using the "On/off action" of another switch

Post by waaren »

DwaynePeeters wrote: Wednesday 19 February 2020 15:40 I have an automated rolling garagedoor which I added to domoticz using a double fibaro relay.
In domoticz I now have two switches, on to open the door, one to close it.
To make it even more neat, I would like to use the "blinds" switch type, so that the animation looks like the garagedoor.
Can you try this ?

Code: Select all

--[[
    I have an automated rolling garagedoor which I added to domoticz using a double fibaro relay.
    In domoticz I now have two switches, on to open the door, one to close it.
    
    To make it even more neat, I would like to use the "blinds" switch type, so that the animation looks like the garagedoor.
    This could all be made possible if I hide both of the switches using a "$-sign", and then create a virtual switch and set the "On action" to trigger the hidden open switch, 
    and set the "off action" to trigger the hidden close switch.


    assuming blindname == garageDoor
    and actual switch-names: $open  $close
]]

return 
{
	on = 
	{
		devices = 
		{
			'garageDoor', -- change to the name of the virtual switch you defined 
	    },
	},
	
	logging = 
	{
        level = domoticz.LOG_DEBUG, -- change to LOG_ERROR when script is fucntioning as expected
        marker = 'garage Door',
    },

	execute = function(dz, item)
		dz.log(item.name .. ' is now ' .. item.state , dz.LOG_DEBUG)
		if item.active then
		   dz.log('Open garagedoor', dz.LOG_DEBUG) 
		   dz.devices('$open').switchOn() 
		else
		   dz.log('Close garagedoor', dz.LOG_DEBUG) 
		   dz.devices('$close').switchOn() 
	    end
	end
}
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
DwaynePeeters
Posts: 3
Joined: Wednesday 19 February 2020 15:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Trigger a switch using the "On/off action" of another switch

Post by DwaynePeeters »

Waaren, You Sir, are a genius!
Thank you very much! Worked immediately and exactly like I hoped! :D:D:D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest