home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.06k stars 29.13k forks source link

Error with Qingping Air Monitor (cgllc.airmonitor.s1) after firmware upgrade to 4.1.8_0244 #76646

Open igogold opened 1 year ago

igogold commented 1 year ago

The problem

After the firmware upgrade of Qingping Air Monitor (cgllc.airmonitor.s1) to version 4.1.8_0244 Home Assistant can't get info anymore.

It seems air monitor resets connection with mi home after upgrade. I reconnected it back to mi home, in the mihome mobile app the monitor started to work and shows current values from screen.

I removed integration in the HA and added it back using a token. It recognized cgllc.airmonitor.s1 device and added it to HA. But now I see only one sensor entry w/o an entry from air_monitor domain. And this sensor entry just unavailable.

What version of Home Assistant Core has the issue?

core-2022.8.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Xiaomi Miio

Link to integration documentation on our website

https://www.home-assistant.io/integrations/xiaomi_miio/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-08-12 10:29:29.412 ERROR (MainThread) [homeassistant.components.air_quality] xiaomi_miio: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 477, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 702, in async_device_update
await task
File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/air_quality.py", line 135, in async_update
state = await self.hass.async_add_executor_job(self._device.status)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/site-packages/miio/click_common.py", line 184, in _wrap
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/miio/airqualitymonitor.py", line 197, in status
return AirQualityMonitorStatus(defaultdict(lambda: None, values))
ValueError: dictionary update sequence element #0 has length 1; 2 is required

2022-08-12 10:29:50.567 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.cgllc_airmonitor_s1 fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 514, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 709, in async_device_update
raise exc
File "/usr/src/homeassistant/homeassistant/components/xiaomi_miio/sensor.py", line 852, in async_update
state = await self.hass.async_add_executor_job(self._device.status)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/site-packages/miio/click_common.py", line 184, in _wrap
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/miio/airqualitymonitor.py", line 197, in status
return AirQualityMonitorStatus(defaultdict(lambda: None, values))
ValueError: dictionary update sequence element #0 has length 1; 2 is required

Additional information

The same issue with latest xiaomi-miio (0.5.12) in command line:

