Xiaomi Philips Light behavior when not available

Hello.

I have included a Philips light in my Home Assistant setup, with the xiaomi_miio platform.

In parallel, I also have a couple of Yeelights included in Home Assistant.

In what concerns to the Philips light, it doesn’t seem to become unavailable as the Yeelight, when turned off in the physical light switch or not available in the network (it either stays turned on/off on frontend).

Example of how a Yeelight appears when not connected to the network:
image

Is there something that can be done or does the platform need to be fixed to be consistent with other lights?

@syssi, what is your view on this?

Thanks in advance for all your help and great work.

Hmmm… I will think about it and try to compare both implementations.

1 Like

Quick question, if I may:

Do you know if this component support this Mijia lamp or is there any other that does (even if custom)?

Btw, do you need help in fixing this component for the unavailable part?

Thanks in advance.

I’m unsure about the unavailable feature. The PlatformNotReady behavior (device doesn’t show up if not found) was suggested by some other people. I’m unsure about the right direction.

The Mijia Desk Lamp should work but it’s untested. Please help if you own the device.

For what it’s worth, my personal opinion is that it would make more to sense to keep it visible and mark it as not available.

Still then, now that you mention it, I don’t think it disappears when it is not available anyway. Should it not show in that case?

Mijia lamp is currently on the way, coming from an European warehouse to a european country, so it should be quick. I’ll drop you a message once it arrives and have it setup.

Now that I think about it, maybe it will also work with the Yeelight component. I’ll try both anyway.

Thanks again.

You are right. Unfortunately the feature cannot be easily achieved. The light.xiaomi_miio tries to autodetect the device type and chooses the appropriate device class. I cannot create a proper device without a knowledge about the “unavailable hardware”. In future all xiaomi_miio devices are handled by auto-discovery. I’m afraid showing a “unavailable device” will be hard.

What puzzles me is how they do it for Yeelight then, because these are also supported via auto-discovery.

A bit of the background:

Yeelight (Unavailable) device is created. Just the ip address is needed.
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/yeelight.py#L139

Yeelight The device decides at runtime which features are supported.
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/yeelight.py#L255-L266

Philips Light Different device classes are available. We have to decide first which hardware & features will be addressed.
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/light/xiaomi_miio.py#L53-L86

First of all, thanks a lot for the in-depth explanation. I see your doubt, it all makes more sense now.

What about having a default light device class to be assigned only when device is unavailable (considering that you’re not able to actually determine the real device class)?

This would allow you to show it as unavailable, but then you’d also need to be able to redetermine the device class if it would become available in the meanwhile (and I don’t know if that’s possible without restarting HA).

Just a thought.

I see the need and I will care about this issue soon. You can track the progress here:

The feature is now available at the custom component for testing. Please add the device model to your configuration to avoid a failing auto-detection of a unreachable device:

light:
  - platform: xiaomi_miio
    name: Xiaomi Philips Smart LED Ball
    host: 192.168.130.67
    token: da548d86f55996413d82eea94279d2ff
    model: philips.light.bulb

@pplucky https://github.com/home-assistant/home-assistant/pull/12449

1 Like