diff --git a/homeassistant/components/daikin/sensor.py b/homeassistant/components/daikin/sensor.py index 3bfc0a3926c..0defa633387 100644 --- a/homeassistant/components/daikin/sensor.py +++ b/homeassistant/components/daikin/sensor.py @@ -86,7 +86,7 @@ class DaikinSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" raise NotImplementedError @@ -101,7 +101,7 @@ class DaikinSensor(SensorEntity): return self._sensor.get(CONF_ICON) @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._sensor[CONF_UNIT_OF_MEASUREMENT] @@ -119,7 +119,7 @@ class DaikinClimateSensor(DaikinSensor): """Representation of a Climate Sensor.""" @property - def state(self): + def native_value(self): """Return the internal state of the sensor.""" if self._device_attribute == ATTR_INSIDE_TEMPERATURE: return self._api.device.inside_temperature @@ -141,7 +141,7 @@ class DaikinPowerSensor(DaikinSensor): """Representation of a power/energy consumption sensor.""" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" if self._device_attribute == ATTR_TOTAL_POWER: return round(self._api.device.current_total_power_consumption, 2) diff --git a/homeassistant/components/danfoss_air/sensor.py b/homeassistant/components/danfoss_air/sensor.py index 792a95e8ac4..25db56a1624 100644 --- a/homeassistant/components/danfoss_air/sensor.py +++ b/homeassistant/components/danfoss_air/sensor.py @@ -100,12 +100,12 @@ class DanfossAir(SensorEntity): return self._device_class @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._unit diff --git a/homeassistant/components/darksky/sensor.py b/homeassistant/components/darksky/sensor.py index 058969d96f9..e73d9b2e1be 100644 --- a/homeassistant/components/darksky/sensor.py +++ b/homeassistant/components/darksky/sensor.py @@ -574,12 +574,12 @@ class DarkSkySensor(SensorEntity): return f"{self.client_name} {self._name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @@ -730,7 +730,7 @@ class DarkSkyAlertSensor(SensorEntity): return f"{self.client_name} {self._name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index 9282f2d26cc..a741a2d37c1 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -160,7 +160,9 @@ class DeconzSensor(DeconzDevice, SensorEntity): self._attr_device_class = DEVICE_CLASS.get(type(self._device)) self._attr_icon = ICON.get(type(self._device)) self._attr_state_class = STATE_CLASS.get(type(self._device)) - self._attr_unit_of_measurement = UNIT_OF_MEASUREMENT.get(type(self._device)) + self._attr_native_unit_of_measurement = UNIT_OF_MEASUREMENT.get( + type(self._device) + ) if device.type in Consumption.ZHATYPE: self._attr_last_reset = dt_util.utc_from_timestamp(0) @@ -173,7 +175,7 @@ class DeconzSensor(DeconzDevice, SensorEntity): super().async_update_callback(force_update=force_update) @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._device.state @@ -217,7 +219,7 @@ class DeconzTemperature(DeconzDevice, SensorEntity): _attr_device_class = DEVICE_CLASS_TEMPERATURE _attr_state_class = STATE_CLASS_MEASUREMENT - _attr_unit_of_measurement = TEMP_CELSIUS + _attr_native_unit_of_measurement = TEMP_CELSIUS TYPE = DOMAIN @@ -240,7 +242,7 @@ class DeconzTemperature(DeconzDevice, SensorEntity): super().async_update_callback(force_update=force_update) @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._device.secondary_temperature @@ -250,7 +252,7 @@ class DeconzBattery(DeconzDevice, SensorEntity): _attr_device_class = DEVICE_CLASS_BATTERY _attr_state_class = STATE_CLASS_MEASUREMENT - _attr_unit_of_measurement = PERCENTAGE + _attr_native_unit_of_measurement = PERCENTAGE TYPE = DOMAIN @@ -284,7 +286,7 @@ class DeconzBattery(DeconzDevice, SensorEntity): return f"{self.serial}-battery" @property - def state(self): + def native_value(self): """Return the state of the battery.""" return self._device.battery diff --git a/homeassistant/components/delijn/sensor.py b/homeassistant/components/delijn/sensor.py index b105ff5ff7b..395c2d93dff 100644 --- a/homeassistant/components/delijn/sensor.py +++ b/homeassistant/components/delijn/sensor.py @@ -112,7 +112,7 @@ class DeLijnPublicTransportSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/deluge/sensor.py b/homeassistant/components/deluge/sensor.py index 0c79e6f835e..63c9645dac4 100644 --- a/homeassistant/components/deluge/sensor.py +++ b/homeassistant/components/deluge/sensor.py @@ -87,7 +87,7 @@ class DelugeSensor(SensorEntity): return f"{self.client_name} {self._name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -97,7 +97,7 @@ class DelugeSensor(SensorEntity): return self._available @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement diff --git a/homeassistant/components/demo/sensor.py b/homeassistant/components/demo/sensor.py index 488c34be983..21ec8e1d391 100644 --- a/homeassistant/components/demo/sensor.py +++ b/homeassistant/components/demo/sensor.py @@ -120,10 +120,10 @@ class DemoSensor(SensorEntity): """Initialize the sensor.""" self._attr_device_class = device_class self._attr_name = name - self._attr_state = state + self._attr_native_unit_of_measurement = unit_of_measurement + self._attr_native_value = state self._attr_state_class = state_class self._attr_unique_id = unique_id - self._attr_unit_of_measurement = unit_of_measurement self._attr_device_info = { "identifiers": {(DOMAIN, unique_id)}, diff --git a/homeassistant/components/derivative/sensor.py b/homeassistant/components/derivative/sensor.py index c8b639a1db1..45f5db57a90 100644 --- a/homeassistant/components/derivative/sensor.py +++ b/homeassistant/components/derivative/sensor.py @@ -196,12 +196,12 @@ class DerivativeSensor(RestoreEntity, SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return round(self._state, self._round_digits) @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit_of_measurement diff --git a/homeassistant/components/deutsche_bahn/sensor.py b/homeassistant/components/deutsche_bahn/sensor.py index 33fd9a8224f..34711a9a2d7 100644 --- a/homeassistant/components/deutsche_bahn/sensor.py +++ b/homeassistant/components/deutsche_bahn/sensor.py @@ -59,7 +59,7 @@ class DeutscheBahnSensor(SensorEntity): return ICON @property - def state(self): + def native_value(self): """Return the departure time of the next train.""" return self._state diff --git a/homeassistant/components/devolo_home_control/sensor.py b/homeassistant/components/devolo_home_control/sensor.py index 7cb8cc8e837..5c8bed7818b 100644 --- a/homeassistant/components/devolo_home_control/sensor.py +++ b/homeassistant/components/devolo_home_control/sensor.py @@ -78,7 +78,7 @@ class DevoloMultiLevelDeviceEntity(DevoloDeviceEntity, SensorEntity): """Abstract representation of a multi level sensor within devolo Home Control.""" @property - def state(self) -> int: + def native_value(self) -> int: """Return the state of the sensor.""" return self._value @@ -106,7 +106,7 @@ class DevoloGenericMultiLevelDeviceEntity(DevoloMultiLevelDeviceEntity): self._attr_device_class = DEVICE_CLASS_MAPPING.get( self._multi_level_sensor_property.sensor_type ) - self._attr_unit_of_measurement = self._multi_level_sensor_property.unit + self._attr_native_unit_of_measurement = self._multi_level_sensor_property.unit self._value = self._multi_level_sensor_property.value @@ -132,7 +132,7 @@ class DevoloBatteryEntity(DevoloMultiLevelDeviceEntity): ) self._attr_device_class = DEVICE_CLASS_MAPPING.get("battery") - self._attr_unit_of_measurement = PERCENTAGE + self._attr_native_unit_of_measurement = PERCENTAGE self._value = device_instance.battery_level @@ -157,7 +157,7 @@ class DevoloConsumptionEntity(DevoloMultiLevelDeviceEntity): self._sensor_type = consumption self._attr_device_class = DEVICE_CLASS_MAPPING.get(consumption) - self._attr_unit_of_measurement = getattr( + self._attr_native_unit_of_measurement = getattr( device_instance.consumption_property[element_uid], f"{consumption}_unit" ) diff --git a/homeassistant/components/dexcom/sensor.py b/homeassistant/components/dexcom/sensor.py index 730a1824e1a..316f36e3630 100644 --- a/homeassistant/components/dexcom/sensor.py +++ b/homeassistant/components/dexcom/sensor.py @@ -42,12 +42,12 @@ class DexcomGlucoseValueSensor(CoordinatorEntity, SensorEntity): return GLUCOSE_VALUE_ICON @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of the device.""" return self._unit_of_measurement @property - def state(self): + def native_value(self): """Return the state of the sensor.""" if self.coordinator.data: return getattr(self.coordinator.data, self._attribute_unit_of_measurement) @@ -82,7 +82,7 @@ class DexcomGlucoseTrendSensor(CoordinatorEntity, SensorEntity): return GLUCOSE_TREND_ICON[0] @property - def state(self): + def native_value(self): """Return the state of the sensor.""" if self.coordinator.data: return self.coordinator.data.trend_description diff --git a/homeassistant/components/dht/sensor.py b/homeassistant/components/dht/sensor.py index 1300c165b37..d81d12f33cf 100644 --- a/homeassistant/components/dht/sensor.py +++ b/homeassistant/components/dht/sensor.py @@ -134,12 +134,12 @@ class DHTSensor(SensorEntity): return f"{self.client_name} {self._name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement diff --git a/homeassistant/components/discogs/sensor.py b/homeassistant/components/discogs/sensor.py index 81beec0e60e..3d90956a2b5 100644 --- a/homeassistant/components/discogs/sensor.py +++ b/homeassistant/components/discogs/sensor.py @@ -105,7 +105,7 @@ class DiscogsSensor(SensorEntity): return f"{self._name} {SENSORS[self._type]['name']}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -115,7 +115,7 @@ class DiscogsSensor(SensorEntity): return SENSORS[self._type]["icon"] @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" return SENSORS[self._type]["unit_of_measurement"] diff --git a/homeassistant/components/dnsip/sensor.py b/homeassistant/components/dnsip/sensor.py index 2fb0e30da90..a429d336379 100644 --- a/homeassistant/components/dnsip/sensor.py +++ b/homeassistant/components/dnsip/sensor.py @@ -79,6 +79,6 @@ class WanIpSensor(SensorEntity): response = None if response: - self._attr_state = response[0].host + self._attr_native_value = response[0].host else: - self._attr_state = None + self._attr_native_value = None diff --git a/homeassistant/components/dovado/sensor.py b/homeassistant/components/dovado/sensor.py index e7b3dbdd363..46f4c34cc31 100644 --- a/homeassistant/components/dovado/sensor.py +++ b/homeassistant/components/dovado/sensor.py @@ -89,7 +89,7 @@ class DovadoSensor(SensorEntity): return f"{self._data.name} {SENSORS[self._sensor][1]}" @property - def state(self): + def native_value(self): """Return the sensor state.""" return self._state @@ -99,7 +99,7 @@ class DovadoSensor(SensorEntity): return SENSORS[self._sensor][3] @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return SENSORS[self._sensor][2] diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index faff62ddeb4..ae3fb6b01a4 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -238,7 +238,7 @@ class DSMREntity(SensorEntity): return attr @property - def state(self) -> StateType: + def native_value(self) -> StateType: """Return the state of sensor, if available, translate if needed.""" value = self.get_dsmr_object_attr("value") if value is None: @@ -258,7 +258,7 @@ class DSMREntity(SensorEntity): return None @property - def unit_of_measurement(self) -> str | None: + def native_unit_of_measurement(self) -> str | None: """Return the unit of measurement of this entity, if any.""" return self.get_dsmr_object_attr("unit") diff --git a/homeassistant/components/dsmr_reader/definitions.py b/homeassistant/components/dsmr_reader/definitions.py index 1a46f86132b..a5fc2b8147a 100644 --- a/homeassistant/components/dsmr_reader/definitions.py +++ b/homeassistant/components/dsmr_reader/definitions.py @@ -50,7 +50,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/reading/electricity_delivered_1", name="Low tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -58,7 +58,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/reading/electricity_returned_1", name="Low tariff returned", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -66,7 +66,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/reading/electricity_delivered_2", name="High tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -74,7 +74,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/reading/electricity_returned_2", name="High tariff returned", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -82,14 +82,14 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/reading/electricity_currently_delivered", name="Current power usage", device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( key="dsmr/reading/electricity_currently_returned", name="Current power return", device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -97,7 +97,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current power usage L1", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -105,7 +105,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current power usage L2", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -113,7 +113,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current power usage L3", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -121,7 +121,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current power return L1", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -129,7 +129,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current power return L2", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -137,7 +137,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current power return L3", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_KILO_WATT, + native_unit_of_measurement=POWER_KILO_WATT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -145,7 +145,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Gas meter usage", entity_registry_enabled_default=False, icon="mdi:fire", - unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=VOLUME_CUBIC_METERS, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -154,7 +154,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current voltage L1", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_VOLTAGE, - unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -162,7 +162,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current voltage L2", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_VOLTAGE, - unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -170,7 +170,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Current voltage L3", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_VOLTAGE, - unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -178,7 +178,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Phase power current L1", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_CURRENT, - unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -186,7 +186,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Phase power current L2", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_CURRENT, - unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -194,7 +194,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( name="Phase power current L3", entity_registry_enabled_default=False, device_class=DEVICE_CLASS_CURRENT, - unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -207,7 +207,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/consumption/gas/delivered", name="Gas usage", icon="mdi:fire", - unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=VOLUME_CUBIC_METERS, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -215,7 +215,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/consumption/gas/currently_delivered", name="Current gas usage", icon="mdi:fire", - unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=VOLUME_CUBIC_METERS, state_class=STATE_CLASS_MEASUREMENT, ), DSMRReaderSensorEntityDescription( @@ -228,7 +228,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity1", name="Low tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -236,7 +236,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity2", name="High tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -244,7 +244,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity1_returned", name="Low tariff return", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -252,7 +252,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity2_returned", name="High tariff return", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -260,7 +260,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity_merged", name="Power usage total", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -268,7 +268,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity_returned_merged", name="Power return total", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, last_reset=dt_util.utc_from_timestamp(0), ), @@ -276,73 +276,73 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/day-consumption/electricity1_cost", name="Low tariff cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/electricity2_cost", name="High tariff cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/electricity_cost_merged", name="Power total cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/gas", name="Gas usage", icon="mdi:counter", - unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=VOLUME_CUBIC_METERS, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/gas_cost", name="Gas cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/total_cost", name="Total cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/energy_supplier_price_electricity_delivered_1", name="Low tariff delivered price", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/energy_supplier_price_electricity_delivered_2", name="High tariff delivered price", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/energy_supplier_price_electricity_returned_1", name="Low tariff returned price", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/energy_supplier_price_electricity_returned_2", name="High tariff returned price", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/energy_supplier_price_gas", name="Gas price", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/day-consumption/fixed_cost", name="Current day fixed cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/meter-stats/dsmr_version", @@ -415,156 +415,156 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = ( key="dsmr/current-month/electricity1", name="Current month low tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity2", name="Current month high tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity1_returned", name="Current month low tariff returned", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity2_returned", name="Current month high tariff returned", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity_merged", name="Current month power usage total", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity_returned_merged", name="Current month power return total", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity1_cost", name="Current month low tariff cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity2_cost", name="Current month high tariff cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/electricity_cost_merged", name="Current month power total cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/gas", name="Current month gas usage", icon="mdi:counter", - unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=VOLUME_CUBIC_METERS, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/gas_cost", name="Current month gas cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/fixed_cost", name="Current month fixed cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-month/total_cost", name="Current month total cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity1", name="Current year low tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity2", name="Current year high tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity1_returned", name="Current year low tariff returned", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity2_returned", name="Current year high tariff usage", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity_merged", name="Current year power usage total", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity_returned_merged", name="Current year power returned total", device_class=DEVICE_CLASS_ENERGY, - unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity1_cost", name="Current year low tariff cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity2_cost", name="Current year high tariff cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/electricity_cost_merged", name="Current year power total cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/gas", name="Current year gas usage", icon="mdi:counter", - unit_of_measurement=VOLUME_CUBIC_METERS, + native_unit_of_measurement=VOLUME_CUBIC_METERS, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/gas_cost", name="Current year gas cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/fixed_cost", name="Current year fixed cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), DSMRReaderSensorEntityDescription( key="dsmr/current-year/total_cost", name="Current year total cost", icon="mdi:currency-eur", - unit_of_measurement=CURRENCY_EURO, + native_unit_of_measurement=CURRENCY_EURO, ), ) diff --git a/homeassistant/components/dsmr_reader/sensor.py b/homeassistant/components/dsmr_reader/sensor.py index 39356db46b5..84947ec41f1 100644 --- a/homeassistant/components/dsmr_reader/sensor.py +++ b/homeassistant/components/dsmr_reader/sensor.py @@ -33,9 +33,9 @@ class DSMRSensor(SensorEntity): def message_received(message): """Handle new MQTT messages.""" if self.entity_description.state is not None: - self._attr_state = self.entity_description.state(message.payload) + self._attr_native_value = self.entity_description.state(message.payload) else: - self._attr_state = message.payload + self._attr_native_value = message.payload self.async_write_ha_state() diff --git a/homeassistant/components/dte_energy_bridge/sensor.py b/homeassistant/components/dte_energy_bridge/sensor.py index 4e095955818..5b08e8e142c 100644 --- a/homeassistant/components/dte_energy_bridge/sensor.py +++ b/homeassistant/components/dte_energy_bridge/sensor.py @@ -66,12 +66,12 @@ class DteEnergyBridgeSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement diff --git a/homeassistant/components/dublin_bus_transport/sensor.py b/homeassistant/components/dublin_bus_transport/sensor.py index dbe1d10b553..b7daf661e63 100644 --- a/homeassistant/components/dublin_bus_transport/sensor.py +++ b/homeassistant/components/dublin_bus_transport/sensor.py @@ -82,7 +82,7 @@ class DublinPublicTransportSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -105,7 +105,7 @@ class DublinPublicTransportSensor(SensorEntity): } @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" return TIME_MINUTES diff --git a/homeassistant/components/dwd_weather_warnings/sensor.py b/homeassistant/components/dwd_weather_warnings/sensor.py index 428ed3ab427..2668e573b7c 100644 --- a/homeassistant/components/dwd_weather_warnings/sensor.py +++ b/homeassistant/components/dwd_weather_warnings/sensor.py @@ -112,7 +112,7 @@ class DwdWeatherWarningsSensor(SensorEntity): self._attr_name = f"{name} {description.name}" @property - def state(self): + def native_value(self): """Return the state of the device.""" if self.entity_description.key == CURRENT_WARNING_SENSOR: return self._api.api.current_warning_level diff --git a/homeassistant/components/dweet/sensor.py b/homeassistant/components/dweet/sensor.py index f1243cd5407..3d980b34d00 100644 --- a/homeassistant/components/dweet/sensor.py +++ b/homeassistant/components/dweet/sensor.py @@ -73,12 +73,12 @@ class DweetSensor(SensorEntity): return self._name @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit_of_measurement @property - def state(self): + def native_value(self): """Return the state.""" return self._state diff --git a/homeassistant/components/dyson/sensor.py b/homeassistant/components/dyson/sensor.py index cff4b8f5501..be83a7e4373 100644 --- a/homeassistant/components/dyson/sensor.py +++ b/homeassistant/components/dyson/sensor.py @@ -129,7 +129,7 @@ class DysonSensor(DysonEntity, SensorEntity): return f"{self._device.serial}-{self._sensor_type}" @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._attributes.get(ATTR_UNIT_OF_MEASUREMENT) @@ -152,7 +152,7 @@ class DysonFilterLifeSensor(DysonSensor): super().__init__(device, "filter_life") @property - def state(self): + def native_value(self): """Return filter life in hours.""" return int(self._device.state.filter_life) @@ -165,7 +165,7 @@ class DysonCarbonFilterLifeSensor(DysonSensor): super().__init__(device, "carbon_filter_state") @property - def state(self): + def native_value(self): """Return filter life remaining in percent.""" return int(self._device.state.carbon_filter_state) @@ -178,7 +178,7 @@ class DysonHepaFilterLifeSensor(DysonSensor): super().__init__(device, f"{filter_type}_filter_state") @property - def state(self): + def native_value(self): """Return filter life remaining in percent.""" return int(self._device.state.hepa_filter_state) @@ -191,7 +191,7 @@ class DysonDustSensor(DysonSensor): super().__init__(device, "dust") @property - def state(self): + def native_value(self): """Return Dust value.""" return self._device.environmental_state.dust @@ -204,7 +204,7 @@ class DysonHumiditySensor(DysonSensor): super().__init__(device, "humidity") @property - def state(self): + def native_value(self): """Return Humidity value.""" if self._device.environmental_state.humidity == 0: return STATE_OFF @@ -220,7 +220,7 @@ class DysonTemperatureSensor(DysonSensor): self._unit = unit @property - def state(self): + def native_value(self): """Return Temperature value.""" temperature_kelvin = self._device.environmental_state.temperature if temperature_kelvin == 0: @@ -230,7 +230,7 @@ class DysonTemperatureSensor(DysonSensor): return float(f"{(temperature_kelvin * 9 / 5 - 459.67):.1f}") @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit @@ -243,6 +243,6 @@ class DysonAirQualitySensor(DysonSensor): super().__init__(device, "air_quality") @property - def state(self): + def native_value(self): """Return Air Quality value.""" return int(self._device.environmental_state.volatil_organic_compounds) diff --git a/homeassistant/components/eafm/sensor.py b/homeassistant/components/eafm/sensor.py index b3d726f9cd3..bc2158e4db8 100644 --- a/homeassistant/components/eafm/sensor.py +++ b/homeassistant/components/eafm/sensor.py @@ -149,7 +149,7 @@ class Measurement(CoordinatorEntity, SensorEntity): return True @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return units for the sensor.""" measure = self.coordinator.data["measures"][self.key] if "unit" not in measure: @@ -162,6 +162,6 @@ class Measurement(CoordinatorEntity, SensorEntity): return {ATTR_ATTRIBUTION: self.attribution} @property - def state(self): + def native_value(self): """Return the current sensor value.""" return self.coordinator.data["measures"][self.key]["latestReading"]["value"] diff --git a/homeassistant/components/ebox/sensor.py b/homeassistant/components/ebox/sensor.py index e98dea45929..3c43dd36130 100644 --- a/homeassistant/components/ebox/sensor.py +++ b/homeassistant/components/ebox/sensor.py @@ -45,79 +45,79 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="usage", name="Usage", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, icon="mdi:percent", ), SensorEntityDescription( key="balance", name="Balance", - unit_of_measurement=PRICE, + native_unit_of_measurement=PRICE, icon="mdi:cash-usd", ), SensorEntityDescription( key="limit", name="Data limit", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), SensorEntityDescription( key="days_left", name="Days left", - unit_of_measurement=TIME_DAYS, + native_unit_of_measurement=TIME_DAYS, icon="mdi:calendar-today", ), SensorEntityDescription( key="before_offpeak_download", name="Download before offpeak", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), SensorEntityDescription( key="before_offpeak_upload", name="Upload before offpeak", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:upload", ), SensorEntityDescription( key="before_offpeak_total", name="Total before offpeak", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), SensorEntityDescription( key="offpeak_download", name="Offpeak download", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), SensorEntityDescription( key="offpeak_upload", name="Offpeak Upload", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:upload", ), SensorEntityDescription( key="offpeak_total", name="Offpeak Total", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), SensorEntityDescription( key="download", name="Download", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), SensorEntityDescription( key="upload", name="Upload", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:upload", ), SensorEntityDescription( key="total", name="Total", - unit_of_measurement=DATA_GIGABITS, + native_unit_of_measurement=DATA_GIGABITS, icon="mdi:download", ), ) @@ -179,7 +179,7 @@ class EBoxSensor(SensorEntity): """Get the latest data from EBox and update the state.""" await self.ebox_data.async_update() if self.entity_description.key in self.ebox_data.data: - self._attr_state = round( + self._attr_native_value = round( self.ebox_data.data[self.entity_description.key], 2 ) diff --git a/homeassistant/components/ebusd/sensor.py b/homeassistant/components/ebusd/sensor.py index abd9620130d..dcfd4ec7eef 100644 --- a/homeassistant/components/ebusd/sensor.py +++ b/homeassistant/components/ebusd/sensor.py @@ -56,7 +56,7 @@ class EbusdSensor(SensorEntity): return f"{self._client_name} {self._name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -94,7 +94,7 @@ class EbusdSensor(SensorEntity): return self._icon @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._unit_of_measurement diff --git a/homeassistant/components/ecoal_boiler/sensor.py b/homeassistant/components/ecoal_boiler/sensor.py index 9a2fbdd9b87..d9689631280 100644 --- a/homeassistant/components/ecoal_boiler/sensor.py +++ b/homeassistant/components/ecoal_boiler/sensor.py @@ -33,7 +33,7 @@ class EcoalTempSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -43,7 +43,7 @@ class EcoalTempSensor(SensorEntity): return DEVICE_CLASS_TEMPERATURE @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return TEMP_CELSIUS diff --git a/homeassistant/components/ecobee/sensor.py b/homeassistant/components/ecobee/sensor.py index 97f9fe6eae0..eb72f667b5f 100644 --- a/homeassistant/components/ecobee/sensor.py +++ b/homeassistant/components/ecobee/sensor.py @@ -107,7 +107,7 @@ class EcobeeSensor(SensorEntity): return None @property - def state(self): + def native_value(self): """Return the state of the sensor.""" if self._state in ( ECOBEE_STATE_CALIBRATING, @@ -122,7 +122,7 @@ class EcobeeSensor(SensorEntity): return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement this sensor expresses itself in.""" return self._unit_of_measurement diff --git a/homeassistant/components/econet/sensor.py b/homeassistant/components/econet/sensor.py index 0dfe8df7fb3..bbcf54003e8 100644 --- a/homeassistant/components/econet/sensor.py +++ b/homeassistant/components/econet/sensor.py @@ -82,7 +82,7 @@ class EcoNetSensor(EcoNetEntity, SensorEntity): self._device_name = device_name @property - def state(self): + def native_value(self): """Return sensors state.""" value = getattr(self._econet, SENSOR_NAMES_TO_ATTRIBUTES[self._device_name]) if isinstance(value, float): @@ -90,7 +90,7 @@ class EcoNetSensor(EcoNetEntity, SensorEntity): return value @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" unit_of_measurement = SENSOR_NAMES_TO_UNIT_OF_MEASUREMENT[self._device_name] if self._device_name == POWER_USAGE_TODAY: diff --git a/homeassistant/components/eddystone_temperature/sensor.py b/homeassistant/components/eddystone_temperature/sensor.py index 9adb7665753..1eee0b47272 100644 --- a/homeassistant/components/eddystone_temperature/sensor.py +++ b/homeassistant/components/eddystone_temperature/sensor.py @@ -114,7 +114,7 @@ class EddystoneTemp(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the device.""" return self.temperature @@ -124,7 +124,7 @@ class EddystoneTemp(SensorEntity): return DEVICE_CLASS_TEMPERATURE @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return TEMP_CELSIUS diff --git a/homeassistant/components/edl21/sensor.py b/homeassistant/components/edl21/sensor.py index a00f77efa0b..407f5902198 100644 --- a/homeassistant/components/edl21/sensor.py +++ b/homeassistant/components/edl21/sensor.py @@ -301,7 +301,7 @@ class EDL21Entity(SensorEntity): return self._name @property - def state(self) -> str: + def native_value(self) -> str: """Return the value of the last received telegram.""" return self._telegram.get("value") @@ -315,7 +315,7 @@ class EDL21Entity(SensorEntity): } @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._telegram.get("unit") diff --git a/homeassistant/components/efergy/sensor.py b/homeassistant/components/efergy/sensor.py index 6e2ac1c01c7..391aca7b4af 100644 --- a/homeassistant/components/efergy/sensor.py +++ b/homeassistant/components/efergy/sensor.py @@ -120,12 +120,12 @@ class EfergySensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement diff --git a/homeassistant/components/eight_sleep/sensor.py b/homeassistant/components/eight_sleep/sensor.py index 01413ceaec0..df0d7882491 100644 --- a/homeassistant/components/eight_sleep/sensor.py +++ b/homeassistant/components/eight_sleep/sensor.py @@ -101,12 +101,12 @@ class EightHeatSensor(EightSleepHeatEntity, SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return PERCENTAGE @@ -157,12 +157,12 @@ class EightUserSensor(EightSleepUserEntity, SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" if ( "current_sleep" in self._sensor @@ -316,7 +316,7 @@ class EightRoomSensor(EightSleepUserEntity, SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -333,7 +333,7 @@ class EightRoomSensor(EightSleepUserEntity, SensorEntity): self._state = None @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" if self._units == "si": return TEMP_CELSIUS diff --git a/homeassistant/components/eliqonline/sensor.py b/homeassistant/components/eliqonline/sensor.py index 253913b3779..ecd6e4ad4bb 100644 --- a/homeassistant/components/eliqonline/sensor.py +++ b/homeassistant/components/eliqonline/sensor.py @@ -78,12 +78,12 @@ class EliqSensor(SensorEntity): return ICON @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return UNIT_OF_MEASUREMENT @property - def state(self): + def native_value(self): """Return the state of the device.""" return self._state diff --git a/homeassistant/components/elkm1/sensor.py b/homeassistant/components/elkm1/sensor.py index 8f26af545b7..30fe87103c7 100644 --- a/homeassistant/components/elkm1/sensor.py +++ b/homeassistant/components/elkm1/sensor.py @@ -77,7 +77,7 @@ class ElkSensor(ElkAttachedEntity, SensorEntity): self._state = None @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -127,7 +127,7 @@ class ElkKeypad(ElkSensor): return self._temperature_unit @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._temperature_unit @@ -250,7 +250,7 @@ class ElkZone(ElkSensor): return None @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" if self._element.definition == ZoneType.TEMPERATURE.value: return self._temperature_unit diff --git a/homeassistant/components/emoncms/sensor.py b/homeassistant/components/emoncms/sensor.py index bfc86db387e..5180275b528 100644 --- a/homeassistant/components/emoncms/sensor.py +++ b/homeassistant/components/emoncms/sensor.py @@ -162,12 +162,12 @@ class EmonCmsSensor(SensorEntity): return self._name @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement @property - def state(self): + def native_value(self): """Return the state of the device.""" return self._state diff --git a/homeassistant/components/emonitor/sensor.py b/homeassistant/components/emonitor/sensor.py index 1dca3f2d89d..1d699b42473 100644 --- a/homeassistant/components/emonitor/sensor.py +++ b/homeassistant/components/emonitor/sensor.py @@ -38,7 +38,7 @@ class EmonitorPowerSensor(CoordinatorEntity, SensorEntity): """Representation of an Emonitor power sensor entity.""" _attr_device_class = DEVICE_CLASS_POWER - _attr_unit_of_measurement = POWER_WATT + _attr_native_unit_of_measurement = POWER_WATT def __init__(self, coordinator: DataUpdateCoordinator, channel_number: int) -> None: """Initialize the channel sensor.""" @@ -73,7 +73,7 @@ class EmonitorPowerSensor(CoordinatorEntity, SensorEntity): return attr_val @property - def state(self) -> StateType: + def native_value(self) -> StateType: """State of the sensor.""" return self._paired_attr("inst_power") diff --git a/homeassistant/components/energy/sensor.py b/homeassistant/components/energy/sensor.py index e974035cbd6..ccf1a0d7b34 100644 --- a/homeassistant/components/energy/sensor.py +++ b/homeassistant/components/energy/sensor.py @@ -164,7 +164,7 @@ class EnergyCostSensor(SensorEntity): def _reset(self, energy_state: State) -> None: """Reset the cost sensor.""" - self._attr_state = 0.0 + self._attr_native_value = 0.0 self._cur_value = 0.0 self._attr_last_reset = dt_util.utcnow() self._last_energy_sensor_state = energy_state @@ -231,7 +231,7 @@ class EnergyCostSensor(SensorEntity): # Update with newly incurred cost old_energy_value = float(self._last_energy_sensor_state.state) self._cur_value += (energy - old_energy_value) * energy_price - self._attr_state = round(self._cur_value, 2) + self._attr_native_value = round(self._cur_value, 2) self._last_energy_sensor_state = energy_state @@ -281,6 +281,6 @@ class EnergyCostSensor(SensorEntity): self._flow = flow @property - def unit_of_measurement(self) -> str | None: + def native_unit_of_measurement(self) -> str | None: """Return the units of measurement.""" return self.hass.config.currency diff --git a/homeassistant/components/enocean/sensor.py b/homeassistant/components/enocean/sensor.py index 1814efb9c87..ef7fe242092 100644 --- a/homeassistant/components/enocean/sensor.py +++ b/homeassistant/components/enocean/sensor.py @@ -130,12 +130,12 @@ class EnOceanSensor(EnOceanEntity, RestoreEntity, SensorEntity): return self._device_class @property - def state(self): + def native_value(self): """Return the state of the device.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._unit_of_measurement diff --git a/homeassistant/components/enphase_envoy/const.py b/homeassistant/components/enphase_envoy/const.py index 9f87a821787..1d0dfba8990 100644 --- a/homeassistant/components/enphase_envoy/const.py +++ b/homeassistant/components/enphase_envoy/const.py @@ -20,27 +20,27 @@ SENSORS = ( SensorEntityDescription( key="production", name="Current Power Production", - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key="daily_production", name="Today's Energy Production", - unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="seven_days_production", name="Last Seven Days Energy Production", - unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="lifetime_production", name="Lifetime Energy Production", - unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, last_reset=dt.utc_from_timestamp(0), @@ -48,27 +48,27 @@ SENSORS = ( SensorEntityDescription( key="consumption", name="Current Power Consumption", - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key="daily_consumption", name="Today's Energy Consumption", - unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="seven_days_consumption", name="Last Seven Days Energy Consumption", - unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, ), SensorEntityDescription( key="lifetime_consumption", name="Lifetime Energy Consumption", - unit_of_measurement=ENERGY_WATT_HOUR, + native_unit_of_measurement=ENERGY_WATT_HOUR, state_class=STATE_CLASS_MEASUREMENT, device_class=DEVICE_CLASS_ENERGY, last_reset=dt.utc_from_timestamp(0), @@ -76,7 +76,7 @@ SENSORS = ( SensorEntityDescription( key="inverters", name="Inverter", - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, state_class=STATE_CLASS_MEASUREMENT, ), ) diff --git a/homeassistant/components/enphase_envoy/sensor.py b/homeassistant/components/enphase_envoy/sensor.py index 3af5cd1ec0c..9bf4073847e 100644 --- a/homeassistant/components/enphase_envoy/sensor.py +++ b/homeassistant/components/enphase_envoy/sensor.py @@ -132,7 +132,7 @@ class Envoy(CoordinatorEntity, SensorEntity): return f"{self._device_serial_number}_{self.entity_description.key}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" if self.entity_description.key != "inverters": value = self.coordinator.data.get(self.entity_description.key) diff --git a/homeassistant/components/entur_public_transport/sensor.py b/homeassistant/components/entur_public_transport/sensor.py index 0852f95bd99..cad8a49884f 100644 --- a/homeassistant/components/entur_public_transport/sensor.py +++ b/homeassistant/components/entur_public_transport/sensor.py @@ -168,7 +168,7 @@ class EnturPublicTransportSensor(SensorEntity): return self._name @property - def state(self) -> str: + def native_value(self) -> str: """Return the state of the sensor.""" return self._state @@ -180,7 +180,7 @@ class EnturPublicTransportSensor(SensorEntity): return self._attributes @property - def unit_of_measurement(self) -> str: + def native_unit_of_measurement(self) -> str: """Return the unit this state is expressed in.""" return TIME_MINUTES diff --git a/homeassistant/components/environment_canada/sensor.py b/homeassistant/components/environment_canada/sensor.py index 2c16eca9ea1..3690703d8d2 100644 --- a/homeassistant/components/environment_canada/sensor.py +++ b/homeassistant/components/environment_canada/sensor.py @@ -91,7 +91,7 @@ class ECSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -101,7 +101,7 @@ class ECSensor(SensorEntity): return self._attr @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the units of measurement.""" return self._unit diff --git a/homeassistant/components/envirophat/sensor.py b/homeassistant/components/envirophat/sensor.py index 9bca552326a..a41b1678faa 100644 --- a/homeassistant/components/envirophat/sensor.py +++ b/homeassistant/components/envirophat/sensor.py @@ -88,7 +88,7 @@ class EnvirophatSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -103,7 +103,7 @@ class EnvirophatSensor(SensorEntity): return SENSOR_TYPES[self.type][2] @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit_of_measurement diff --git a/homeassistant/components/envisalink/sensor.py b/homeassistant/components/envisalink/sensor.py index 6fd7f32c6fe..88aa7fa988c 100644 --- a/homeassistant/components/envisalink/sensor.py +++ b/homeassistant/components/envisalink/sensor.py @@ -61,7 +61,7 @@ class EnvisalinkSensor(EnvisalinkDevice, SensorEntity): return self._icon @property - def state(self): + def native_value(self): """Return the overall state.""" return self._info["status"]["alpha"] diff --git a/homeassistant/components/epsonworkforce/sensor.py b/homeassistant/components/epsonworkforce/sensor.py index 2f483b9fcbf..285f2fc83e7 100644 --- a/homeassistant/components/epsonworkforce/sensor.py +++ b/homeassistant/components/epsonworkforce/sensor.py @@ -20,37 +20,37 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="black", name="Ink level Black", icon="mdi:water", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, ), SensorEntityDescription( key="photoblack", name="Ink level Photoblack", icon="mdi:water", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, ), SensorEntityDescription( key="magenta", name="Ink level Magenta", icon="mdi:water", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, ), SensorEntityDescription( key="cyan", name="Ink level Cyan", icon="mdi:water", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, ), SensorEntityDescription( key="yellow", name="Ink level Yellow", icon="mdi:water", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, ), SensorEntityDescription( key="clean", name="Cleaning level", icon="mdi:water", - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, ), ) MONITORED_CONDITIONS: list[str] = [desc.key for desc in SENSOR_TYPES] @@ -92,7 +92,7 @@ class EpsonPrinterCartridge(SensorEntity): self.entity_description = description @property - def state(self): + def native_value(self): """Return the state of the device.""" return self._api.getSensorValue(self.entity_description.key) diff --git a/homeassistant/components/esphome/sensor.py b/homeassistant/components/esphome/sensor.py index 6a2b51498f0..3e8fbc19a4d 100644 --- a/homeassistant/components/esphome/sensor.py +++ b/homeassistant/components/esphome/sensor.py @@ -161,7 +161,7 @@ class EsphomeSensor( return self._static_info.force_update @esphome_state_property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the entity.""" if math.isnan(self._state.state): return None @@ -172,7 +172,7 @@ class EsphomeSensor( return f"{self._state.state:.{self._static_info.accuracy_decimals}f}" @property - def unit_of_measurement(self) -> str | None: + def native_unit_of_measurement(self) -> str | None: """Return the unit the value is expressed in.""" if not self._static_info.unit_of_measurement: return None @@ -202,7 +202,7 @@ class EsphomeTextSensor(EsphomeEntity[TextSensorInfo, TextSensorState], SensorEn return self._static_info.icon @esphome_state_property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the entity.""" if self._state.missing_state: return None diff --git a/homeassistant/components/essent/sensor.py b/homeassistant/components/essent/sensor.py index f0dc70d7be4..42a4c1c399b 100644 --- a/homeassistant/components/essent/sensor.py +++ b/homeassistant/components/essent/sensor.py @@ -104,12 +104,12 @@ class EssentMeter(SensorEntity): return f"Essent {self._type} ({self._tariff})" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" if self._unit.lower() == "kwh": return ENERGY_KILO_WATT_HOUR diff --git a/homeassistant/components/etherscan/sensor.py b/homeassistant/components/etherscan/sensor.py index 1b10cc39fe1..b1ec3cddb0c 100644 --- a/homeassistant/components/etherscan/sensor.py +++ b/homeassistant/components/etherscan/sensor.py @@ -59,12 +59,12 @@ class EtherscanSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement this sensor expresses itself in.""" return self._unit_of_measurement diff --git a/homeassistant/components/ezviz/sensor.py b/homeassistant/components/ezviz/sensor.py index 4e81ef6a6a7..42283b52d35 100644 --- a/homeassistant/components/ezviz/sensor.py +++ b/homeassistant/components/ezviz/sensor.py @@ -66,7 +66,7 @@ class EzvizSensor(CoordinatorEntity, Entity): return self._name @property - def state(self) -> int | str: + def native_value(self) -> int | str: """Return the state of the sensor.""" return self.coordinator.data[self._idx][self._name]