When adding a new Sensor Variable with v3.4.7, configured with
Device Class: PM25
State Class: MEASUREMENT
Unit of Measurement: µg/m³
the Entity can't get created. In UI it shows up as "No Device or Entity". Reload doesn't help either.
The corresponding Error Log says:
Error adding entity sensor.ac_cleaner_1_pm25_daily_1st_hour_average for domain sensor with platform variable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 714, in _async_add_entity
entity.add_to_platform_start(
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 244, in add_to_platform_start
self._sensor_option_unit_of_measurement = self._get_initial_suggested_unit()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 415, in _get_initial_suggested_unit
if not self._is_valid_suggested_unit(suggested_unit_of_measurement):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 383, in _is_valid_suggested_unit
raise ValueError(
ValueError: Entity <class 'custom_components.variable.sensor.Variable'> suggest an incorrect unit of measurement: µg/m³.
What helped me was a hacky procedure:
Set up the Sensor without any Measurement/Class/Unit
Then it gets created sucessfully
Edit the set up Sensor and add the missing Measurements etc.
Then it gets shown with the correct Unit. I hope it will end up in the LTS as well.
When adding a new Sensor Variable with v3.4.7, configured with
the Entity can't get created. In UI it shows up as "No Device or Entity". Reload doesn't help either. The corresponding Error Log says:
What helped me was a hacky procedure: