Xiaomi Smart Socket Plug WiFi

Compatibility (hardware, devices and OS)
Post Reply
juzx
Posts: 16
Joined: Thursday 23 March 2017 15:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Xiaomi Smart Socket Plug WiFi

Post by juzx » Sunday 26 March 2017 19:56

Since there are more people trying to get this working and the Xiaomi main threat was getting floated I decided to make a dedicated topic to hopefully solve this issue to get the Xiaomi Smart Socket Plug WiFi working in Domoticz.

Running nmap gave me the following info
Running: iRobot embedded
OS CPE: cpe:/h:irobot:roomba_980
OS details: iRobot Roomba 980 vacuum cleaner

A wifi access point (open) is used to configure the device out of box
UDP Port 5353 is open (ZeroConf)
UDP Port 54321 is open to receive switch commands

Switch 'On' and 'Off' and 'Status' commands appear to be send as a UDP packet with a data payload.

I tried the same Method as Sevift did with the Vacuum Cleaner. I think indeed they use some sort of same way of communication. My results so far with the BlueStacks > WireShark > PacketSender method.

It looks like the socket is working with some kind of handshake method where 2 packages are sent and two are received.

If you try to turn on the socket from the App it always sents the following message
21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff

The answer on this message changes. It seems that there is some sort of counter in it. Below are 3 different responses from 3 different tries. You see a pattern that the first part is always the same and the last part. Only the middle part changes.

213100200000000003499f5d000 17 d5d 716ef1302435d69990f86a8c784db01f

213100200000000003499f5d000 18 3da 716ef1302435d69990f86a8c784db01f

213100200000000003499f5d000 18 4b1 716ef1302435d69990f86a8c784db01f

After this the app sents the following messages (again 3, also the 3 responses from the received signals from above). Here you also see a pattern. It uses the first part of the received message and then adds something probably encrypted?

213100600000000003499f5d000 17 d5d d531bc1c897ebfb15f5341678a6d0eba34cb5514fc89cb573d80d9617e9cf0e23ccf9685f7415287c2149336f51211ba817d8101670106990945d6daf0630546f6f42ab4547f92ef4f0aed6f78dc7ffb

213100600000000003499f5d000 18 3da 6315570f8702ce010b9d9562093474b660e38047a77a80588dee67ca90326f4586c1aad9f4e434c6083408e3211dad488c5509e04b6cbddc398bd95da60396c9edf821d224b951aa40f1a59a71f5ead5

213100600000000003499f5d000 18 4b1 aa2db754bec96fdd156abe56a2e2cfbecff67a91c17e502e744a72928bb1130def5e7be78e04c24921dfdf65a91514e070984b09a8a5f4b8e09903d64303a7a5dedea888a2a1137edee2f1051cddb795

After this you receive another package from the socket but this is probably not necessary to decrypt for now since it is the confirmation

I think the vacuumcleaner, air purifier and the wifi wall socket all use the same method of communication.

Someone who got experience with this kind of decrypthing?

juzx
Posts: 16
Joined: Thursday 23 March 2017 15:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by juzx » Wednesday 12 April 2017 12:17

For the people interested, there is progress.

The communication protocol used, miio
https://github.com/aholstenson/miio

Homebridge implementation
https://github.com/Bluebie/homebridge-miio

ToneStrife
Posts: 21
Joined: Sunday 16 April 2017 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by ToneStrife » Sunday 16 April 2017 19:22

So it will be possible?

Anything I can do to test? I have to of them.

Do you it will be able to make the xiaomi IR blaster work too?

juzx
Posts: 16
Joined: Thursday 23 March 2017 15:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by juzx » Wednesday 19 April 2017 9:56

It is working for me with Homebridge and the Homebridge-miio plugin. So it is definitely working but there is no Domoticz plugin yet.

These WiFi plugs are ideal now since you don't need the gateway and are not depending on anything from Xiaomi anymore since there is direct communication to the plug.

ToneStrife
Posts: 21
Joined: Sunday 16 April 2017 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by ToneStrife » Wednesday 19 April 2017 12:55

So, sorry for my ignorance hehe. What is exactly Homebridge? Is there anyway that-domoticz hombridge can communicate.

juzx
Posts: 16
Joined: Thursday 23 March 2017 15:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by juzx » Thursday 20 April 2017 22:03

https://github.com/nfarina/homebridge

Simulates that your stuff is HomeKit licensed

ToneStrife
Posts: 21
Joined: Sunday 16 April 2017 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by ToneStrife » Tuesday 25 April 2017 20:02

Thanks, so I have installed HomeBridge and the HomeBridge plugin for Domoticz.
My Hombridge config.json file is

Code: Select all

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:21:3E:E4:DE:33",
        "port": 51826,
        "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
        {
            "platform": "eDomoticz",
            "name": "eDomoticz",
            "server": "127.0.0.1",
            "port": "8080",
            "ssl": 0,
            "roomid": 4,
            "mqtt": 1
        },
    {
      "platform" : "XiaomiMiio",
      "name" : "XiaomiMiio",
      "pollChanges": true,
      "pollInterval": 15
    }
    ],
    "accessories": []
}
But now I don't know what to do. I don't have an apple device to control Homekit. Is there anything I can do?

ToneStrife
Posts: 21
Joined: Sunday 16 April 2017 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by ToneStrife » Tuesday 25 April 2017 20:37

Ok. Now I have follow the isntructions to Add and configure the device to miio. My next thing is to configure it in domoticz. Any advice?

juzx
Posts: 16
Joined: Thursday 23 March 2017 15:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by juzx » Friday 28 April 2017 17:22

Homebridge is ONLY for Apple devices. Like I said before it simulates HomeKit for your iPad or iPhone.

The way you want to use it doesn't work. Homebridge uses information from DOmoticz, not the other way around. So you can control Domoticz with homebridge, but not homebridge with Domoticz.

juzx
Posts: 16
Joined: Thursday 23 March 2017 15:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by juzx » Monday 22 May 2017 9:25

You can get the WiFi wallplugs working with the same method as the air purifier. See topic viewtopic.php?f=56&t=15537

I have it working now. There is some on/off switching delay but yes it is working.

Wob76
Posts: 50
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by Wob76 » Friday 18 August 2017 4:55

Just looking at this, I have found a nodered module that will talk to the wifi plug, as well as the gateway and associated devices, since the gateway has native domoticz support you don't really need any of that.

I have MQTT and nodered working for my AC, so it is an easier route for me, I did a quick test with inject buttons and it turns on and off fine, fairly quickly too, just need to put the MQTT done from domoticz as the input and translate the associated dummy switch to a ON\OFF payload.

Anyway here it is for anyone wanting to go that path.
https://flows.nodered.org/node/node-red ... mi-devices

He also states the wifi code is taken from the miio code on github, if someone smarter than me can build that into Domoticz it would be great.
https://github.com/aholstenson/miio

Wob

Diab
Posts: 3
Joined: Thursday 20 April 2017 8:59
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: Xiaomi Smart Socket Plug WiFi

Post by Diab » Wednesday 13 September 2017 16:01

Hi Wob.
I'm quite familiar with MQTT but just learned about Nodered that is recently implemented on my PI. Can you share the module you are speaking about?
I know the address and the token of my devices but I'm not able to capture packets in order to broadcast Wifi messages towards sockets? Isn't there any other solution?
Thanks for your help.
Diab

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests