Page 1 of 1
Xiaomi Wireless Switch Click action issue
Posted: Thursday 09 February 2017 22:02
by mKotek
I have build a scenario, where I am using Wireless Switch by Xiaomi (a round one) + great
AC Dimmer by trackerj. More on this and initial movie, showing current scenario
here.
All is working fine in general, but there is a small issue.
My current blocky uses Click action to power on the lights and Double Click to power off the lights. It also uses Long Click to dim the lights, but that is irrelevant to my issue.
Here is current blocky:

- Blocky using Click, Double Click and Long Click actions
- BlockyXiaomiAndDimmer.png (101.39 KiB) Viewed 12802 times
I would like to replace the Double Click action used to power down the lights with another Click action. So the end result would be: if the lights would be on, turn them off and if they are off, turn them on.
If I replace the current Double Click state (mind you, Xiaomi switch is a selector in Domoticz), for some reason it is switching permanently between on and off state. After troubleshooting, I have realised, Click is the permanent action and hence gets triggered all the time. So I have added the Set state to Off in the blocky you can see above, but this does not seem to be working. The Off state is not set by blocky.
Any ideas?
Re: Xiaomi Wireless Switch Click action issue
Posted: Thursday 09 February 2017 23:22
by pikapt
just add a 1 sec delay to the switch, should be enough
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 7:53
by mKotek
pikapt wrote:just add a 1 sec delay to the switch, should be enough
Unfortunately, this does not suffice.
For some reason, Off is not set on the selector. I have even tried to replace text "Off" with standard Off state, but then selector behaves strangely: both actions stay marked on the selector: Off and Click.
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 8:43
by lamouette
Hi Michal,
On my side, "Off" state of the Xiaomi Switch has been set up inside the selector configuration (with a 5 seconds delay) and not inside my blocky(ies).
Please also have a look, still inside the selector configuration of the selector levels order:
00 Off
10 Click
20 Long click
30 Long click release
40 Double click
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 8:50
by mKotek
lamouette wrote:Hi Michal,
On my side, "Off" state of the Xiaomi Switch has been set up inside the selector configuration (with a 5 seconds delay) and not inside my blocky(ies).
Please also have a look, still inside the selector configuration of the selector levels order:
00 Off
10 Click
20 Long click
30 Long click release
40 Double click
Can you provide the screenshot or explain, how the Off state is set automatically in your case?
In my case, I have Off state created automatically, but the Selector normally stays on the action last executed, so if Xiaomi sets Click, Click action stays. That is why, in my blocky I am trying to set Off via Set in reaction to Click action.
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 8:55
by lamouette
Sure, here it is :

- Capture.PNG (101.16 KiB) Viewed 12762 times
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 8:57
by mKotek
Yes, so this is what I set, but to 1s. Yet this does not change the state of the Selector. After Click action, the selector stays on Click, does not switch to Off state.
Edit: Wait, this seems to be working now

Edit 2: I need to check the rest. If I have just Click and Double Click actions and your delay, Selector switches to off. But as soon as I change the second If in my blocky from Double Click, to Click, the Click is invoked and never changes to Off and my lights go crazy.
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 9:16
by lamouette
Here is my setup.
I have 2 blockies, setting up the status of a group.
I am not a big fan of "Else if"

- Capture.PNG (11.83 KiB) Viewed 12755 times

- Capture1.PNG (12.43 KiB) Viewed 12755 times
And the scene is the following:

- Capture2.PNG (276.45 KiB) Viewed 12755 times
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 10:06
by corbin
mKotek wrote:
Any ideas?
I haven't looked into your script yet, but can you confirm you have the same states as lamouette for the switch? -

