Page 1 of 1
Three way switch (or hotel/stairway lights)
Posted: Sunday 01 December 2013 16:18
by XL-Network
Hi,
I have created a three way switch using one KAKU receiver (dimmer) and two KAKU switches. The receiver has learnt both codes and responds to On/Off-signals from both switches. In Domoticz I have added both switches and given each of them a unique name. The problem is that when I use switch 1 to turn on the light and switch 2 to turn off the light switch one stays 'on' in Domoticz. I tried to use Sub/Slave device to enable the other switch (and vice versa) but that doesn't work correctly. Can anyone tell me how to configure a three way switch so that both the switches are linked (so they share the same status). Ideally you would want to create one switch in Domoticz which responds to both codes (making one switch the 'main' switch for sending signals from Domoticz).
Thanks in advance,
Wilfred
Re: Three way switch (or hotel/stairway lights)
Posted: Sunday 01 December 2013 19:07
by elythomaslumber
Don't know if you run Domoticz on a RaspberryPi. If you do so one solution could be a bash script using the "domoticz_main" script.
If your RFXCOM receives an on or off from switch 1 or 2 the other will be switched to the same status.
Since I'm a noob to Linux I cannot guaranty that it works "out of the box" (especially since it is a dimmer). Also other solutions are possible like LUA or blockly.
Regards
Hardy
Code: Select all
#!/bin/sh
startup_path=$1
hardware_id=$2
device_id=$3
status=$4
status2=$5
devname=$6
#--------------------------------------------
if [ "$device_id" = 1 ] ; then # if switch 1 was pressed
if [ "$status" = "On" ] ; then # …ON
curl http://192.168.1.18:8080/json.htm?type=command¶m=switchlight&idx=2&switchcmd=On&level=0"; # switch on 2nd switch
else
curl "http://192.168.1.18:8080/json.htm?type=command¶m=switchlight&idx=2&switchcmd=Off&level=0"; # switch off 2nd switch
fi
fi
if [ "$device_id" = 2 ] ; then # if switch 2 was pressed
if [ "$status" = "On" ] ; then # …ON
curl http://192.168.1.18:8080/json.htm?type=command¶m=switchlight&idx=1&switchcmd=On&level=0"; # switch on 1st switch
else
curl "http://192.168.1.18:8080/json.htm?type=command¶m=switchlight&idx=1&switchcmd=Off&level=0"; # switch off 1st switch
fi
fi
Re: Three way switch (or hotel/stairway lights)
Posted: Sunday 01 December 2013 19:16
by XL-Network
I have Domoticz installed on my Raspberry Pi so I can use a bash-script. The problem is (I think) that doing it this way would send another 'on' command which the receiver for the light will pick up and it will start dimming. I want to enable the second switch without actually (re)sending a second 'on' command.
Re: Three way switch (or hotel/stairway lights)
Posted: Sunday 01 December 2013 21:22
by bizziebis
Domoticz sends a real ON or OFF command to your KAKU dimmer. It won't start a dimming cyclus when you send another ON command.
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 8:30
by XL-Network
bizziebis wrote:Domoticz sends a real ON or OFF command to your KAKU dimmer. It won't start a dimming cyclus when you send another ON command.
That is not correct. When all the light is turned of and both switches are off in Domoticz and I press switch 1 (in Domoticz) the light comes on (no dimming). When I turn the second switch on the light starts dimming. This is because the receiver (the KAKU dimmer) has received two 'on'-commands. It doesn't matter that they are from different switches (the dimmer has learnt both switches).
The best solution would be to 'merge' two switches in Domoticz so they are one (with one being master). That would require coding on the application side I believe. Maybe I can put in a feature request?
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 12:34
by bizziebis
You could create two groups. For example "Light - Switch 1" and "Light - Switch 2". You also make a new "Light1" with a manual code which you will learn to the dimmer. In both groups you add the "Light1" you want to control.
Each group you 'learn' the code of the switch on the wall. You have to remove the two learned switches from the dimmer.
When you hit switch 1 it will switch on the group and also the light through Domoticz. Group 2 also notice that light1 is on. So when you hit switch 2 to off the light will switch off.
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 12:51
by XL-Network
Sounds like a good idea but there are a few problems. You can only add a light to the group and specify a percentage the light must be dimmed (not to send only the 'on' command). So it is not possible to use the dimming function. Also there would be a extra delay from switching the light on/off.
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 12:57
by bizziebis
If you add the light with 100% it acts like "ON". It's embedded in the command Domoticz send. So it doesn't first switch it on and then set the dimming level. It's instant switched on to the leveI you specify.I use it this way in my livingroom. You can of course use any value if you want the light to switch on dimmed. The delay is almost nothing.
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 14:19
by goedh452
Can you explain why the sub/slave mechanism does not work correctly? I think it was designed especially for these kinds of situations. All my dimmers have at least 2 switches controlling them. This is how I managed to do that:
1) Learn switch 1 to the dimmer
2) Learn switch 2 to the dimmer
3) Open devices tab in Domoticz
4) Find switch one and press the green arrow
5) Give it a name and add it as Master
6) Find switch 2 and press the green arrow
7) Give it a different name and add is as sub/slave to the name you gave in step 5
Now the second switch is displayed in the devices tab as "unused" however it is linked to the dimmer. Only the name you entered in step 5 is displayed in the Switch tab. The second one is disregard in the switch tab, since it is "unused". No matter with what switch you control the ligt now, the status is correctly updated in Domoticz.
Good luck!
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 17:20
by XL-Network
Thanks I tried it and it seems that if you add a sub/slave device using the Devices-page that it does not show in the regular overview and it stays in 'Unused' devices. However, if I add both as a main device and later on change it using the edit button for one device to act as a sub/slave for the other device it still is visable on the Switches-page. Is this an error or by design? Read: you can only add a (hidden) sub/slave-device via the Devices page?
PS. Is it a good idea to be able to hide certain switches (so you can show/hide them later). For this to work it should also be able to edit a switch from the Devices page.
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 02 December 2013 23:43
by XL-Network
I could only (partly) test it this afternoon when I was at work, but now that I'm home it works. There is however a small issue. Both switches keep their own log (which is good ofcourse) but you cannot have a aggregated log of all the (combined) actions.
Thanks for all the assistance. The manual (which I read) says that sub/slave devices are a bit difficult to understand. The manual was right (or maybe I should have read it better).
Re: Three way switch (or hotel/stairway lights)
Posted: Thursday 05 December 2013 10:45
by goedh452
XL-Network wrote:Thanks I tried it and it seems that if you add a sub/slave device using the Devices-page that it does not show in the regular overview and it stays in 'Unused' devices. However, if I add both as a main device and later on change it using the edit button for one device to act as a sub/slave for the other device it still is visable on the Switches-page. Is this an error or by design? Read: you can only add a (hidden) sub/slave-device via the Devices page?
PS. Is it a good idea to be able to hide certain switches (so you can show/hide them later). For this to work it should also be able to edit a switch from the Devices page.
I think you're right that both switches stay visible in the switches tab. I added all slaves directly as slave from the devices tab. That way also the logs aren't divided over two switches.
Re: Three way switch (or hotel/stairway lights)
Posted: Thursday 05 December 2013 11:06
by XL-Network
goedh452 wrote:I think you're right that both switches stay visible in the switches tab. I added all slaves directly as slave from the devices tab. That way also the logs aren't divided over two switches.
Correct. I didn't even notice that. Adding a slave via the Devicestab not only hides it from the Switches-tab, but also 'merges' the log. So it looks like both switches act as one. Would be nice to be able to merge two existing switches or something.
Re: Three way switch (or hotel/stairway lights)
Posted: Monday 18 January 2016 11:59
by elmortero
I use this to make any switch a so called Hotel switch.
It checks the state of the light(switch) in this case called 'Hallway' and no matter what state I put a switch (in this case called 'Kitchen') - On or off - it will cause the hallway light to switch to it's opposite state. This also means that the switches no longer have a real on/off state and you can actually have an unlimited (?).
I am currently using this for all lights that have multiple physical switches. Also these are not affected by actions either through domoticz or timers as the action always depends on the current state of the light.
Code: Select all
commandArray = {}
if (devicechanged['Kitchen'] == 'On' and otherdevices['Hallway'] == 'Off')
then
print ('Switching Hallway light On')
commandArray['Hallway']='On'
end
if (devicechanged['Kitchen'] == 'On' and otherdevices['Hallway'] == 'On')
then
print ('Switching Hallway light Off')
commandArray['Hallway']='Off'
end
if (devicechanged['Kitchen'] == 'Off' and otherdevices['Hallway'] == 'On')
then
print ('Switching Hallway light Off')
commandArray['Hallway']='Off'
end
if (devicechanged['Kitchen'] == 'Off' and otherdevices['Hallway'] == 'Off')
then
print ('Switching Hallway light On')
commandArray['Hallway']='On'
end
return commandArray