Xiaomi MiIO switch - Not initializing

Hey all,

I’m having an issue with the Xiaomi MiIO switch.

When loading HASS i see in the logs a message like this:

2018-03-11 20:28:13 INFO (MainThread) [homeassistant.components.switch.xiaomi_miio] Initializing with host 192.168.1.32 (token XXX)

I reviewed the new configuration settings and except for the ‘model’, everything looks good.

This is my config:

  • platform: xiaomi_miio
    name: Black Lamp
    host: !secret xiaomi_plug.blacklamp.host
    token: !secret xiaomi_plug.blacklamp.token

Any idea? anyone having same issue?

PS: the switch works in MiHome with no issue.

[EDIT]: Adding more details.

If I use the new configuration item ‘model’ i get this result:

[homeassistant.components.switch.xiaomi_miio] Got exception while fetching the state: Unable to discover the device 192.1.X.X

Full config with this item:

- platform: xiaomi_miio
  name: Black Lamp
  host: !secret xiaomi_plug.blacklamp.host
  token: !secret xiaomi_plug.blacklamp.token
  model: chuangmi.plug.m1

thanks!

Please extract the token again. Your used token is incorrect.

thank you @syssi.

I also was thinking that was the issue. But the thing is that this is working in 0.63.3 with no issue. It is when I upgrate to latest when I see the issue.

I have checked the tokens ( I have 2 of this devices ) and both are correct.

anyone having this issue in 0.65.3??

The only issue I have seen is that the blue light can be on solid but it’s gone from HA and also the App says it’s offline and my router shows it’s not connected. First time this happened, I set it up again and got a new token and all good. Second time, I power cycled the switch and it’s all working again.

Funny thing is the last time it did it, my Yeelights were also offline and I power cycled them as well. No idea why this happens but I’m going to power cycle first in the future instead of a full reset.

Only difference is you still have app control which is very odd. Have you done anything strange like block internet access?

Nope, no changes in network, nothing. I did a complete reset of one of them and reconfigure.

Everything working perfectly in 0.63.3 with this log results:

e[32m2018-03-12 11:29:55 INFO (MainThread) [homeassistant.components.switch.xiaomi_miio] Initializing with host 192.168.x.XX (token XXXX…)e[0m
e[32m2018-03-12 11:29:55 INFO (MainThread) [homeassistant.components.switch.xiaomi_miio] chuangmi.plug.m1 1.2.4_17 MW300 initializede[0m

in 0.65.2 … stuck in the Initializing :frowning:

Did you downgrade to 0.63.3 today? If you update to the latest version of HA it didn’t work again?

Yes, I did downgrade to 0.63.3 … it’s the latest version I had this working …

Really want to go to to latest … but I need those switch :frowning:

This is strange. Could you enable the debug mode for the component and miio?

actually, it is … which is really weird … I only see that entry for each of the switches I have:

homeassistant.components.switch.xiaomi_miio: debug

Could you try this setting to enable the debug output of the underlying library:

logger:
  default: warn
  logs:
    homeassistant.components.switch.xiaomi_miio: debug
    miio: debug

Cool! Solved. Here’s what I did so anybaody else can use it.

@syssi, I added that line in the logger component so I started to see this error:

[miio.device] error while reading discover results: _decode() missing 1 required positional argument: ‘path’

I did some googling and found that the issue is because something was stuck un the deps folder and recommendation was to delete and restart. So I did and not everything works fine. This is the github that i found: xiaomi_miio not discovering devices · Issue #13092 · home-assistant/core · GitHub

thank you for your help!!!

2 Likes

I am having the same problem now with 0.80.3 release, but i am on hassbian so deleting the /deps folder nothing changed… any hints?