- xiaomi_states.PNG (32.52 KiB) Viewed 12745 times
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 10:08
by lamouette
Next step will be to remove the switch from the device list and add it again by a refresh of the gateway hardware within domoticz
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 10:34
by mKotek
corbin wrote:mKotek wrote:
Any ideas?
I haven't looked into your script yet, but can you confirm you have the same states as lamouette for the switch? -
xiaomi_states.PNG
Yes, I have removed the switch and added it back again when Long Click Release has been added and I have exactly the same set of actions on the selector.
I am now thinking about simplyfing the blocky to include only check for Click event and the status of the variable and disregard the condition about Lights being not Off in the second Click check.
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 10:36
by mKotek
lamouette wrote:Here is my setup.
I have 2 blockies, setting up the status of a group.
I am not a big fan of "Else if"
Capture.PNG
Capture1.PNG
And the scene is the following:
Capture2.PNG
I am also not a big fan of else if, but what I am trying to achieve is to act on Click action depending on whether at least one light is on or off.
The scenario you have shown with Click and Double Click works fine in my case. I am trying to replace Double Click with Click, so that it works once to turn the lights on and then again to turn lights off.
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 11:15
by lamouette
Why don't you set "LampaBorysa_K1" and "LampaBorysa_K2" to "On" ?
Mistake on your Else If, in the "or", you check two times "LampaBorysa_K1"
Re: Xiaomi Wireless Switch Click action issue
Posted: Friday 10 February 2017 18:24
by mKotek
lamouette wrote:Why don't you set "LampaBorysa_K1" and "LampaBorysa_K2" to "On" ?
Mistake on your Else If, in the "or", you check two times "LampaBorysa_K1"
I have corrected this (have missed that completely, so thank you), but this has not solved the problem.
I have even removed the whole AND part of the second click, leaving only variable check, but still the disco lights start when only I replace Double Click with Click. Will need to debug piece by piece.
Re: Xiaomi Wireless Switch Click action issue
Posted: Tuesday 12 December 2017 11:31
by Hurricanezzz
how about this for a solution:
set your switch delay at 1 seconds.
then when "click" is selected
set first switch to off
then lamp on after 2 seconds.
this prevents that the state of the lamp is seen "on" at the same time that the switch is in state "click"
Re: Xiaomi Wireless Switch Click action issue
Posted: Wednesday 13 December 2017 20:35
by johnnie
Hi mKotek,
Are you still having issue’s to set the wireless switch to OFF?
I find the answer, you need the logic OFF in blockly, and not the text logic where you fill in the “state of wired switch”!
The text box in blockly is used for the other states, like “click” etc etc.
Make sure that the off state in the device is also set to 0.
Hopefully this will help.
Best regards, John
Re: Xiaomi Wireless Switch Click action issue
Posted: Tuesday 25 September 2018 19:20
by madvisionz
Does this also work with the Wireless Wall Switch? I want to use this switch for turning on/off HUE light, but this doesn't work.
I added the switch to domoticz and changed to type selector, created a blockly with "Click" and "Double Click" but no response of the HUE bulb.
And when I click on the switch itself it always gives as data "Off" in the log.
How can I get this thing working?
Re: Xiaomi Wireless Switch Click action issue
Posted: Sunday 30 September 2018 20:41
by Mathijs
I have the same question. Can't seem to get my group to turn on or off when one of the buttons of the xiaomi wireless dual switch is clicked.
Any help is appreciated.
@madvision. The data "off" is because the unit itself will switch to Off after a some seconds, as mentioned above.

Re: Xiaomi Wireless Switch Click action issue
Posted: Monday 01 October 2018 11:01
by madvisionz
I didn't setup a Off delay so the device doesn't switch to off after some seconds.
When I set a Off delay the light is going into a loop on/off/on/off etc.
I also switched back to type "Push On button" which is set as default when you add the Xiaomi Wireless Wall Switch (single button) to Domoticz. The device in Domoticz is working with type selector, but not with the physical device itself. It always returns "Off" in log by every click.
The problem is that type "push on button" always gives a ON status when you click on the device and I can't figure out how to manage to create a toggle so the lamp is going ON when it's OFF and OFF when it's ON at every click.
Does someone has this working already with the Xiaomi/Aqara Wireless Wall Switch (single button)?
If so, please share your config.

Re: Xiaomi Wireless Switch Click action issue
Posted: Sunday 14 October 2018 9:34
by 125db
Hi there,
I got my XIaomi switches working with multiple scenes on one action, see the code below. In that example I used the Double Click action to switch between 3 different scenes, you can do it with 2 scenes (1 with your light-s on, 1 with the light-s off) and it should work just fine.
Hope it helps!