Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.84k stars 1.65k forks source link

Z2M reports incomplete state information for lights #21672

Open fredck opened 6 months ago

fredck commented 6 months ago

What happened?

A long discussion has been taking place at https://github.com/home-assistant/core/issues/110440 about issues with light states. In that issue, the problem is specifically related to a MiBoxer RGB+CCT led controller, identified by Z2M as Tuya TS0505B_1. The outcome of that discussion, in short is: HA requires lights to provide their complete state information if they wish to be properly handled.

I could have opened an issue for Tuya TS0505B_1 only but I believe this issue can be expanded to a broader issue: Z2M is reporting incomplete state information for lights, sometimes.


The specific case

I have many MiBoxer led controllers (Tuya TS0505B_1) at home. For some reason, some of them don't have complete state information in Z2M. For comparison, I've just copied the following state information directly from Z2M from two of these controllers:

Case 1: this one has complete state:

{
    "brightness": 127,
    "color": {
        "x": 0.417,
        "y": 0.3963
    },
    "color_mode": "color_temp",
    "color_power_on_behavior": null,
    "color_temp": 303,
    "do_not_disturb": null,
    "linkquality": 163,
    "state": "ON"
}

Case 2: this one has partial state:

{
    "brightness": 127,
    "color_power_on_behavior": null,
    "do_not_disturb": null,
    "linkquality": 29,
    "state": "ON"
}

The thing to notice for the second case is that, the physical light works. It goes on and the brightness is properly applied.

As expected, the above states are being reported to MQTT, reaching the HA MQTT Integration, which completes the state data with everything that HA requires.

HA's Light entities are required to provide state data that include certain properties. Among them we have color_mode and supported_color_modes. Additionally, for the specified color_mode the relative color data must be provided (and data for other color modes should not be present, as well).

Everything is good with the state data of the first case I've exemplified. But the second one doesn't have enough information to build a complete state information. The MQTT Integration and HA start doing guess work then and things get messy.

What did you expect to happen?

In short: Z2M must always provide complete state information of lights.

This means that the second case in my examples should have as much information as the first one.

How to reproduce it (minimal and precise)

I don't have a clear way to reproduce this problem.

On thing that anyone can try is checking the state information for all lights they have installed until one with not enough state information is found.


My guess is that color has never been set to the "Case 2" light since it has been installed and the device never reported color information to Z2M. Since Z2M doesn't have this information, the light state stays partial.

Zigbee2MQTT version

1.36.0

Adapter firmware version

20230507

Adapter

SLZB-06 POE

Setup

Docker container

Debug log

I can attach some log, in required, but the device "State" tab in Z2M is the right place to look at.

github-actions[bot] commented 4 weeks ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days

fredck commented 6 days ago

This is still an issue.

It would be nice to have someone at least commenting on whether having the full state for lights makes sense.