Mi(Xiaomi) Smart home bindings?


(Sergey M) #770

I can not enable developer mode. Has something changed after updating the My Home application?
Update: figured out


(Constantinos Contis) #771

my non neutral sinlge switch gives an error too but it works just fine.I just needed to know if the neutral version switches works fine too .They r cheaper right know at Gearbest.


(Constantinos Contis) #772

noobie here ,what PR means?


(Carel Van Hemert) #773

I don’t know if the previous posters that had a similar issue fixed theirs, but I had an issue recently with a new Xiaomi Gateway.

The first issue was that it refused to be autodetected by openHab. The only way I could get it onto OH was to manually add it using its IP. This is new. My previous two Gateways automatically were detected, and was easy to add. After updating to the newest OH, this seems to have become an issue. Not sure what the cause is.

After manuall adding, and entering the developer key, I did manage to successfully add the gateway, as well as the sensors attached to it.

BUT. I was unable to control the Gateway. I also received no updates from the sensors linked to it.
I could change the light on the Gateway with the Mi App, and basic things like Brightness would update on OH, but not vice versa.
I have two other of the same Gateways connected to OH, and they worked fine, so it was strange.

Now, I configure almost everything with files except for loading the actual Things which I do through Paper UI.
So, I took the three Gateways (2 working, 1 with the issue)'s JSONDB Things entries, and placed them together and checked for differences. And I found one. The non-working Gateway’s record didn’t have a ‘serialNumber’ field under properties.

The other two had an serialNumber, which is exactly the same as the identifier ID of the Thing. After some checking, I found that the serialNumber appears to be the MAC address of the Gateway, which is easily findable in the Mi App.

So, I entered the serialNumber (the MAC address without the colons) and refreshed the developer key, and reentered that. This resolved my issue instantly. I can now control my Gateway, as well as receive updates from the sensors connected to it.

So.

  • It appears when adding the Gateway Bridge manually via Paper UI, it doesn’t automatically assign a serialNumber Property to the Thing. This is a read-only field on Paper UI. I had to stop my OH service, and add the property manually to the JsonDB file, and restart OH, to add the value.
  • Note that this applies to the Bridge thing, not the Gateway Light and Sound thing.

Hopefully this helps someone.


(Andrew Pawelski) #774

I have a similar issue but not quite the same - my devices are all online in OH2 and receive sensor updates, but I cannot control it from OH - it feels like its the developer key but from IOS I have gone into the device on the Mi Home app, tapped repeatedly in the about screen (now everything is is chinese) selected the second option and then used the value next to the “cycle” arrows (which Ive also tapped to get a new code and tried updating. I have also turned on the slider above it (I think this is to enable LAN functions based on other guides)

Anyone have any idea? am I using the correct developer code?


(Sergey M) #775

Hello!
I can not get the events of pressing the buttons of the switches with the neutral line. I left for 2 weeks, or forgot or something has changed, help please.
There are 2 switches, one-key and two-key.


rules:

//---------------------------------------------------------------------------------------------
rule "x1"
when
    Channel "mihome:ctrl_ln1:158d0001f2766d:ch1" triggered SHORT_PRESSED
then
    logInfo("RULE","<-- x1")
end
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
rule "x2 ch1"
when
    Channel "mihome:ctrl_ln2:158d000239f928:ch1" triggered SHORT_PRESSED
then
    logInfo("RULE","<-- x2 ch1")
end
//---------------------------------------------------------------------------------------------
rule "x2 ch2"
when
    Channel "mihome:ctrl_ln2:158d000239f928:ch2" triggered SHORT_PRESSED
then
    logInfo("RULE","<-- x2 ch2")
end
//---------------------------------------------------------------------------------------------

log x1:

2018-05-06 20:41:24.805 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:41:28.325 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:41:28.325 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"heartbeat","model":"gateway","sid":"286c07fa22a3","short_id":"0","token":"gU08P2A0zE9BYucU","data":"{\"ip\":\"192.168.215.203\"}"}
2018-05-06 20:41:28.326 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 286c07fa22a3
2018-05-06 20:41:28.326 [DEBUG] [discovery.XiaomiItemDiscoveryService] - Detected Xiaomi smart device - sid: 286c07fa22a3 model: gateway
2018-05-06 20:41:28.328 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:41:28.329 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:41:29.229 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:41:29.230 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:41:29.231 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0001f2766d
2018-05-06 20:41:29.232 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:41:29.233 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:41:29.234 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:41:31.918 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:41:31.918 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:41:31.919 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d0001f2766d
2018-05-06 20:41:31.919 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln1.aq1","sid":"158d0001f2766d","short_id":36019,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:41:31.923 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:41:31.924 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898

log x2:

2018-05-06 20:45:57.873 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:00.945 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:00.946 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:46:00.947 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:00.947 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"on\"}"}
2018-05-06 20:46:00.948 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:00.950 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:04.488 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.140:4321 on Port 9898
2018-05-06 20:46:04.489 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:04.490 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:04.860 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:04.861 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"on\"}"}
2018-05-06 20:46:04.862 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:04.863 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"on\"}"}
2018-05-06 20:46:04.865 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:04.866 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:07.853 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:07.853 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"heartbeat","model":"gateway","sid":"286c07fa22a3","short_id":"0","token":"HmY3FTHKieD5ckhh","data":"{\"ip\":\"192.168.215.203\"}"}
2018-05-06 20:46:07.854 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 286c07fa22a3
2018-05-06 20:46:07.854 [DEBUG] [discovery.XiaomiItemDiscoveryService] - Detected Xiaomi smart device - sid: 286c07fa22a3 model: gateway
2018-05-06 20:46:07.856 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:07.856 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:08.200 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:08.201 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:46:08.201 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:08.207 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_0\":\"off\"}"}
2018-05-06 20:46:08.213 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:08.215 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:10.959 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.203:4321 on Port 9898
2018-05-06 20:46:10.960 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Received message {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"off\"}"}
2018-05-06 20:46:10.961 [TRACE] [g.mihome.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 158d000239f928
2018-05-06 20:46:10.961 [DEBUG] [home.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"report","model":"ctrl_ln2.aq1","sid":"158d000239f928","short_id":10095,"data":"{\"channel_1\":\"off\"}"}
2018-05-06 20:46:10.965 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners
2018-05-06 20:46:10.966 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-34,5,main] waiting for data on port 9898
2018-05-06 20:46:14.473 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.215.140:4321 on Port 9898
2018-05-06 20:46:14.474 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners

switches work from site map and from paper, but the rules do not work, what do I do wrong?
Thank you!
PS openHAB 2.3.0 Build #1269


(Constantinos Contis) #776

i install a double switch (zero line,neutral) the mihome app sees it and working ok but it is not shown at my openhab inbox…all my other switches are showing and working fine (non neutral) .Do i have to manually add it?how can i find the MiHome device ID ?


(Constantinos Contis) #777

updated the binding and now the switch found and working allright


(Carel Van Hemert) #778

Hi there.

Does your ‘wireless communication’ menu screen look like this?

Generally in my experience, if the developer key isn’t correct, you are able to receive updates from sensors, but can’t actually send commands, so it seems to be the culprit. Also check for updates on your mi home binding.


(Andrew Pawelski) #779

Yes it looks same except on iOS it is all in Chinese - just in case I spun up an android emulator and got the same key (also tried new key button). Yes it feels like the key isn’t right as I get the same result if I type in any random string

I also can’t update the firmware on the gateway perhaps that is related to a hardware issue

Thanks
Andrew


(Carel Van Hemert) #780

Okay, I see my iOS version of the APP also has the chinese on that screen. But I can see the same developer key that it shows on my Android version.

So the only other thing I can think of is that you have a similar issue to mine, where the serial might be missing. Or there might be input issues on your dev key.

See below, as per Paper UI:

Do you have anything entered under Serial Number as indicated on my screenshot?

Also check whether you might have spaces at the beginning or end of your Developer Key.

Also, is yours pointing to the same Port? 9898?


(Andrew Pawelski) #781

yes serial is mac address and yes 9898


(Sergey M) #783

Do you get an on / off event in the rules? Please see my post above. I can turn on and off, but I can not catch the on and off events. Dear @dimalo help me deal with this.


(Andrew Pawelski) #784

Ok for those following - i got a replacement gateway and turned on and the firmware update version to go to was different - this went fine and then after enabling developer mode OH did it’s thing and everything works like it said on the tin. Seems like there must be a faulty batch of gateways out there


(Carel Van Hemert) #785

Question. According to the documentation, :ch1 on the wall switches is a Switch item, meaning it would usually have an ON and OFF state.
I don’t think you can do a triggered event on a switch item (but I can be wrong).

So maybe (and this is just a guess), you can capture update events on the channel like this:
(Where itemname is an item that references channel “mihome:ctrl_ln1:158d0001f2766d:ch1”)

rule "x1"
when
    Channel *itemname* changed
then
    if (*itemname*.state == ON)
	{
		logInfo("INFO","Switch On")
	}
    else
    {
        logInfo("INFO","Switch Off")
    }

end

(Carel Van Hemert) #786

Glad you were able to fix it.


(TootToot168) #787

Updates: This issue is solved with update of Openhab to v2.3 and use xiaomi binding v2.3 and updated the Xiaomi Gateway to Firmware v1.4.1_155.0143

Anyone faced issue in Xiaomi Aqara ZigBee Wired Wall Switch 1 button (No neutral) not able to control ON/Off via OpenHAB Basic UI? I am only able to control this particular switch via the original MiHome Mobile App.

OpenHAB v2.2 with Xiaomi Mi Smart Home Binding v2.2 installed.
Port 9898 is not used by any other services on the host machine

Switch is paired to Xiaomi Gateway and appeared as Thing in Paper UI.

  • Xiaomi Aqara 1 Channel Wall Switch
  • Status Online
  • Mains powered Aqara Switch with 1 controllable Channel
  • Channel Button Switch: mihome:ctrl_neutral1:158d00020fa390:ch1

Items file configured the switch as

Switch Restroom_Light	 "Restroom Light" 	 <light> (lightings) [ "Switchable" ] { channel="mihome:ctrl_neutral1:158d00020fa390:ch1" }

In Paper UI, Thing does show the channel is linked to the Switch item.


(Sergey M) #788

Thank you for helping! So I also tried, does not work (((


(Sergey M) #789

I have a two-button, it works from paper and the main interface, in your description I do not see a problem. Did you restart the openHAB / computer?


(TootToot168) #790

Restarting does not work too.

Have another two-button switch and it does not work as per the configuration as well