Page 1 of 1

How to use a selector switch (Xiaomi) to ON/OFF Hue light ?

Posted: Saturday 28 January 2017 14:33
by Gl0ox
Dear all,

I am a very beginner of Domoticz and I am trying to use my Xiaomi selector switch (Click / Long Click / Double Click) to control my Hue lights. (as it is my first post I really hope I am not asking a dumb/already discussed 100 times question :oops: )
Image
I would like to be able to turn light ON/OFF by clicking once on the button (Click): if I click and light is ON, it turns it OFF and vice versa.

I have the hue lights into a switch, I can On/Off by clicking on it in Domoticz.

Problem is that "Click" is a state (selector) and so it stays at "Click" state unless I change it, for instance by double clicking the button (Double Click state). I could use Click to switch ON and Double Click to switch off... but Double Click would no longer be free for some other scene.

So every try I did (events using blocky or sub/slave device function) is a failure :|

I am very happy and thankfull for the recent job of the community for Xiaomi Gateway integration! Probably I lack some basic knowledge to do this, but this integration of XG is what made me adopt Domoticz !

Re: How to use a selector switch (Xiaomi) to ON/OFF Hue light ?

Posted: Saturday 28 January 2017 16:18
by Mooseknuckle
Hi there,

You can use a user variable to determine the state of the switch, for example:
- make a uservariable "switch state" and give initial value "Off"
- make a lua script (or blockly):

Code: Select all

if (devicechanged['Xiaomi switch'] == 'Click'and uservariables['switch state'] == 'Off') then
   commandArray['Hue lights']='On'
   commandArray['Variable:switch state']= 'On'
end
The same code you can use for turning the lights off or for double click or long press actions of the switch.

Re: How to use a selector switch (Xiaomi) to ON/OFF Hue light ?

Posted: Saturday 28 January 2017 17:05
by Gl0ox
Thank you so much ! :D

Image
Working

Re: How to use a selector switch (Xiaomi) to ON/OFF Hue light ?

Posted: Tuesday 25 September 2018 12:42
by madvisionz
Hi, I have a Xiaomi Wireless Wall Switch and some HUE bulbs which I want to combine with Domoticz.
How can I configure the switch to control the HUE bulbs? I did some tests with Blockly, but nothing happens so far.
I do not have any experience with LUA yet so if that's needed I need a good instruction for dummies. :)
I also tried with the user variable described here and doesn't work either, but maybe I'm missing something.

Can someone tell me how I can set this up?

Current Scenario:
HUE bulbs and Xiaomi Wireless Switch are added in Domoticz, changed the switch type of the Xiaomi switch to "Selector" with 5 levels:
0-Off, 10-Click, 20-Long Click, 30-Long Click Release and 40-Double Click, but when I click on the switch the Off status always appears in the log.
When I click on the buttons in Domoticz the status is shown in the log, but after couple of seconds it changed back to off.
xiaomi_switch.PNG
xiaomi_switch.PNG (97.13 KiB) Viewed 2691 times
I also configured Blockly for one Click to turn one bedroom bulb on/off, see attachment.
blockly.PNG
blockly.PNG (62.87 KiB) Viewed 2691 times
Thnx!