vlebourl / custom_vesync

Custom VeSync component for Home Assistant
96 stars 59 forks source link

Core 300S Automation Broken #160

Closed crypticviper closed 9 months ago

crypticviper commented 10 months ago

The problem

I had an automation which was using the Air Quality sensor value changes to trigger some actions. However, after recent update (I updated both the firmware on the device and also the integration in HA, not sure what is causing this!) the trigger on which my automation was using shows as "unknown" and there doesn't seem to be an alternative trigger which I can use for my purpose.

Firmware version is 1.1.108

What version of this integration has the issue?

1.0.2

What version of Home Assistant Core has the issue?

2023.8.4

Diagnostics

Diagnostics ```json { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.8.4", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.4", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.1.21-v8", "supervisor": "2023.08.1", "host_os": "Home Assistant OS 10.5", "docker_version": "23.0.6", "chassis": "embedded", "run_as_root": true }, "custom_components": { "vesync": { "version": "1.0.2", "requirements": [ "pyvesync==2.1.7" ] }, "hacs": { "version": "1.32.1", "requirements": [ "aiogithubapi>=22.10.1" ] } }, "integration_manifest": { "domain": "vesync", "name": "VeSync", "codeowners": [ "@markperdue", "@webdjoe", "@thegardenmonkey", "@vlebourl" ], "config_flow": true, "dhcp": [ { "hostname": "levoit-*", "macaddress": "*" } ], "documentation": "https://www.home-assistant.io/integrations/vesync", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/vlebourl/custom_vesync", "requirements": [ "pyvesync==2.1.7" ], "version": "1.0.2", "is_built_in": false }, "data": { "fans": [ { "device_name": "Bedroom Air Purifier", "device_image": "https://image.vesync.com/defaultImages/deviceDefaultImages/wifibtonboardingnotify_airpurifier_core300s_eu_240.png", "cid": "**REDACTED**", "connection_status": "online", "connection_type": "WiFi+BTOnboarding+BTNotify", "device_type": "Core300S", "type": "wifi-air", "uuid": "**REDACTED**", "config_module": "WiFiBTOnboardingNotify_AirPurifier_Core300S_EU", "mac_id": "**REDACTED**", "mode": "sleep", "speed": 1, "extension": { "airQuality": -1, "airQualityLevel": 1, "mode": "sleep", "fanSpeedLevel": "255" }, "current_firm_version": null, "device_region": "EU", "pid": null, "sub_device_no": null, "config": { "display": false, "display_forever": true }, "device_status": "off", "enabled": false, "config_dict": { "module": "VeSyncAirBypass", "models": [ "Core300S", "LAP-C301S-WJP", "LAP-C302S-WUSB" ], "modes": [ "sleep", "off", "auto", "manual" ], "features": [ "air_quality" ], "levels": [ 1, 2, 3, 4 ] }, "features": [ "air_quality" ], "modes": [ "sleep", "off", "auto", "manual" ], "air_quality_feature": true, "details": { "filter_life": 91, "mode": "manual", "level": 0, "display": false, "child_lock": false, "night_light": "off", "air_quality": 1, "display_forever": false, "air_quality_value": 5 }, "timer": null } ] } } ```

Home Assistant log

Screenshot of automation options:

image
Logs Nothing interesting or fishy after enabling debug logs.

Additional information

Not sure if this is related to already closed issues on Core300S #142 #150

BrettEBowman commented 10 months ago

My system log is showing this error for the vesync air quality value. I believe this is why it is no longer being reported in HA.

Source: components/sensor/__init__.py:595
Integration: Sensor (documentation, issues)
First occurred: 3:37:03 PM (6 occurrences)
Last logged: 3:51:33 PM

Error adding entities for domain sensor with platform vesync
Error while setting up vesync platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 593, in state
    numerical_value = float(value)  # type:ignore[arg-type]
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'Excellent'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 746, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 808, in _async_write_ha_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 752, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 595, in state
    raise ValueError(
ValueError: Sensor sensor.air_purifier_air_quality has device class 'aqi', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Excellent' (<class 'str'>)
vlebourl commented 9 months ago

Hey, sorry for the delay... I'm not sure where the 'Excellent' is comig from. Would you be willing to share your device so I can debug it? I suspect #162 is also related to this. Here's my email for sharing. image

crypticviper commented 9 months ago

@vlebourl app says "Please remind the user to to download the latest version".

vlebourl commented 9 months ago

what app? from your phone? did you update it recently?

crypticviper commented 9 months ago

Yes, the iPhone app. Last updated on September 5th. I don't see any new updates.

vlebourl commented 9 months ago

nothing that can be done on my side for that... nevertheless, would you be willing to share access to the Core 300S so I can debug the integration? this can be done through the app by long pressing the device, and select "share".

crypticviper commented 9 months ago

I am willing to and was trying to share. That's when I get the error I mentioned above.

WhatsApp Image 2023-09-14 at 9 37 29 AM

vlebourl commented 9 months ago

damn... I am on latest version though... ok, can you use the second email? image (at gmail as well)

crypticviper commented 9 months ago

Invite sent (or so it says!)

vlebourl commented 9 months ago

mind joining the discord ? https://discord.gg/svRa6qQq

vlebourl commented 9 months ago

My system log is showing this error for the vesync air quality value. I believe this is why it is no longer being reported in HA.

Source: components/sensor/__init__.py:595
Integration: Sensor (documentation, issues)
First occurred: 3:37:03 PM (6 occurrences)
Last logged: 3:51:33 PM

Error adding entities for domain sensor with platform vesync
Error while setting up vesync platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 593, in state
    numerical_value = float(value)  # type:ignore[arg-type]
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'Excellent'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 746, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 808, in _async_write_ha_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 752, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 595, in state
    raise ValueError(
ValueError: Sensor sensor.air_purifier_air_quality has device class 'aqi', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Excellent' (<class 'str'>)

Do you have the LV-PUR131S by any chance?

vlebourl commented 9 months ago

This should be fixed now. Be aware a new sensor has been added. If available on the device, it now shows both "Air Quality" and "Air Quality Value", reflecting the different values from the underlying library (see https://github.com/webdjoe/pyvesync/commit/744a0712fd2ccd564fc694d9c00ca461aaad8a93) where the latter relates to the PM2.5 reading.