Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm25_value could be "unsupported" if dehumidifier didn't have pm2.5 sensor. #45

Closed
RiANOl opened this issue May 7, 2023 · 7 comments · Fixed by #47
Closed

pm25_value could be "unsupported" if dehumidifier didn't have pm2.5 sensor. #45

RiANOl opened this issue May 7, 2023 · 7 comments · Fixed by #47

Comments

@RiANOl
Copy link
Contributor

RiANOl commented May 7, 2023

pm25_value could be "unsupported" if dehumidifier didn't have pm2.5 sensor.
Tested on RDI-640HH

@qqaatw
Copy link
Owner

qqaatw commented May 7, 2023

That’s the desired behavior.

@RiANOl
Copy link
Contributor Author

RiANOl commented May 7, 2023

But it will crash whole integration.
Home Assistant consider this entity must not be string because of pm25 device class.
Maybe it should return None if get the "unsupported" value?

@qqaatw
Copy link
Owner

qqaatw commented May 7, 2023

Does the crash cause the integration being fully unusable or just throwing an error message?

Can you please paste the log or screenshot here? We accept PRs fixing that if the former is the case.

@RiANOl
Copy link
Contributor Author

RiANOl commented May 7, 2023

It will throw exception while setting up integration.

Log Details (ERROR)
Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:583
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 11:07:14 AM (2 occurrences)
Last logged: 11:07:14 AM

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

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 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 846, in add_to_platform_finish
    self.async_write_ha_state()
  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.dehumidifier_pm2_5 has device class pm25, state class None unit µg/m³ and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: unsupported (<class 'str'>)

@RiANOl RiANOl changed the title pm25_value could be "unsuppoerted" if dehumidifier didn't have pm2.5 sensor. pm25_value could be "unsupported" if dehumidifier didn't have pm2.5 sensor. May 7, 2023
@qqaatw
Copy link
Owner

qqaatw commented May 7, 2023

Hmm, when the error occurred, could other sensors/entities in other platforms be loaded normally, or they were blocked by the error?

It used to work until some changes brought by recent HA core versions I guess.

@RiANOl
Copy link
Contributor Author

RiANOl commented May 7, 2023

It still can set value but unable to get the update when the error occurred.
For example, I can turn on/off AC or dehumidifier or change the temperature, but the entity still show the previous value.

@RiANOl
Copy link
Contributor Author

RiANOl commented May 7, 2023

It used to work until some changes brought by recent HA core versions I guess.

Exactly, it happened since HA core upgrade to 2023.5.

@qqaatw qqaatw closed this as completed in #47 May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants