Page 1 of 1
Xiaomi Smart Socket Plug WiFi
Posted: Sunday 26 March 2017 19:56
by juzx
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?
Re: Xiaomi Smart Socket Plug WiFi
Posted: Wednesday 12 April 2017 12:17
by juzx
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
Re: Xiaomi Smart Socket Plug WiFi
Posted: Sunday 16 April 2017 19:22
by ToneStrife
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?
Re: Xiaomi Smart Socket Plug WiFi
Posted: Wednesday 19 April 2017 9:56
by juzx
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.
Re: Xiaomi Smart Socket Plug WiFi
Posted: Wednesday 19 April 2017 12:55
by ToneStrife
So, sorry for my ignorance hehe. What is exactly Homebridge? Is there anyway that-domoticz hombridge can communicate.
Re: Xiaomi Smart Socket Plug WiFi
Posted: Thursday 20 April 2017 22:03
by juzx
https://github.com/nfarina/homebridge
Simulates that your stuff is HomeKit licensed
Re: Xiaomi Smart Socket Plug WiFi
Posted: Tuesday 25 April 2017 20:02
by ToneStrife
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?
Re: Xiaomi Smart Socket Plug WiFi
Posted: Tuesday 25 April 2017 20:37
by ToneStrife
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?
Re: Xiaomi Smart Socket Plug WiFi
Posted: Friday 28 April 2017 17:22
by juzx
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.
Re: Xiaomi Smart Socket Plug WiFi
Posted: Monday 22 May 2017 9:25
by juzx
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.
Re: Xiaomi Smart Socket Plug WiFi
Posted: Friday 18 August 2017 4:55
by Wob76
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
Re: Xiaomi Smart Socket Plug WiFi
Posted: Wednesday 13 September 2017 16:01
by Diab
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
Re: Xiaomi Smart Socket Plug WiFi
Posted: Sunday 31 December 2017 17:55
by goshi0
Hi just found an easy way to control this plugs, only to change state, without Matt and nodered, only installing python miio and creating a script in the on /off section of the switch Wich call :
Code: Select all
miplug --ip <here goes plug ip> --token <here goes the plug token> on
To obtain the IP and token just :
I am trying to make work the ir remote but without success.
Re: Xiaomi Smart Socket Plug WiFi
Posted: Thursday 15 February 2018 16:44
by renedis
You need to install
https://github.com/aholstenson/miio
after that you need to do a discovery:
sudo miio discover
Or:
sudo mirobo --discover
Commando to read internal temperature (if available):
sudo mirobo --ip PLUGORPWRSTRIP-IP --token TOKEN raw_command get_prop '["temperature"]' | tail -1 | awk '{print substr($0, 2, length($0) - 2)}'
Commando to read current wattage usage (if available):
sudo mirobo --ip PLUGORPWRSTRIP-IP --token TOKEN raw_command get_prop '["power_consume_rate"]' | tail -1 | awk '{print substr($0, 2, length($0) - 2)}'
Commando to turn on:
sudo mirobo --ip PLUGORPWRSTRIP-IP --token TOKEN raw_command set_power '["on"]'
Or:
sudo miplug --ip PLUGORPWRSTRIP-IP --token TOKEN on
Commando to turn off:
sudo mirobo --ip PLUGORPWRSTRIP-IP --token TOKEN raw_command set_power '["off"]'
Or:
sudo miplug --ip PLUGORPWRSTRIP-IP --token TOKEN off
Re: Xiaomi Smart Socket Plug WiFi
Posted: Monday 16 July 2018 1:50
by fubar
An update for anyone interested in the xiaomi mi plug mini wifi version. It has the big advantage that once set up, you don't need to put it within range of a xiaomi aqara gateway - it can be anywhere your local wifi network will reach.
The miio project is now available as python-miio
http://python-miio.readthedocs.io/en/latest/
I could not get the CLI to work with the old M1 model I got cheaply from gearbest - I updated the firmware as soon as I got it via the awful mihome app and that may have been a mistake as xiaomi sometimes upgrade the firmware to make it harder to use the device outside their ecosystem. Ain't capitalism grand?
Fortunately the classes work fine when called directly in python, so I can switch on and off with some tiny python scripts - use:
to learn the token and ip for your device, then create a text file something like:
Code: Select all
#!/usr/bin/python3
import miio
good = {'ok'}
foo = miio.chuangmi_plug.ChuangmiPlug(ip="your device ip",debug=1,token="your device token")
res = foo.on()
# want to be able to rely on a non-zero exit to indicate failure to the calling script..
if res==good:
exit(0)
else:
exit(1)
seems to do the needful.
use foo.off() in a copy of the above script to turn it off.
foo.status() can be used to get the status including temperature and power for printing if they're available.
Mine shows:
<ChuangmiPlugStatus power=False, usb_power=None, temperature=40load_power=None, wifi_led=None>
I'll update here when I get these little scripts working in domoticz - I want to be able to control a heater...
Re: Xiaomi Smart Socket Plug WiFi
Posted: Wednesday 13 March 2019 11:15
by ruchita
It is working for me with Homebridge and the Homebridge-miio module. So it is unquestionably working yet there is no Domoticz module yet.
These WiFi plugs are perfect now since you needn't bother with the passage and are not relying upon anything from Xiaomi any longer since there is immediate correspondence to the fitting.
Re: Xiaomi Smart Socket Plug WiFi
Posted: Friday 01 November 2019 13:50
by Mazur
Hello! Please tell me how to do it on windows ?
Re: Xiaomi Smart Socket Plug WiFi
Posted: Sunday 03 May 2020 8:11
by rippe
Yes, as Mazur said, Any way of doing this in Windows. Some time has passed since the last comment so I'm hoping that something happened in this area.
Best regards,
Richard