Hi,
I have a Xiaomi zibgee smart plug, that cannot be found by HA. (all remaining sensors are working).
switch:
- platform: xiaomi
devices:
192.168.1.129:
name: Plug
Any ideas of how I should configure to be discovered?
Tks!
Hi,
I have a Xiaomi zibgee smart plug, that cannot be found by HA. (all remaining sensors are working).
switch:
Any ideas of how I should configure to be discovered?
Tks!
Why does it have an ip address?
Do you have a zigbee controller?
Are the other sensors zigbee or z-wave?
Does Xiaomi use an open Zigbee protocol or a closed protocol like Digi
Tks for the response.
I only have Xiaomi gateway that already controls this socket and all appliances have an IP. And I donāt have a zibgee controller.
I know itās zigbee, but I think itās not open.
This is the device: http://www.gearbest.com/living-appliances/pp_344666.html
This is the Xiaomi supported devices:
And I think that the device I have should fit here: āPlug aka Socket (ZigBee version, reports power consumed, power load, state and if device in use)ā
But itās strange because it is not being detected. I also have the yeelight and these are detected without any problems.
Any idea??
Tks!
Ok forgive me if Iām off base (Iām new to this too) but you are trying to control a Zigbee device directly from HA instead of the Zigbee gateway that is required.
The socket is a device, there is only Zigbee communication to this device.
The gateway required to control multiple devices will be the bridge between the device and HA.
Your link is for gateways.
xiaomi: gateways: - mac: key: xxxxxxxxxxxxxxxx
Do you have a gateway? Are your other devices Zigbee.
Yeelight seems to be wifi.
Correct! I indeed have this xiaomi gateway defined. If a bunch of sensors connected in listed in HA.
Since xiaomi has the ability to control this device I was hoping to have HA control also this device /using xiaomi).
And it seems to be on the supported list.
For instance, my aqara wall switch are working in HA without any problem and they are zigbee.
Tks!
Ok, little trouble shooting
Can you see the questioned switch within the Xiamio gateway?
If yes then can you see it within HA <> list of states? Vera has its name first in attributes so I know what is associated with that gateway, assuming yours is the same as I do not have one.
Check all devices with the Xiamio attributes and ensure they are being used in HA the entity is what is needed. Then to see it on a page you just use the entity, no need to do what you did in original post.
ex:
entity:
light.in_wall_dimmer_30
attribute:
Vera Device Id: 30
friendly_name: In Wall Dimmer
supported_features: 1
To clarify it: There is a āwifi versionā and a āzigbeeā version. The zigbee version works fine with the xiaomi component, because itās zigbee and paired like any other device. The wifi version needs another protocol and must be integrated separately into home assistant. f.e. by the xiaomiplug custom component (https://github.com/syssi/xiaomiplug).There is no official support of the wifi plug so far.
Furthermore: The wifi version cannot measure power consumption / load / is used. The zigbee version reports this values. If you want to buy one of these devices: Take the zigbee one.
Hi syssi,
Thank you for the help! I bough the zigbee according gearbest but i never had the measuring working, and indeed it connects using wifi. But it was a while ago and I cannot return it.
Iāve installed your module, and already set the configuration. Everything seems to be OK, however my main problem is that i cannot find the token. Iāve read multiple posts where they say that the token can be extracted with āmiio --discoverā however this command runs in one second and gives me not output. Iām in the same subnet as the plug. Any alternative to get this ID? (already explored the xiaomi app, but no luck either getting de 32 chars token).
Thank you!
Do you own a rooted android device and are you familiar with adb? There is a simple way to extract the token from the sqlite database of the mi home app. I can explain it if you like.
Tks for the quick response! Coincidence because I was already doing this.
I got the token from the sqlite file, and worked on the first execution:
Tks for the support and the excellent work!
I check my gearbest purchase order and after all i bought the wireless version (half of the price) because the measuring was not important for that appliance. Know i regret a bit, however thanks to you I can have the included in the platform!
Tks!
Perfect! I can recommend the zigbee version. The wifi plug is less responsive and needs to be polled.
Two references for people with the same problem (extract the token from sqlite):
me@laptop:~ $ ./adb connect 192.168.xx.yy
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 192.168.xx.yy:5555
me@laptop:~ $ ./adb shell
rpi3:/ $ su
rpi3:/data/data # cd com.xiaomi.smarthome/databases/
rpi3:/data/data/com.xiaomi.smarthome/databases # sqlite3
SQLite version 3.9.2 2015-11-02 18:31:45
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open miio2.db
sqlite> .tables
android_metadata devicerecord
sqlite> select * from devicerecord;
Here you get all the settings along with the token.
sqlite> .quit
rpi3:/data/data/com.xiaomi.smarthome/databases # exit
rpi3:/ $ exit
me@laptop:~ $
There is a column called ātokenā. A token looks like this: b051cd82786f85996283d82ccf9d27bd2db
What is your config for the socket? Iām confused, because the zigbee version hasnāt IP address, I have the token but I donāt know how to configure it with the gateway. Thanks.
UPDATE:
I found the right conf:
switch:
A token isnāt needed for the xiaomi gateway & zigbee sub-devices.
So, If you have two sockets connected, how does hass know each one?
Iām trying to access the in_use
and load_power
attributes as triggers for an automation - I want to send a notification if power is on (ie the socket hasnāt been unplugged or turned off at the switch), but the `load_powerā is under some threshold (say 20). Iāve been told that to do this I need to setup 2 template sensors to access these attributes and have code in my configuration.yaml as follows:
sensors:
- platform: template
sensors:
mydevice_power:
value_template: '{{ states.switch.plug_158d0001xxxxxx.load_power|int }}'
- platform: template
sensors:
mydevice_inuse:
value_template: '{{ states.switch.plug_158d0001xxxxxx.in_use|default(0) }}'
Iāve played around with various formulations and must admit I canāt fully understand the template after the pipe ā|ā, except it determines the format of what is returned. The sensors show up at the top of my home page, but donāt show values. They are available via the āStatesā page within HA, so the switches are working and sending values to HA, I just canāt figure out how to access them.
Any pointers appreciated.
Hello.
Try the following instead:
sensors:
- platform: template
sensors:
mydevice_power:
value_template: '{{ states.switch.plug_158d0001xxxxxx.attributes.load_power|int }}'
- platform: template
sensors:
mydevice_inuse:
value_template: '{{ states.switch.plug_158d0001xxxxxx.attributes.in_use|default(0) }}'
That should do the trick.
Thanks. That does the job perfectly!
Hi @syssi, Iāve been using the Xiaomi gateway for a month or two and generally it works fine.
Iām running a few movement sensors etc off it and it was pretty much plug and play.
My only issue is with the Plug aka Socket (Zigbee version). When I try to turn it on/off from Homeassistant, it doesnāt work.
Basically, I just turn the switch on/ff via the interface, and the switch moves and after a few seconds reverts back to the original position.
If I use the MiHome app to turn on/off the switch, I see the switch mode within HA changes accordingly. I also get to see the power utilisation etc as it should. See below.
Hereās the log;
2017-10-28 06:05:41 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step result = coro.throw(exc) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1026, in _event_to_service_call yield from service_handler.func(service_call) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/__init__.py", line 117, in async_handle_switch_service yield from switch.async_turn_off() File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/xiaomi_aqara.py", line 106, in turn_off if self._write_to_hub(self._sid, **{self._data_key: 'off'}): File "/srv/homeassistant/lib/python3.5/site-packages/PyXiaomiGateway/__init__.py", line 290, in write_to_hub data['key'] = self._get_key() File "/srv/homeassistant/lib/python3.5/site-packages/PyXiaomiGateway/__init__.py", line 320, in _get_key encryptor = AES.new(self.key.encode(), AES.MODE_CBC, IV=init_vector) File "/srv/homeassistant/lib/python3.5/site-packages/Crypto/Cipher/AES.py", line 95, in new return AESCipher(key, *args, **kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/Crypto/Cipher/AES.py", line 59, in __init__ blockalgo.BlockAlgo.__init__(self, _AES, key, *args, **kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/Crypto/Cipher/blockalgo.py", line 141, in __init__ self._cipher = factory.new(key, *args, **kwargs) ValueError: Key cannot be the null string
Any thoughts?
Thx
JP