Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Wednesday 02 August 2017 18:05
Hey did anybody trying to integrate this beautiful desklamp von Xiaomi: Xiaomi Mijia Smart LED Desk Lamp
Open source Home Automation System
https://forum.domoticz.com/
I have nothing against posting good deals here on the board, but in the name of openness / transparency I'd like to see a mentioning if there is an affiliate link used (yes, one can see it in the link address of course, but would be clearer if it is also mentioned in the post)theo69 wrote:Hey did anybody trying to integrate this beautiful desklamp von Xiaomi: Xiaomi Mijia Smart LED Desk Lamp
Thanks, I was afraid this also has some software needed in the gateway.pvm wrote:This functionality needs to be supported by the gateway. As far as I know xiaomi does not support this at the moment.
You can have a look at the thread about the ikea Tradfri gateway. Someone mentioned a generic zombie gateway if I remember correctly
levynger wrote:thanks, recieved my cube, and used your script, modified it abit to allow turning on/off as well based on rotation is someone interfested in:woody4165 wrote:Just wrote a small script, but since I'm not a coder, I'm sure it can be optimized...deennoo wrote:Rotation value is a text device who appear once you rotate cube once.
In my case, I want that the dimming works only if the lamp is already On.
It seems to work, if you have any suggestion, please share it!Code: Select all
commandArray = {} -- Run only if the cube has been rotated clockwise or anti-clockwise if devicechanged['Xiaomi Cube Switch'] == "clock_wise" or devicechanged['Xiaomi Cube Switch'] == "anti_clock_wise" then -- Runs only if the light is already On if (otherdevices['YeeLight Salone'] == "On" or otherdevices['YeeLight Salone'] == "Set Level") then -- grab the actual dimming value actual_dimming = tonumber(otherdevices_svalues['YeeLight Salone']) --if the cube has been rotated clockwise and dimming is below 100 if ((otherdevices['Xiaomi Cube Switch'] == "clock_wise") and actual_dimming < 100) then -- need to find only the integer value actual_rotation = otherdevices_svalues['Xiaomi Cube Text'] virgola = string.find(actual_rotation, ",") numero = string.sub(actual_rotation, 1, virgola-1) -- Add the rotation value to the actual dimming, and if is greater than 100, set it to 100 new_dim_value = actual_dimming + tonumber(numero) if new_dim_value > 100 then new_dim_value = 100 end comando = "Set Level "..new_dim_value commandArray['YeeLight Salone']=comando end --if the cube has been rotated anti-clockwise and dimming is above 1 if (otherdevices['Xiaomi Cube Switch'] == "anti_clock_wise" and actual_dimming > 1) then -- need to find only the integer value actual_rotation = otherdevices_svalues['Xiaomi Cube Text'] virgola = string.find(actual_rotation, ",") numero = string.sub(actual_rotation, 1, virgola-1) -- Add the rotation value (in this case is a negative value), to the actual dimming, and if is smaller than 1, set it to 1 new_dim_value = actual_dimming + tonumber(numero) if new_dim_value < 1 then new_dim_value = 1 end comando = "Set Level "..new_dim_value commandArray['YeeLight Salone']=comando end end end return commandArray
Code: Select all
-- Run only if the cube has been rotated clockwise or anti-clockwise if devicechanged['Xiaomi Cube'] == "clock_wise" or devicechanged['Xiaomi Cube'] == "anti_clock_wise" then -- Runs only if the light is already On --if (otherdevices['CorridorLight'] == "On" or otherdevices['CorridorLight'] == "Set Level") then -- grab the actual dimming value actual_dimming = tonumber(otherdevices_svalues['CorridorLight']) print("the Current YeeeLightSvalue: " .. actual_dimming) --if the cube has been rotated clockwise and dimming is below 100 if ((otherdevices['Xiaomi Cube'] == "clock_wise") and actual_dimming < 100) then -- need to find only the integer value actual_rotation = otherdevices_svalues['Xiaomi Cube Text'] virgola = string.find(actual_rotation, ",") numero = string.sub(actual_rotation, 1, virgola-1) -- Add the rotation value to the actual dimming, and if is greater than 100, set it to 100 new_dim_value = actual_dimming + tonumber(numero) if new_dim_value > 100 then new_dim_value = 100 end comando = "Set Level "..new_dim_value commandArray['CorridorLight']=comando end --if the cube has been rotated anti-clockwise and dimming is above 1 if (otherdevices['Xiaomi Cube'] == "anti_clock_wise" and actual_dimming > 1) then -- need to find only the integer value print("a test print") actual_rotation = otherdevices_svalues['Xiaomi Cube Text'] virgola = string.find(actual_rotation, ",") numero = string.sub(actual_rotation, 1, virgola-1) -- Add the rotation value (in this case is a negative value), to the actual dimming, and if is smaller than 1, set it to 1 new_dim_value = actual_dimming + tonumber(numero) print("the new value to reduce to: " .. new_dim_value) if new_dim_value <= 1 then new_dim_value = 0 end comando = "Set Level "..new_dim_value commandArray['CorridorLight']=comando end --end end return commandArray
@theo69 It is good to see you promoting the Xiaomi products, but it is also good manners to to include a note that you get a cut from each purchase, including the affiliate links you added on the Wiki.Nautilus wrote:I have nothing against posting good deals here on the board, but in the name of openness / transparency I'd like to see a mentioning if there is an affiliate link used (yes, one can see it in the link address of course, but would be clearer if it is also mentioned in the post)theo69 wrote:Hey did anybody trying to integrate this beautiful desklamp von Xiaomi: Xiaomi Mijia Smart LED Desk Lamp
Thanks a lot for helping, but I don't write this script in domoticz, I copy it in the folder scripts/lua.corbin wrote:@jlmb22 change your Lua script to 'Device' instead of 'All'
On my side adding affiliate to gearbest link can be ok if :.corbin wrote:@theo69 It is good to see you promoting the Xiaomi products, but it is also good manners to to include a note that you get a cut from each purchase, including the affiliate links you added on the Wiki.Nautilus wrote:I have nothing against posting good deals here on the board, but in the name of openness / transparency I'd like to see a mentioning if there is an affiliate link used (yes, one can see it in the link address of course, but would be clearer if it is also mentioned in the post)theo69 wrote:Hey did anybody trying to integrate this beautiful desklamp von Xiaomi: Xiaomi Mijia Smart LED Desk Lamp
Here is an example of simple code to activate Domoticz security panel from Xiaomi Wireless Switch, and toggle sound from the Gateway.wss2 wrote:Hi folks,
I'm new to forum and Domoticz world, am I trying to create a lua script to send the arming signal or double click on the gateway is it possible?
I can send commands via domoticz to the gateway but I can not do these actions or enable the automates already created in the app.
Code: Select all
if devicechanged['Xiaomi Wireless Switch 2'] == 'Double Click' then
if otherdevices['Security Panel'] == 'Arm Away' or otherdevices['Security Panel'] == 'Arm home' then
commandArray['Xiaomi Gateway MP3'] = 'Off'
print("Securty Disarmed")
commandArray['Variable:XiaomiMP3']='10003'
print("the MP3 Var is: " .. tostring(XiaomiMP3))
commandArray['Xiaomi Gateway MP3'] = 'On'
commandArray['Security Panel'] = 'Disarm'
else
print("security Armed")
commandArray['Xiaomi Gateway MP3'] = 'Off'
commandArray['Variable:XiaomiMP3']='10001'
print("the MP3 Var is: " .. tostring(XiaomiMP3))
commandArray['Xiaomi Gateway MP3'] = 'On'
commandArray['Security Panel'] = 'Arm Away AFTER 30'
end
end
return commandArray
the Neutral Version are not (yet) supported.. however it is planned..islandman wrote:Hi I am to new to domoticz. I switched from pure homebridge to this. I have one of the great gateways from Xiaomi. However i bought one of this neutral wire single switches. Are there any tricks to get them show up in domoticz? Its working great with all the other wall switches without neutral wire.
Thanks for your help...
Thanks for the Info, do you have a time frame?levynger wrote: the Neutral Version are not (yet) supported.. however it is planned..
i have sync'ed Corbin's git, i will try to assist him with it. i have received single neutral version...
Thank you for the reply.levynger wrote:Code: Select all
if devicechanged['Xiaomi Wireless Switch 2'] == 'Double Click' then if otherdevices['Security Panel'] == 'Arm Away' or otherdevices['Security Panel'] == 'Arm home' then commandArray['Xiaomi Gateway MP3'] = 'Off' print("Securty Disarmed") commandArray['Variable:XiaomiMP3']='10003' print("the MP3 Var is: " .. tostring(XiaomiMP3)) commandArray['Xiaomi Gateway MP3'] = 'On' commandArray['Security Panel'] = 'Disarm' else print("security Armed") commandArray['Xiaomi Gateway MP3'] = 'Off' commandArray['Variable:XiaomiMP3']='10001' print("the MP3 Var is: " .. tostring(XiaomiMP3)) commandArray['Xiaomi Gateway MP3'] = 'On' commandArray['Security Panel'] = 'Arm Away AFTER 30' end end return commandArray
You want to activate internal xiaomi app scene? Or Domoticz scene?wss2 wrote:Thank you for the reply.levynger wrote:Code: Select all
if devicechanged['Xiaomi Wireless Switch 2'] == 'Double Click' then if otherdevices['Security Panel'] == 'Arm Away' or otherdevices['Security Panel'] == 'Arm home' then commandArray['Xiaomi Gateway MP3'] = 'Off' print("Securty Disarmed") commandArray['Variable:XiaomiMP3']='10003' print("the MP3 Var is: " .. tostring(XiaomiMP3)) commandArray['Xiaomi Gateway MP3'] = 'On' commandArray['Security Panel'] = 'Disarm' else print("security Armed") commandArray['Xiaomi Gateway MP3'] = 'Off' commandArray['Variable:XiaomiMP3']='10001' print("the MP3 Var is: " .. tostring(XiaomiMP3)) commandArray['Xiaomi Gateway MP3'] = 'On' commandArray['Security Panel'] = 'Arm Away AFTER 30' end end return commandArray
Do you think it's possible to activate a gateway scene?
Now that you tell me so I understand the whipped that I've said.levynger wrote: You want to activate internal xiaomi app scene?