(miio) pk-imac-01-27:~% miiocli airqualitymonitor --ip 192.168.XX.XX --token XXXXXXX status
Traceback (most recent call last):
  File "/usr/local/lib/python-venv/miio/bin/miiocli", line 8, in <module>
    sys.exit(create_cli())
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/cli.py", line 66, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/click_common.py", line 51, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/click_common.py", line 305, in wrap
    kwargs["result"] = func(*args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/click_common.py", line 270, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/click_common.py", line 217, in call
    return method(*args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/click_common.py", line 184, in _wrap
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python-venv/miio/lib/python3.9/site-packages/miio/airqualitymonitor.py", line 197, in status
    return AirQualityMonitorStatus(defaultdict(lambda: None, values))
ValueError: dictionary update sequence element #0 has length 1; 2 is required
probot-home-assistant[bot] commented 1 year ago

xiaomi_miio documentation xiaomi_miio source (message by IssueLinks)

probot-home-assistant[bot] commented 1 year ago

Hey there @rytilahti, @syssi, @starkillerog, @bieniu, mind taking a look at this issue as it has been labeled with an integration (xiaomi_miio) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

divanikus commented 1 year ago

Same here, just updated my two monitors, and both doesn't report anything to HA now.

sstu commented 1 year ago

I confirm that the firmware has been updated to version 4.1.8_0244 today and sensor.cleargrass_air Unavailable. Reset and reconnect nothing has changed

rytilahti commented 1 year ago

I suppose this is being tracked upstream at https://github.com/rytilahti/python-miio/issues/1489

ildar170975 commented 1 year ago

Confirm with 2 devices.

Anton-Ka commented 1 year ago

I also confirm this issue. Can you tell me what can be done about it at the moment?

pkmcnc commented 1 year ago

I confirm that problem with my devices

EvgenaNet commented 1 year ago

Same problem is here...

EvgenaNet commented 1 year ago

Same problem is here...

oiltox commented 1 year ago

confirm an issue

rytilahti commented 1 year ago

Feel free to click the subscribe button either here or on the upstream issue (where this needs to be fixed in the first place), I think there are already enough confirmations that it's an issue.

sstu commented 1 year ago

2022.8.5 not fixed

sstu commented 1 year ago

2022.8.6 not fixed

WeslyG commented 1 year ago

I think it would be a great idea to indicate here a link to the original problem in the Miio library https://github.com/rytilahti/python-miio/issues/1489

pechatny commented 1 year ago

I confirm that problem with my device

WeslyG commented 1 year ago

I have written code that fixes this problem for the 4th version of the firmware, but it is not yet clear how fast it will be in the new version of the Miio library and when the Home assistant will be able to update it. we'll wait.

https://github.com/rytilahti/python-miio/pull/1510

sstu commented 1 year ago

https://github.com/Cheaterdev/clear_grass-ha/issues/13

For those who are in a hurry, a temporary solution is written here

droserHA commented 1 year ago

Please explain where to fix this file? where does he lie?

maxifly commented 1 year ago

2022.8.7 not fixed

WeslyG commented 1 year ago

My edit has been successfully merged into the main python-miio branch, I hope the release of a new version with Miio fixes will be fast.

https://github.com/rytilahti/python-miio/issues/1489#event-7290801852

ildar170975 commented 1 year ago

@WeslyG What you commented is: "I wrote an implementation that removes the battery field for the 4th firmware version," -- so this update simply removes battery_level info and shows air quality data, right?

If yes - then this is a "solution" similar to https://github.com/Cheaterdev/clear_grass-ha/issues/13 - and this seems like a temporal fix rather than a real solution.

WeslyG commented 1 year ago

After update 4.1.8._0256 access to battery property has not appeared. :(

WeslyG commented 1 year ago

@ildar170975

yes, unfortunately, my attempts to understand where the property has moved (renamed) did not lead to a result, because we do not know the original xiaomi protocol or their source codes. (which I'm sure can be done if desired, but it will take a very long time). Therefore, now the main task is to make the integration work again, for which you can use the battery field, which may return later after updating the device firmware.

There is a possibility that the disappearance of the battery field (or rather, the return of an exception to its request) this is nothing but a bug in the device's software.

ildar170975 commented 1 year ago

@WeslyG Strange that battery_level still can be acquired from ClearGrass devices by MiHome mobile app. FW on CG was updated 11.08.22 (and I checked it with MiHome that day, it worked), the latest updates of MiHome are below: image

WeslyG commented 1 year ago

@ildar170975 Yes, of course, they will work, because the interface of local interaction (through which we poll devices) and the interface for managing sending data to the server are different parts of the firmware application. In the internal view, everything is still functioning, but no requests are coming directly to the device via wifi. (I was recording my network traffic to this device to determine this) The local interface, as I understand it, is used to get data faster than through an external cloud. It is very likely that now, battery data will always be available only through the cloud.

ildar170975 commented 1 year ago

battery data will always be available only through the cloud.

Using Roborock S5 vacuum robot, battery_level is available via Miio integration. Or is it a different story?

WeslyG commented 1 year ago

@ildar170975

Yes, it seems to me that these are slightly different stories. I tried to draw how I see the whole scheme of working with the device. And it seems to me that cloud sender has slightly different access to Internal state than local sender. I can't prove it yet, but I'll try to put a record of all traffic on port 54321 on my airQuality and see, after a while, on all incoming requests, whether there will be a battery property.

image

igogold commented 1 year ago

2022.9.0 not fixed

vmishurov commented 1 year ago

2022.9.0 not fixed

Because there is still no new release python-miio :(

Cyberlenin commented 1 year ago

Is it possible to fix this issue via HACS? It seems that owner of python-miio is not willing to update it anytime soon.

pkmcnc commented 1 year ago

Interesting fact. I disconnected ClearGrass from power and left it. Later I found that it had transmitted data to HA for ~20mins while it was discharging. It never happens when it's powered.

Anton-Ka commented 1 year ago

Interesting fact.

I trying repeat your case, but I don't have data from ClearGrass.

vmishurov commented 1 year ago

I trying repeat your case, but I don't have data from ClearGrass.

same

pkmcnc commented 1 year ago

Not that it connects to HA immediately when the poswer supply is off. But it definitely connects while the battery charge is somewhere between 100% and 0%. I just observed it when charging the device back - see the picture, two devices transmitted data for ~10 minutes (it's charging faster than discharging). Of course, I re-added both devices to HA after upgrade to 4.1... image

batja84 commented 1 year ago

I've got this message.

image
pkmcnc commented 1 year ago

Have you re-added it to Mi Home after firmware updating? Can you see it in Mi Home?

batja84 commented 1 year ago

Have you re-added it to Mi Home after firmware updating? Can you see it in Mi Home?

😲 Thank you!!! It helped. Just re-added it in MiHome and than done the same in Xiaomi Miot Auto.

pkmcnc commented 1 year ago

😲 Thank you!!! It helped. Just re-added it in MiHome and than done the same in Xiaomi Miot Auto.

And what do you have now?

dumbodumbos commented 1 year ago

😲 Thank you!!! It helped. Just re-added it in MiHome and than done the same in Xiaomi Miot Auto.

And what do you have now?

Снимок экрана 2022-09-15 в 11 24 45
batja84 commented 1 year ago

And what do you have now?

The same as dumbodumbos

vmishurov commented 1 year ago

Well, what's the point in that? Turn the power on and the problem comes back...

Anton-Ka commented 1 year ago

I tried adding the monitor to HA again. I removed the device from MiHome, removed its integration from HA, restarted the server after updating it. Added monitor to MiHome again, added it to HA. In MiHome, I can see all the data, Screenshot_2022-09-15-13-46-25-70_89ed83f5c7ca8fa2c91fc75c50289338 but there is still no data in HA Screenshot_2022-09-15-13-39-25-65_c3a231c25ed346e59462e84656a70e50

dumbodumbos commented 1 year ago

Well, what's the point in that? Turn the power on and the problem comes back...

I didn't turn off the power. The device, as it was powered from the outlet, remained so. Didn't switch to battery power.

Anton-Ka commented 1 year ago

I didn't turn off the power. The device, as it was powered from the outlet, remained so. Didn't switch to battery power.

In which region do you use MiHome?

dumbodumbos commented 1 year ago

I tried adding the monitor to HA again. I removed the device from MiHome, removed its integration from HA, restarted the server after updating it. Added monitor to MiHome again, added it to HA. In MiHome, I can see all the data, Screenshot_2022-09-15-13-46-25-70_89ed83f5c7ca8fa2c91fc75c50289338 but there is still no data in HA Screenshot_2022-09-15-13-39-25-65_c3a231c25ed346e59462e84656a70e50

Буду по русски ) Поставил интеграцию Xiaomi Miot Auto - далее добавил устройство - данные пришли через минуту. На питание от АКБ не переходил. Регион Китай

vmishurov commented 1 year ago

Deleted the device from HA and from MiHome Then connected again. No data :( And... what is "Xiaomi Miot Auto" ? I use Xiaomi Miio integration?

dumbodumbos commented 1 year ago

And... what is "Xiaomi Miot Auto" ? I use Xiaomi Miio integration?

Xiaomi Miot Auto - add it via HACS. In it, this device works correctly. https://github.com/al-one/hass-xiaomi-miot

Anton-Ka commented 1 year ago

Xiaomi Miot Auto - add it via HACS. In it, this device works correctly. https://github.com/al-one/hass-xiaomi-miot

I confirm that. Adding device from this integration and I see data. Thanks dumbodumbos .

ildar170975 commented 1 year ago

Adding device from this integration and I see data.

Including battery level?