Closed xcray closed 6 years ago
Which hardware version of the gateway do you own? Which firmware version do you use and could you provide some steps to reproduce the issue (initial brightness, color and state).
@syssi Thanks for your comment! hw_ver: MW300, model: lumi.gateway.v3, with the newest firmware: fw_ver 1.4.1_155. The wifi_fw_ver is SD878x-14.76.36.p84-702.1.0-WM, also the newest. steps to reproduce: 1, fresh default configurations for xiaomi_gateway integration (I also configured home-assistant-homebridge). 2, turn on and then off the gateway light using HA frontend, or Home App of iOS. 3, go back to Mijia App, click on the light, it will not glitter. 4, modify the brightness/color in Mijia App, then it recovers.
It seems that the brightness had been set to an illegal value after turning on & off via HA, and the color had been set to RED.
Please enable the debug output by
# configuration.yaml
logger:
default: warn
logs:
xiaomi_gateway: debug
homeassistant.components.xiaomi_aqara: debug
homeassistant.components.light.xiaomi_aqara: debug
restart HA, set the brightness of the gateway light to 50%. Toggle the light some times to reproduce the issue and provide the home-assistant.log.
I could reproduce the bug (same firmware & device). It's a bug of the MiHome app / Xiaomi Cloud and cannot be improved here. Home Assistant is always aware of the correct state of the light. The MiHome app gets out of sync some times.
@syssi Thanks for your comments, I totally agree with you that it's a bug or defect of the gateway or it's interface or the app/cloud. It should have an API with a simple command just turn the light on/off, and another command to modify brightness/color and stored inside the GW. I'm not sure if we modify the default brightness/color in HA or PyXiaomiGateway to a lower value/yellow could make help.
In my case the color isn't the issue. Try to do something like this:
Do you have a feeling for the issue?
Please try to identify edge cases. I'm aware of problems if the brightness is very low. In this case the light cannot turned on sometimes. Are there issues with some colors, too?
In my understanding, the LAN API command to control the light is just write RGB value to the GW, RGB=0xFF000000 means turn off while 0xFFFFFFFF means the maximum brightness and white color. Am I right? It seems that HA (& PyXiaomiGateway?) use 0xFFFFFFFF for the first time turning it on, which could cause this issue (I guessed). In my case: 1, I am using a motion sensor to adopt the gw light as a night-light, normally with a brightness of about 5% and orange color. 2, After HA configured, I use HA to turn the light on, it seems to have the maximum brightness and white color, so I guess HA/PyXiaomiGateway use the value of 0xFFFFFFFF. 3, Then I could found that the night-light will be out-of-service, but inside the log of Mijia App, it looks very well, will the automation executed successfully while I move around the motion sensor. 4, Then, in the Mijia App, I try to turn the light on, the icon of bulb indicated it's on, but in fact it's not. And the brightness indication in Mijia App is on the most of right (maximum brightness), color indication is on the bottom of left, which means white. 5, I adjust the brightness now, to any level lower than maximum, the color will jump to red, and then Mijia got back the control.
It seems that Mijia App store lasts glittered RGB value (not 0xFF000000) on the cloud (so different mobiles could sync each-other).
@syssi I'd just taken an experiment:
So, to keep the function of night-light available, I have to disable the light component in "lib/python3.6/site-packages/homeassistant/components/xiaomi_aqara.py".
You could hide the entity by "customize". This should work out of the box.
@syssi Maybe miio interface is a better choice to control gw's light, would u pls consider this?
@syssi It's a regret that hiding in customize can't help to this issue. I'd tried hide it and never tough it in HA, the MiHome (Mijia) App also could lost control of it. So, I have to modify the source code.
Home Assistant release with the issue:
0.71.0
Last working Home Assistant release (if known):
Operating environment (Hass.io/Docker/Windows/etc.):
Ubuntu Component/platform:
https://www.home-assistant.io/components/light.xiaomi_aqara/ https://www.home-assistant.io/components/xiaomi_aqara/
Description of problem:
As default, HA will discover and configure xiaomi_light automatically. But it seems that there are something wrong within the xiaomi_aqara LAN API. If I'd toggled on/off the gateway light, it's brightness/color will be reset to 100/red, and then it will not work properly in the official Mijia App. Even one of mijia app's automation excused successfully with the light turned on, it doesn't glitter at all. Until I'd modified the brightness/color in Mijia App, it will not recover to work. btw, I don't think this is a bug of HA, but of the official LAN API.
Problem-relevant
configuration.yaml
entries and (fill out even if it seems unimportant):Traceback (if applicable):
Additional information: Un ugly hack is to disable the light in HA. If just set "disabled_by" in entity_registry.yaml (as metioned by HA here, this is a quite experimental feature) , HA will throw many errors saying:
So, I'd delete the word 'light' in the line 142 of lib/python3.6/site-packages/homeassistant/components/xiaomi_aqara.py. I know this is not the correct choice, but I don't know a better one just now.
Maybe future code of the xiaomi_aqara component/platform could handle this issue with more adaptability?