mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Move temperature conversions to entity base class (2/8) (#54468)
This commit is contained in:
parent
f020d65416
commit
41f3c2766c
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)},
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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,
|
||||
),
|
||||
)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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"]
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
),
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"]
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user