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

Moderator: leecollings

Post Reply
Gl0ox
Posts: 3
Joined: Saturday 28 January 2017 13:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

Post 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 !
User avatar
Mooseknuckle
Posts: 43
Joined: Sunday 08 March 2015 9:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
RPI 3, Philips Hue,Toon Thermostat, Harmony Smart Control, Yeelights
Mysensors wifi gateway + sensors, RFXtrx433E, Kaku stuff, Xiaomi gateway + sensors
Domoticz controlled DIY ambilight, Selectplus chime, Mi-light led controller
Gl0ox
Posts: 3
Joined: Saturday 28 January 2017 13:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

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

Post by Gl0ox »

Thank you so much ! :D

Image
Working
madvisionz
Posts: 12
Joined: Tuesday 25 September 2018 12:38
Target OS: NAS (Synology & others)
Domoticz version: 4.10327
Contact:

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

Post 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 2675 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 2675 times
Thnx!
Attachments
Hue_Bulb.PNG
Hue_Bulb.PNG (70.19 KiB) Viewed 2675 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest