Page 98 of 123
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Thursday 21 September 2017 22:36
by DAVIZINHO
Egregius wrote: ↑Thursday 21 September 2017 22:35
With pasd2php:
Code: Select all
if(timestamp('motion')<time-1800&&status('motion')=='Off'&&status('purifier')=='On')sw('purifier','Off');
thanks thanks thanks thanks. thankssss!!!!
EDIT,
no maters! i find this:
https://www.domoticz.com/wiki/Event_script_examples
With the exact example of motion sensor and 30 minutes. jejeje
thanks anyway!
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Friday 22 September 2017 0:19
by deennoo
DAVIZINHO wrote:deennoo wrote: ↑Thursday 21 September 2017 21:35
DAVIZINHO wrote:
i use this blocky to turn on the purifier.
But i want to create a blocky to turn OFF the purifier when not detect movement in "movement sensor" in 30 minutes

Use LUA that the only way to do your script
ok, thanks for the info.
Can you tell me how can i make this on lua?.
I only need help for the "if" comand because i dont know how to program the "if sensor not detect move in 30min then"
Search for timedifference, there is various way to arrive to thé same result.
Lots of exemple on m'y blog
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Friday 22 September 2017 8:10
by Peggy
timh1004 wrote: ↑Thursday 21 September 2017 19:04
I was able to update the gateway firmware to 1.4.1_150.0134 with the latest iOS version of the MiHome App. Finally, the left button of the wall switches works again!!
Idem here. Hope it won't reproduce, my home starts to be dependant of some xiaomi stuff...
I stop upgrading mi home for a while.
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Friday 22 September 2017 9:24
by pandemicz
DAVIZINHO wrote:
i use this blocky to turn on the purifier.
But i want to create a blocky to turn OFF the purifier when not detect movement in "movement sensor" in 30 minutes
OK, default sensor timeout is 2 minutes, so have you tryed to add a line to blocky:
Else if => Motion Sensor = Off
Set => Purifier = Off => After 28 minutes
I'm not 100% sure, had problems with Blocky logics myself, especially with timing, but give it a try.
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Friday 22 September 2017 9:59
by CherAlban
Hi,
I have multiple temperature/humidity/pressure sensors installed. My understanding is that these sensors only transmit updates if any of the values "significantly changed".
Is there any possibility to force them to send updates more regularly?
Thanks for your answers
CherAlban
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Friday 22 September 2017 12:01
by DAVIZINHO
pandemicz wrote: ↑Friday 22 September 2017 9:24
DAVIZINHO wrote:
i use this blocky to turn on the purifier.
But i want to create a blocky to turn OFF the purifier when not detect movement in "movement sensor" in 30 minutes
OK, default sensor timeout is 2 minutes, so have you tryed to add a line to blocky:
Else if => Motion Sensor = Off
Set => Purifier = Off => After 28 minutes
I'm not 100% sure, had problems with Blocky logics myself, especially with timing, but give it a try.
Solved, i use this lua script:
Code: Select all
-- script_time_nomotion.lua
local motion_switch = 'Motion'
local nomotion_uservar = 'nomotionCounter'
local status_switch = 'SomeoneHome'
commandArray = {}
no_motion_minutes = tonumber(uservariables[nomotion_uservar])
if (otherdevices[motion_switch] == 'Off') then
no_motion_minutes = no_motion_minutes + 1
--print('<font color="red">No motion has been detected for: ' ..no_motion_minutes.. ' minutes</font>')
else
no_motion_minutes = 0
end
commandArray['Variable:' .. nomotion_uservar] = tostring(no_motion_minutes)
if otherdevices[status_switch] == 'On' and no_motion_minutes > 30 then --change the 30 to the amount of minutes you prefer
commandArray[status_switch]='Off'
end
return commandArray
and i create a user variable called "nomotionCounter" tipe "integer" and value "0"
With this script, works perfect the shutdown of the purifier after 30 minutes of inactivity in the sensor

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Sunday 24 September 2017 0:11
by sincze
Egregius wrote: ↑Thursday 21 September 2017 22:35
With pass2php:
Code: Select all
if(timestamp('motion')<time-1800&&status('motion')=='Off'&&status('purifier')=='On')sw('purifier','Off');
Can it be more simple?
Let's see how much code you'll need in lua to do the same...
It seems we can find Pass2php pretty much everywhere

(for a good reason) around the Domoticz forum.
Just finished reading 98 pages of thread. I must say. WOW. A lot of progress.
Can't wait what will come next.
My house has 433. OpenZwave and now...
Just received the Xiaomi gateway, body sensor and some door/window sensors.
After following the domoticz-wiki everything was up and running.
I'm still connected to the 'chinese' server from within the app.
Don't know if I have to change to the US or different one for a good reason?
Tried it but then all devices were gone (in the APP). After switchting back I could see them again.
Only problem I'm facing is the 'white' led light within the Xiaomi gateway.
The colour picker pressing 'on' it turns 100% white. Howeve I want to dim it.
I can control all colours and brightness (from within the colour picker and via domoticz api) except the white one
(Switching On / Off does work). And ofcourse within the app it does all work nicely.
Any RGB Colour I can select via:
Code: Select all
http://192.168.1.2:8080/json.htm?type=command¶m=setcolbrightnessvalue&idx=12&hue=38&brightness=83&iswhite=false
Colour White (ON/Off no problem)
Code: Select all
On: http://192.168.1.2:8080/json.htm?type=command¶m=switchlight&idx=12&switchcmd=On&level=0&passcode=
Off: http://192.168.1.2:8080/json.htm?type=command¶m=switchlight&idx=12&switchcmd=Off&level=0&passcode=
And no the following did not work for me to produce white light
Code: Select all
On: http://192.168.1.2:8080/json.htmtype=command¶m=setcolbrightnessvalue&idx=12&hue=38&brightness=83&iswhite=true
And yes I am using Pass2php as well

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Sunday 24 September 2017 6:31
by Egregius
I just want to prove how easy it can be

Seen the difference in code between pass2php and lua?
On topic: my Xiaomi gateway is still on the road
I didn't read much about it,just ordered one...
What do you mean by 'connected to Chinese server'? Don't say you can't use it without external stuff...
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Sunday 24 September 2017 10:52
by sincze
Egregius wrote: ↑Sunday 24 September 2017 6:31
I just want to prove how easy it can be

Seen the difference in code between pass2php and lua?
I spotted the difference Instantly
Egregius wrote: ↑Sunday 24 September 2017 6:31
On topic: my Xiaomi gateway is still on the road
I didn't read much about it,just ordered one...
What do you mean by 'connected to Chinese server'? Don't say you can't use it without external stuff...
Yes mine was on offer for under 15 euro so could not resist myself.
I followed the wiki
- Spoiler: show
- https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
Had to install the APP first and create an account. It will ask you to what server you want to connect.
However as I read Chinese in the wiki.. I thought.. go for the Chinese server, but with your Xiaomi account you can connect to different servers as wel, but after switching to the other server my gateway and configured sensors were gone.
But back to configuration on the Chinese server:
After connecting the gateway to the wifi and enabling development mode I think you are able to use the device locally (have to modify the firewall to block traffic to be sure). However for adding additional devices I still needed to use the APP but did not sniff enough traffic to see if that information is uploaded to China.
Small warning: The APP offered me a newer update... by downloading it from the website and not using the Playstore... skipped that one for security reasons. Eventually it will end up in the Playstore.
So hope it arrives soon for you and we will see the updated functions on your github

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Sunday 24 September 2017 12:05
by Sevift
sincze wrote: ↑Sunday 24 September 2017 0:11
I can control all colours and brightness (from within the colour picker and via domoticz api) except the white one
(Switching On / Off does work). And ofcourse within the app it does all work nicely.
Any RGB Colour I can select via:
Code: Select all
http://192.168.1.2:8080/json.htm?type=command¶m=setcolbrightnessvalue&idx=12&hue=38&brightness=83&iswhite=false
Colour White (ON/Off no problem)
Code: Select all
On: http://192.168.1.2:8080/json.htm?type=command¶m=switchlight&idx=12&switchcmd=On&level=0&passcode=
Off: http://192.168.1.2:8080/json.htm?type=command¶m=switchlight&idx=12&switchcmd=Off&level=0&passcode=
And no the following did not work for me to produce white light
Code: Select all
On: http://192.168.1.2:8080/json.htmtype=command¶m=setcolbrightnessvalue&idx=12&hue=38&brightness=83&iswhite=true
And yes I am using Pass2php as well
I once wrote the code for DzVents
Code: Select all
return {
active = true,
on = {
devices = {
'Mi Gateway RGB'
}
},
logging = {
level = domoticz.LOG_ERROR
},
execute = function(domoticz, device)
local miGateway = domoticz.devices(domoticz.globalData.MiGateway)
local url = "http://192.168.100.13:8080/json.htm?param=setcolbrightnessvalue&type=command&idx="..miGateway.idx.."&hex="
local scene = {}
scene[#scene+1] = {'Red', 'FF0000'}
scene[#scene+1] = {'Yellow', 'FFFF00'}
scene[#scene+1] = {'Blue', '0000FF'}
scene[#scene+1] = {'Purple', '800080'}
scene[#scene+1] = {'Magenta','FF0099'}
scene[#scene+1] = {'Green', '008000'}
if device.levelName == 'Off' and miGateway.state == 'On' then
miGateway.switchOff()
elseif device.levelName == 'White' then
miGateway.switchOff()
miGateway.switchOn()
else
for i in pairs(scene) do
if device.levelName == scene[i][1] then
local sceneCmd = 'curl -s '..'"'..url..scene[i][2]..'&iswhite=false'..'"'..' &'
os.execute(sceneCmd)
end
end
end
end
}
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Sunday 24 September 2017 13:11
by sincze
Sevift wrote: ↑Sunday 24 September 2017 12:05
I once wrote the code for DzVents
Code: Select all
return {
active = true,
on = {
devices = {
'Mi Gateway RGB'
}
},
logging = {
level = domoticz.LOG_ERROR
},
execute = function(domoticz, device)
local miGateway = domoticz.devices(domoticz.globalData.MiGateway)
local url = "http://192.168.100.13:8080/json.htm?param=setcolbrightnessvalue&type=command&idx="..miGateway.idx.."&hex="
local scene = {}
scene[#scene+1] = {'Red', 'FF0000'}
scene[#scene+1] = {'Yellow', 'FFFF00'}
scene[#scene+1] = {'Blue', '0000FF'}
scene[#scene+1] = {'Purple', '800080'}
scene[#scene+1] = {'Magenta','FF0099'}
scene[#scene+1] = {'Green', '008000'}
if device.levelName == 'Off' and miGateway.state == 'On' then
miGateway.switchOff()
elseif device.levelName == 'White' then
miGateway.switchOff()
miGateway.switchOn()
else
for i in pairs(scene) do
if device.levelName == scene[i][1] then
local sceneCmd = 'curl -s '..'"'..url..scene[i][2]..'&iswhite=false'..'"'..' &'
os.execute(sceneCmd)
end
end
end
end
}
Tnx for sharing. If I read your code correctly you are able to give the Xiaomi Gateway several Colours (thats great, Í'm able to reproduce that). In addition if you switch it ON it will produce the colour white. My question would be. Are you able to DIM the white light to lets say 10%? I'm no code-wizard to be honest so I was unable to read that from your code. DIM the white LED to any level of the Xiaomi Gateway is that possible? Any other colour I am able to DIM to the level I want, except White.
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Tuesday 26 September 2017 0:10
by chatainsim
Does anyone know how to solve this :
Code: Select all
2017-09-26 00:07:57.047 User: admin initiated a switch command (389/Xiaomi Smart Plug 2/On)
2017-09-26 00:07:57.294 (Gateway) Light/Switch (Xiaomi Smart Plug 2)
2017-09-26 00:08:01.970 User: admin initiated a switch command (389/Xiaomi Smart Plug 2/Off)
[b]2017-09-26 00:08:02.121 Error: XiaomiGateway: unable to write command - Invalid Key
[/b]2017-09-26 00:08:02.121 XiaomiGateway: SendMessageToGateway failed on first attempt, will try again
[b]2017-09-26 00:08:02.371 Error: XiaomiGateway: unable to write command - Invalid Key
[/b]2017-09-26 00:08:05.552 User: admin initiated a switch command (389/Xiaomi Smart Plug 2/Off)
[b]2017-09-26 00:08:05.703 Error: XiaomiGateway: unable to write command - Invalid Key
[/b]2017-09-26 00:08:05.703 XiaomiGateway: SendMessageToGateway failed on first attempt, will try again
[b]2017-09-26 00:08:05.954 Error: XiaomiGateway: unable to write command - Invalid Key
[/b]2017-09-26 00:08:08.801 User: admin initiated a switch command (389/Xiaomi Smart Plug 2/Off)
2017-09-26 00:08:08.977 {"cmd":"report","model":"plug","sid":"158d00012a42ca","short_id":49876,"data":"{\"status\":\"off\"}"}
2017-09-26 00:08:09.077 (Gateway) Light/Switch (Xiaomi Smart Plug 2)
I've double checked the key and it's the good one. I've also try to reset it but still.
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Tuesday 26 September 2017 8:06
by sincze
Your gateway password still okay?
Don't exactly know what key the gateway is talking about but could be the generated access token.
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Tuesday 26 September 2017 15:00
by matteos1
is this correct
this is sensor for door/windows
if door is open netatmo go to away
else in on

- Cattura.PNG (16.15 KiB) Viewed 3309 times
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Tuesday 26 September 2017 15:24
by matteos1
how is it possible some error in sqlite database?
2017-09-26 14:35:06.418 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:40:07.487 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:45:05.344 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:50:07.817 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:55:07.184 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Tuesday 26 September 2017 15:56
by sincze
matteos1 wrote: ↑Tuesday 26 September 2017 15:24
how is it possible some error in sqlite database?
2017-09-26 14:35:06.418 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:40:07.487 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:45:05.344 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:50:07.817 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
2017-09-26 14:55:07.184 Error: SQL Query("DELETE FROM Percentage WHERE strftime('%s',datetime('now','localtime')) - strftime('%s',Date) > (SELECT p.nValue * 86400 From Preferences AS p WHERE p.Key='5MinuteHistoryDays')") : database disk image is malformed
Mmm interesting,
May I suggest you create a new thread for this one? As sql errors are a different story to this topic: "Xiaomi Smart Home Suite (very cheap) compatibilty?"
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Tuesday 26 September 2017 17:42
by chatainsim
sincze wrote: ↑Tuesday 26 September 2017 8:06
Your gateway password still okay?
Don't exactly know what key the gateway is talking about but could be the generated access token.
Yes, password is ok.
Sometimes it works sometimes not.
Does someone know how the messages are sent to the gateway ?
Is it broadcast ? Maybe the other Gateway (not configure in domoticz) answer ?
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Wednesday 27 September 2017 20:13
by sincze
Mmm call be a donut.
The following happened.
Someone took out the Gateway from the power socket.
After re-attaching it to the powersupply All sensors start working (motion / door). However I am unable to control the LED on the gateway itself (Xiaomi RGB) and Xiaomi Gateway Alarm Ringtone / MP3 / Doorbell e.g. from the Domoticz Webinterface.
The log says:
Code: Select all
2017-09-27 20:06:53.628 (GW-Xiaomi) Lighting Limitless/Applamp (Xiaomi RGB Gateway)
2017-09-27 20:06:53.970 (GW-Xiaomi) Lighting Limitless/Applamp (Xiaomi RGB Gateway)
However Noting really happens. How is it possible that all sensors work but not the gateway. If I use the Xiaomi APP I can switch on the LED light and play doorbell sounds. That would mean the Gateway is not broken

Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Wednesday 27 September 2017 20:25
by sincze
Haha, well let me answer my own donut question.
For some reason the Static IP did not work.
I found out via the Xiaomi APP that the gateway jumped to a different IP address.. After changing that in Domoticz all worked fine again.
Question remains... why didn't domoticz notice

and why do all sensors still work when I entered the wrong IP for the Gateway. Stopping and Starting the hardware device in Domoticz doesn't result in an error message as well.
Re: Xiaomi Smart Home Suite (very cheap) compatibilty?
Posted: Thursday 28 September 2017 7:29
by Wob76
Hi,
I have discovered a strange issue with the Power Sockets (Zigbee) when using MQTT. The units function fine, and will turn on\off as expected from Domoticz, and via HTTP JSON Calls, if however I toggle the switch from MQTT nothing happens, the switch in Domoticz will still toggle on\off, but the socket itself will not. I have tried a couple of devices with the same results, looking at domoticz and the logs it all seems to be functioning fine, but the message is just not making it to the socket. Any ideas?
Thanks,
Wob