Temperature unit conversions are moving from the
Entity base class to the
class. Unit conversions will only be done if the sensor's
device_class attribute is set
DEVICE_CLASS_TEMPERATURE. If the
device_class is not set or is not set to
DEVICE_CLASS_TEMPERATURE temperature conversion will take place during a transition
period and a warning will be logged.
To facilitate this, the sensor entity model has been updated with two new properties,
native_unit_of_measurement. This allows us to add additional
unit conversions in the future instead of relying on the integrations to do it themselves.
Sensor implementations should no longer implement the
state() property function or set
_attr_state attribute. Sensor implementations should also not implement the
unit_of_measurement property function, set the
or set the
unit_of_measurement member of
The value reported by the sensor.
The actual state written to the state machine may be modified by
SensorEntity due to
The unit of measurement of the sensor, if any.
unit_of_measurement written to the state machine may be modified by
due to unit conversions.