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

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
if self._key == "battery":
return self._device.battery_level
Expand All @@ -90,7 +90,7 @@ def state(self):
return None

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Get the unit of measurement."""
if self._key == "balance":
return self._device.balance.get("currency") or "₽"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/starlingbank/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def name(self):
)

@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._starling_account.currency

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

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
return self.mean if not self.is_binary else self.count

@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 if not self.is_binary else None

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/steam_online/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def entity_id(self):
return f"sensor.steam_{self._account}"

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

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/streamlabswater/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def icon(self):
return WATER_ICON

@property
def state(self):
def native_value(self):
"""Return the current daily usage."""
return self._streamlabs_usage_data.get_daily_usage()

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return gallons as the unit measurement for water."""
return VOLUME_GALLONS

Expand All @@ -110,7 +110,7 @@ def name(self):
return f"{self._location_name} {NAME_MONTHLY_USAGE}"

@property
def state(self):
def native_value(self):
"""Return the current monthly usage."""
return self._streamlabs_usage_data.get_monthly_usage()

Expand All @@ -124,6 +124,6 @@ def name(self):
return f"{self._location_name} {NAME_YEARLY_USAGE}"

@property
def state(self):
def native_value(self):
"""Return the current yearly usage."""
return self._streamlabs_usage_data.get_yearly_usage()
4 changes: 2 additions & 2 deletions homeassistant/components/subaru/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def icon(self):
return None

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
self.current_value = self.get_current_value()

Expand Down Expand Up @@ -238,7 +238,7 @@ def state(self):
return self.current_value

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit_of_measurement of the device."""
if self.api_unit in TEMPERATURE_UNITS:
return self.hass.config.units.temperature_unit
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/suez_water/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def name(self):
return COMPONENT_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."""
return VOLUME_LITERS

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

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

Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/surepetcare/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, _id: int, spc: SurePetcareAPI) -> None:

self._attr_device_class = DEVICE_CLASS_BATTERY
self._attr_name = f"{surepy_entity.type.name.capitalize()} {surepy_entity.name.capitalize()} Battery Level"
self._attr_unit_of_measurement = PERCENTAGE
self._attr_native_unit_of_measurement = PERCENTAGE
self._attr_unique_id = (
f"{surepy_entity.household_id}-{surepy_entity.id}-battery"
)
Expand All @@ -75,11 +75,11 @@ def _async_update(self) -> None:
try:
per_battery_voltage = state["battery"] / 4
voltage_diff = per_battery_voltage - SURE_BATT_VOLTAGE_LOW
self._attr_state = min(
self._attr_native_value = min(
int(voltage_diff / SURE_BATT_VOLTAGE_DIFF * 100), 100
)
except (KeyError, TypeError):
self._attr_state = None
self._attr_native_value = None

if state:
voltage_per_battery = float(state["battery"]) / 4
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/swiss_hydrological_data/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ def unique_id(self) -> str:
return f"{self._station}_{self._condition}"

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
if self._state is not None:
return self.hydro_data.data["parameters"][self._condition]["unit"]
return None

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
if isinstance(self._state, (int, float)):
return round(self._state, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def name(self):
return self._name

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
return (
self._opendata.connections[0]["departure"]
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/switcher_kis/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(
# Entity class attributes
self._attr_name = f"{wrapper.name} {description.name}"
self._attr_icon = description.icon
self._attr_unit_of_measurement = description.unit
self._attr_native_unit_of_measurement = description.unit
self._attr_device_class = description.device_class
self._attr_entity_registry_enabled_default = description.default_enabled

Expand All @@ -122,6 +122,6 @@ def __init__(
}

@property
def state(self) -> StateType:
def native_value(self) -> StateType:
"""Return value of sensor."""
return getattr(self.wrapper.data, self.attribute) # type: ignore[no-any-return]
2 changes: 1 addition & 1 deletion homeassistant/components/syncthing/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def unique_id(self):
return f"{self._short_server_id}-{self._folder_id}"

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

Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/syncthru/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def icon(self):
return self._icon

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit of measuremnt."""
return self._unit_of_measurement

Expand All @@ -148,7 +148,7 @@ def __init__(self, coordinator, name):
self._id_suffix = "_main"

@property
def state(self):
def native_value(self):
"""Set state to human readable version of syncthru status."""
return SYNCTHRU_STATE_HUMAN[self.syncthru.device_status()]

Expand Down Expand Up @@ -182,7 +182,7 @@ def extra_state_attributes(self):
return self.syncthru.toner_status().get(self._color, {})

@property
def state(self):
def native_value(self):
"""Show amount of remaining toner."""
return self.syncthru.toner_status().get(self._color, {}).get("remaining")

Expand All @@ -204,7 +204,7 @@ def extra_state_attributes(self):
return self.syncthru.drum_status().get(self._color, {})

@property
def state(self):
def native_value(self):
"""Show amount of remaining drum."""
return self.syncthru.drum_status().get(self._color, {}).get("remaining")

Expand All @@ -225,7 +225,7 @@ def extra_state_attributes(self):
return self.syncthru.input_tray_status().get(self._number, {})

@property
def state(self):
def native_value(self):
"""Display ready unless there is some error, then display error."""
tray_state = (
self.syncthru.input_tray_status().get(self._number, {}).get("newError")
Expand All @@ -251,7 +251,7 @@ def extra_state_attributes(self):
return self.syncthru.output_tray_status().get(self._number, {})

@property
def state(self):
def native_value(self):
"""Display ready unless there is some error, then display error."""
tray_state = (
self.syncthru.output_tray_status().get(self._number, {}).get("status")
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/synology_dsm/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SynoDSMSensor(SynologyDSMBaseEntity):
"""Mixin for sensor specific attributes."""

@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 self.entity_type in TEMP_SENSORS_KEYS:
return self.hass.config.units.temperature_unit
Expand All @@ -101,7 +101,7 @@ class SynoDSMUtilSensor(SynoDSMSensor, SensorEntity):
"""Representation a Synology Utilisation sensor."""

@property
def state(self) -> Any | None:
def native_value(self) -> Any | None:
"""Return the state."""
attr = getattr(self._api.utilisation, self.entity_type)
if callable(attr):
Expand Down Expand Up @@ -133,7 +133,7 @@ class SynoDSMStorageSensor(SynologyDSMDeviceEntity, SynoDSMSensor, SensorEntity)
"""Representation a Synology Storage sensor."""

@property
def state(self) -> Any | None:
def native_value(self) -> Any | None:
"""Return the state."""
attr = getattr(self._api.storage, self.entity_type)(self._device_id)
if attr is None:
Expand Down Expand Up @@ -166,7 +166,7 @@ def __init__(
self._last_boot: str | None = None

@property
def state(self) -> Any | None:
def native_value(self) -> Any | None:
"""Return the state."""
attr = getattr(self._api.information, self.entity_type)
if attr is None:
Expand Down
Loading