Page 1 of 1

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

Posted: Wednesday 19 February 2020 15:40
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

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

Posted: Wednesday 19 February 2020 16:31
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."

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

Posted: Wednesday 19 February 2020 16:55
by DwaynePeeters
Waaren, You Sir, are a genius!
Thank you very much! Worked immediately and exactly like I hoped! :D:D:D