Creating a toggle switch
Moderator: leecollings
-
- Posts: 12
- Joined: Tuesday 06 December 2016 20:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Creating a toggle switch
I'm struggling with something that seems like it should be really simple. I've bought a lightwave RF switch that is designed to select lighting scenes. It is essentially a selector switch with 5 options.
I want to repurpose the buttons as toggle switches, so that rather than choosing between one of 5 scenes, each button can be used to toggle a device on and off.
Example: if I press button 3 once, a device switches on. If I press it again, the device switches off. I thought I could create a blocky logic as follows:
If lightwave switch = button 3, and device switch is off, set to on
Or
If lightwave switch = button 3 and device switch is on, set to off.
The problem with this is that the lightwave switch is a selector, so once I press button 3, it stays selected until I select another button. This results in an endless loop as the device switches on and off until I press a different button on the lightwave switch.
Is there a way to count the number of presses of a button? There is a record in the log each time I press the button so it seems like it should be possible. If I could count the number of presses, I could possibly create some logic to identify if pressing button 3 should be an On action or and Off action.
Or is there some other way? Any guidance would be appreciated.
I want to repurpose the buttons as toggle switches, so that rather than choosing between one of 5 scenes, each button can be used to toggle a device on and off.
Example: if I press button 3 once, a device switches on. If I press it again, the device switches off. I thought I could create a blocky logic as follows:
If lightwave switch = button 3, and device switch is off, set to on
Or
If lightwave switch = button 3 and device switch is on, set to off.
The problem with this is that the lightwave switch is a selector, so once I press button 3, it stays selected until I select another button. This results in an endless loop as the device switches on and off until I press a different button on the lightwave switch.
Is there a way to count the number of presses of a button? There is a record in the log each time I press the button so it seems like it should be possible. If I could count the number of presses, I could possibly create some logic to identify if pressing button 3 should be an On action or and Off action.
Or is there some other way? Any guidance would be appreciated.
-
- Posts: 4
- Joined: Wednesday 28 February 2018 14:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Switzerland
- Contact:
Re: Creating a toggle switch
Maybe you give this a try: viewtopic.php?f=62&t=20683&p=174002#p174002
Re: Creating a toggle switch
Have you tried it yet? I suppose that after selecting a scene, the device is not continuously sending a signal. So in my opinion your own suggestion for the blockly is correct. But as I don’t know the exact function of the switch, it is a presumption.
-
- Posts: 4
- Joined: Wednesday 28 February 2018 14:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Switzerland
- Contact:
Re: Creating a toggle switch
I tried the same as @gavacac proposed with the zwave.me/Popp/devolo scene controller, but this only lead to blinking light (constantly on and off). Only the approach as given in the link did finally do what I wanted (toggle). The button report is always ON, so I ended up with the additional variable to check the current status. Unfortunately not so straight forward, but works reliably.
Re: Creating a toggle switch
Could it be that the sender sends a signal multiple times in a very short period? That would explain the loop imho. Perhaps delaying the action could prevent it? Something like If signal then toggle light after 5 seconds? Just thinking out loud. 

-
- Posts: 107
- Joined: Tuesday 31 January 2017 21:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Creating a toggle switch
have a look at https://www.domoticz.com/wiki/Blockly
last of the examples describe a toggle switch. make sure to set trigger to device!
last of the examples describe a toggle switch. make sure to set trigger to device!
-
- Posts: 70
- Joined: Tuesday 27 March 2018 17:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Creating a toggle switch
Another variation on the same theme. This allows a single button on a Remotec ZRC-90 to successively toggle 3 switches on and then back off again in reverse order.
-
- Posts: 170
- Joined: Monday 22 January 2018 21:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Creating a toggle switch
I tried different options to create a toggle switch from a wall switch using Blocky. Also tried the method mentioned in the wiki. The light keeps going on and of every 8 or so minutes. I tried these 2 options, both of them have this slow loop:
Hope someone can help with this.
- Spoiler: show
Hope someone can help with this.
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Zwave, Zigate, RFlink etc.
-
- Posts: 109
- Joined: Tuesday 02 October 2018 20:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Creating a toggle switch
Shouldn't you only switch on the state on dor your switch?
-
- Posts: 170
- Joined: Monday 22 January 2018 21:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Creating a toggle switch
I solved it by using a DzVents script I already used for something else: Found it a while ago (credits @waaren).
- Spoiler: show
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Zwave, Zigate, RFlink etc.
Who is online
Users browsing this forum: No registered users and 1 guest