libdyson-wg / ha-dyson

Home Assistant custom integration for Wi-Fi connected Dyson devices
MIT License
251 stars 28 forks source link

ValueError: invalid literal for int() with base 10: 'NONE' #2

Closed GitPetri closed 1 year ago

GitPetri commented 1 year ago

I have a Home Assistant dyson integration and the following error message appears in the log: `File "/usr/local/lib/python3.10/site-packages/libdyson/dyson_pure_humidify_cool.py", line 110, in formaldehyde return int(self._get_environmental_field_value("hcho"))

File "/usr/local/lib/python3.10/site-packages/libdyson/dyson_device.py", line 292, in _get_environmental_field_value return int(value)

ValueError: invalid literal for int() with base 10: 'NONE'`

dotvezz commented 1 year ago

@GitPetri thanks for this report! I have a few quick questions for you:

  1. Is the integration failing to set up your device at all?
  2. What is your device model? If you can post here exactly what the website/app says, that would be awesome.

It sounds like you have a non-Formaldehyde model, which we've recently learned has some internal naming overlaps with the Formaldehyde models that affect some of the logic in libdyson.

My next priority on this project is to clear up the Formaldehyde conflicts so both types can live happily together. Your answers could really help!

GitPetri commented 1 year ago

@GitPetri thanks for this report! I have a few quick questions for you:

  1. Is the integration failing to set up your device at all?
  2. What is your device model? If you can post here exactly what the website/app says, that would be awesome.

Hi there

  1. the integration works, it seems to be just an annoying log error message
  2. I have 2 Dyson devices and the models are 358E and 520 as reported by the Dyson integration device info. I assume the error message comes from the 358E which is not a formaldehyde model. The user guide for the 358E states Dyson model number ph03: www.fi.dyson.com/content/dam/dyson/maintenance/user-guides/fi_FI/airtreatment/purifier-humidifiers/ph03/369095-01.pdf Android App shows Dyson Purifier Humidify+Cool™
GitPetri commented 1 year ago

And this is the full log entry `Logger: homeassistant Source: custom_components/dyson_local/sensor.py:337 Integration: Dyson Local (documentation, issues) First occurred: 09:36:58 (58 occurrences) Last logged: 09:50:58

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 330, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 135, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 390, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 600, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 565, in _stringify_state if (state := self.state) is None: File "/config/custom_components/dysonlocal/utils.py", line 18, in __get__ value = super().__get_\(obj, type) File "/config/custom_components/dyson_local/sensor.py", line 337, in state return self._device.formaldehyde File "/usr/local/lib/python3.10/site-packages/libdyson/dyson_pure_humidify_cool.py", line 110, in formaldehyde return int(self._get_environmental_field_value("hcho")) File "/usr/local/lib/python3.10/site-packages/libdyson/dyson_device.py", line 292, in _get_environmental_field_value return int(value) ValueError: invalid literal for int() with base 10: 'NONE'`

Anto79-ops commented 1 year ago

I get something similar, I think the machine might output a "fail" value every once in a while, and that is not-numeric. Maybe if you add and 'else' not numeric, it becomes "unknown" and not none?

Logger: homeassistant
Source: components/sensor/__init__.py:583
First occurred: May 8, 2023 at 8:48:53 PM (6 occurrences)
Last logged: 11:36:43 AM

Error doing job: Exception in callback Entity.async_write_ha_state()
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 579, in state
    numerical_value = int(value)
ValueError: invalid literal for int() with base 10: 'fail'

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 583, in state
    raise ValueError(
ValueError: Sensor sensor.pure_hot_cool_pm_2_5 has device class pm25, state class measurement unit µg/m³ and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: fail (<class 'str'>)
dotvezz commented 1 year ago

v0.21.0 has been released which potentially resolves this issue. Let me know if you have issues @Anto79-ops and @GitPetri!

Anto79-ops commented 1 year ago

Thanks @dotvezz! Keep you posted.

Anto79-ops commented 1 year ago

@dotvezz just updated and no issues. Sometimes its takes a day for this error message to show up so I'll keep an eye on the logs.

By the way, I still see this in my logs , I realize that the HCHO thing is still a work in progress...but I just recently connected with a Dyson engineer on LinkedIn named David Hill. He seems like someone who would know the answer so keep you posted on that!

GitPetri commented 1 year ago

v0.21.0 has been released which potentially resolves this issue. Let me know if you have issues @Anto79-ops and @GitPetri!

Just updated, will keep you posted on results.

GitPetri commented 1 year ago

@dotvezz just updated and no issues. Sometimes its takes a day for this error message to show up so I'll keep an eye on the logs.

By the way, I still see this in my logs , I realize that the HCHO thing is still a work in progress...but I just recently connected with a Dyson engineer on LinkedIn named David Hill. He seems like someone who would know the answer so keep you posted on that!

Do you mean this?

--- clip ---

Logger: homeassistant.components.sensor Source: components/sensor/init.py:650 Integration: Sensor (documentation, issues) First occurred: 10:27:57 (1 occurrences) Last logged: 10:27:57

Entity sensor.master_bedroom_formaldehyde (<class 'custom_components.dyson_local.sensor.DysonHCHOSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('volatile_organic_compounds') it is using; expected one of ['µg/m³']; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

dotvezz commented 1 year ago

Yeah, the HCHO Sensor is still not using any units. This is because we haven't been able to figure out what units the sensor is reporting in, and haven't nailed down a reasonable conversation factor.

I'm super curious about whether your new connection can help us out, @Anto79-ops!

dotvezz commented 1 year ago

We were finally able to nail down the formaldehyde sensor! https://github.com/libdyson-wg/ha-dyson/releases/tag/v0.22.0

Anto79-ops commented 1 year ago

Since updating, I have not seen this message quoted here.

https://github.com/libdyson-wg/ha-dyson/issues/2#issuecomment-1540606028

Thanks for fixing that!

GitPetri commented 1 year ago

Since updating, I have not seen this message quoted here.

#2 (comment)

Thanks for fixing that!

Same for me. Thank you for fixing.

GitPetri commented 1 year ago

We were finally able to nail down the formaldehyde sensor! https://github.com/libdyson-wg/ha-dyson/releases/tag/v0.22.0

Installed v0.22.1 via HACS - Formaldehyde gives values and I got rid of the log error

image
dotvezz commented 1 year ago

I wish it didn't just have the "Eye" icon, but to fix that I'll have to add a SensorDeviceClass for Formaldehyde in HA Core. I'll add that to the list of things to do. But for now, closing this issue! Feel free to reopen or follow up if yo uhave any more issues.

Anto79-ops commented 1 year ago

@dotvezz you can easily change the icon using front end... Just click on the entity properties and change the MDI icon, for example:

Screenshot_20230710_080432_Home Assistant.jpg

mundschenk-at commented 1 year ago

I am pretty sure you can also set custom icons programmatically without a Core device class.

dotvezz commented 1 year ago

Aha, I'll look into setting the icons programmatically then! Thanks!