Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions homeassistant/components/daikin/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def name(self):
return self._name

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
raise NotImplementedError

Expand All @@ -101,7 +101,7 @@ def icon(self):
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]

Expand All @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/danfoss_air/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ def device_class(self):
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

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/darksky/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,12 @@ def name(self):
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

Expand Down Expand Up @@ -730,7 +730,7 @@ def name(self):
return f"{self.client_name} {self._name}"

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
return self._state

Expand Down
14 changes: 8 additions & 6 deletions homeassistant/components/deconz/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def __init__(self, device, gateway):
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)
Expand All @@ -173,7 +175,7 @@ def async_update_callback(self, force_update=False):
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

Expand Down Expand Up @@ -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

Expand All @@ -240,7 +242,7 @@ def async_update_callback(self, force_update=False):
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

Expand All @@ -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

Expand Down Expand Up @@ -284,7 +286,7 @@ def unique_id(self):
return f"{self.serial}-battery"

@property
def state(self):
def native_value(self):
"""Return the state of the battery."""
return self._device.battery

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/delijn/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def name(self):
return self._name

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
return self._state

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/deluge/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def name(self):
return f"{self.client_name} {self._name}"

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
return self._state

Expand All @@ -97,7 +97,7 @@ def available(self):
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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/demo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def __init__(
"""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)},
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/derivative/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ def name(self):
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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/deutsche_bahn/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def icon(self):
return ICON

@property
def state(self):
def native_value(self):
"""Return the departure time of the next train."""
return self._state

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/devolo_home_control/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -106,7 +106,7 @@ def __init__(
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

Expand All @@ -132,7 +132,7 @@ def __init__(
)

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

Expand All @@ -157,7 +157,7 @@ def __init__(

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"
)

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/dexcom/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def icon(self):
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)
Expand Down Expand Up @@ -82,7 +82,7 @@ def icon(self):
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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/dht/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def name(self):
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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/discogs/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def name(self):
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

Expand All @@ -115,7 +115,7 @@ def icon(self):
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"]

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/dnsip/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ async def async_update(self) -> None:
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
4 changes: 2 additions & 2 deletions homeassistant/components/dovado/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def name(self):
return f"{self._data.name} {SENSORS[self._sensor][1]}"

@property
def state(self):
def native_value(self):
"""Return the sensor state."""
return self._state

Expand All @@ -99,7 +99,7 @@ def icon(self):
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]

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/dsmr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def get_dsmr_object_attr(self, attribute: str) -> str | None:
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:
Expand All @@ -258,7 +258,7 @@ def state(self) -> StateType:
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")

Expand Down
Loading