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
2 changes: 1 addition & 1 deletion homeassistant/components/fail2ban/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def extra_state_attributes(self):
return self.ban_dict

@property
def state(self):
def native_value(self):
"""Return the most recently banned IP Address."""
return self.last_ban

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/fastdotcom/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class SpeedtestSensor(RestoreEntity, SensorEntity):
"""Implementation of a FAst.com sensor."""

_attr_name = "Fast.com Download"
_attr_unit_of_measurement = DATA_RATE_MEGABITS_PER_SECOND
_attr_native_unit_of_measurement = DATA_RATE_MEGABITS_PER_SECOND
_attr_icon = ICON
_attr_should_poll = False
_attr_state = None
_attr_native_value = None

def __init__(self, speedtest_data: dict[str, Any]) -> None:
"""Initialize the sensor."""
Expand All @@ -52,14 +52,14 @@ async def async_added_to_hass(self) -> None:
state = await self.async_get_last_state()
if not state:
return
self._attr_state = state.state
self._attr_native_value = state.state

def update(self) -> None:
"""Get the latest data and update the states."""
data = self._speedtest_data.data # type: ignore[attr-defined]
if data is None:
return
self._attr_state = data["download"]
self._attr_native_value = data["download"]

@callback
def _schedule_immediate_update(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fibaro/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ def __init__(self, fibaro_device):
self._unit = self.fibaro_device.properties.unit

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

@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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fido/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ def name(self):
return f"{self.client_name} {self._number} {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/file/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def name(self):
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

Expand All @@ -72,7 +72,7 @@ def icon(self):
return ICON

@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/filesize/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def name(self):
return self._name

@property
def state(self):
def native_value(self):
"""Return the size of the file in MB."""
decimals = 2
state_mb = round(self._size / 1e6, decimals)
Expand All @@ -84,6 +84,6 @@ def extra_state_attributes(self):
}

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

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/fints/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def update(self) -> None:
"""Get the current balance and currency for the account."""
bank = self._client.client
balance = bank.get_balance(self._account)
self._attr_state = balance.amount.amount
self._attr_unit_of_measurement = balance.amount.currency
self._attr_native_value = balance.amount.amount
self._attr_native_unit_of_measurement = balance.amount.currency
_LOGGER.debug("updated balance of account %s", self.name)


Expand All @@ -198,13 +198,13 @@ def __init__(self, client: FinTsClient, account, name: str) -> None:
self._account = account
self._holdings: list[Any] = []
self._attr_icon = ICON
self._attr_unit_of_measurement = "EUR"
self._attr_native_unit_of_measurement = "EUR"

def update(self) -> None:
"""Get the current holdings for the account."""
bank = self._client.client
self._holdings = bank.get_holdings(self._account)
self._attr_state = sum(h.total_value for h in self._holdings)
self._attr_native_value = sum(h.total_value for h in self._holdings)

@property
def extra_state_attributes(self) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fireservicerota/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def icon(self) -> str:
return "mdi:fire-truck"

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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/firmata/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ async def async_will_remove_from_hass(self) -> None:
await self._api.stop_pin()

@property
def state(self) -> int:
def native_value(self) -> int:
"""Return sensor state."""
return self._api.state
4 changes: 2 additions & 2 deletions homeassistant/components/fitbit/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ def name(self) -> str:
return self._name

@property
def state(self) -> str | None:
def native_value(self) -> str | None:
"""Return the state of the sensor."""
return self._state

@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._unit_of_measurement

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

@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/flick_electric/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def async_setup_entry(
class FlickPricingSensor(SensorEntity):
"""Entity object for Flick Electric sensor."""

_attr_unit_of_measurement = UNIT_NAME
_attr_native_unit_of_measurement = UNIT_NAME

def __init__(self, api: FlickAPI) -> None:
"""Entity object for Flick Electric sensor."""
Expand All @@ -53,7 +53,7 @@ def name(self):
return FRIENDLY_NAME

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

Expand Down
26 changes: 13 additions & 13 deletions homeassistant/components/flo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ class FloDailyUsageSensor(FloEntity, SensorEntity):
"""Monitors the daily water usage."""

_attr_icon = WATER_ICON
_attr_unit_of_measurement = VOLUME_GALLONS
_attr_native_unit_of_measurement = VOLUME_GALLONS

def __init__(self, device):
"""Initialize the daily water usage sensor."""
super().__init__("daily_consumption", NAME_DAILY_USAGE, device)
self._state: float = None

@property
def state(self) -> float | None:
def native_value(self) -> float | None:
"""Return the current daily usage."""
if self._device.consumption_today is None:
return None
Expand All @@ -85,7 +85,7 @@ def __init__(self, device):
self._state: str = None

@property
def state(self) -> str | None:
def native_value(self) -> str | None:
"""Return the current system mode."""
if not self._device.current_system_mode:
return None
Expand All @@ -96,15 +96,15 @@ class FloCurrentFlowRateSensor(FloEntity, SensorEntity):
"""Monitors the current water flow rate."""

_attr_icon = GAUGE_ICON
_attr_unit_of_measurement = "gpm"
_attr_native_unit_of_measurement = "gpm"

def __init__(self, device):
"""Initialize the flow rate sensor."""
super().__init__("current_flow_rate", NAME_FLOW_RATE, device)
self._state: float = None

@property
def state(self) -> float | None:
def native_value(self) -> float | None:
"""Return the current flow rate."""
if self._device.current_flow_rate is None:
return None
Expand All @@ -115,15 +115,15 @@ class FloTemperatureSensor(FloEntity, SensorEntity):
"""Monitors the temperature."""

_attr_device_class = DEVICE_CLASS_TEMPERATURE
_attr_unit_of_measurement = TEMP_FAHRENHEIT
_attr_native_unit_of_measurement = TEMP_FAHRENHEIT

def __init__(self, name, device):
"""Initialize the temperature sensor."""
super().__init__("temperature", name, device)
self._state: float = None

@property
def state(self) -> float | None:
def native_value(self) -> float | None:
"""Return the current temperature."""
if self._device.temperature is None:
return None
Expand All @@ -134,15 +134,15 @@ class FloHumiditySensor(FloEntity, SensorEntity):
"""Monitors the humidity."""

_attr_device_class = DEVICE_CLASS_HUMIDITY
_attr_unit_of_measurement = PERCENTAGE
_attr_native_unit_of_measurement = PERCENTAGE

def __init__(self, device):
"""Initialize the humidity sensor."""
super().__init__("humidity", NAME_HUMIDITY, device)
self._state: float = None

@property
def state(self) -> float | None:
def native_value(self) -> float | None:
"""Return the current humidity."""
if self._device.humidity is None:
return None
Expand All @@ -153,15 +153,15 @@ class FloPressureSensor(FloEntity, SensorEntity):
"""Monitors the water pressure."""

_attr_device_class = DEVICE_CLASS_PRESSURE
_attr_unit_of_measurement = PRESSURE_PSI
_attr_native_unit_of_measurement = PRESSURE_PSI

def __init__(self, device):
"""Initialize the pressure sensor."""
super().__init__("water_pressure", NAME_WATER_PRESSURE, device)
self._state: float = None

@property
def state(self) -> float | None:
def native_value(self) -> float | None:
"""Return the current water pressure."""
if self._device.current_psi is None:
return None
Expand All @@ -172,14 +172,14 @@ class FloBatterySensor(FloEntity, SensorEntity):
"""Monitors the battery level for battery-powered leak detectors."""

_attr_device_class = DEVICE_CLASS_BATTERY
_attr_unit_of_measurement = PERCENTAGE
_attr_native_unit_of_measurement = PERCENTAGE

def __init__(self, device):
"""Initialize the battery sensor."""
super().__init__("battery", NAME_BATTERY, device)
self._state: float = None

@property
def state(self) -> float | None:
def native_value(self) -> float | None:
"""Return the current battery level."""
return self._device.battery_level
4 changes: 2 additions & 2 deletions homeassistant/components/flume/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def name(self):
return self._name

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
sensor_key = self._flume_query_sensor[0]
if sensor_key not in self._flume_device.values:
Expand All @@ -145,7 +145,7 @@ def state(self):
return _format_state_value(self._flume_device.values[sensor_key])

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
# This is in gallons per SCAN_INTERVAL
return self._flume_query_sensor[1]["unit_of_measurement"]
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/flunearyou/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(
f"{entry.data[CONF_LATITUDE]},"
f"{entry.data[CONF_LONGITUDE]}_{sensor_type}"
)
self._attr_unit_of_measurement = unit
self._attr_native_unit_of_measurement = unit
self._entry = entry
self._sensor_type = sensor_type

Expand Down Expand Up @@ -149,7 +149,7 @@ def update_from_latest_data(self) -> None:
ATTR_STATE: self.coordinator.data["name"],
}
)
self._attr_state = self.coordinator.data[self._sensor_type]
self._attr_native_value = self.coordinator.data[self._sensor_type]


class UserSensor(FluNearYouSensor):
Expand Down Expand Up @@ -181,7 +181,7 @@ def update_from_latest_data(self) -> None:
] = self.coordinator.data["state"]["last_week_data"][states_key]

if self._sensor_type == SENSOR_TYPE_USER_TOTAL:
self._attr_state = sum(
self._attr_native_value = sum(
v
for k, v in self.coordinator.data["local"].items()
if k
Expand All @@ -194,4 +194,4 @@ def update_from_latest_data(self) -> None:
)
)
else:
self._attr_state = self.coordinator.data["local"][self._sensor_type]
self._attr_native_value = self.coordinator.data["local"][self._sensor_type]
4 changes: 2 additions & 2 deletions homeassistant/components/folder/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def name(self):
return self._name

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
decimals = 2
size_mb = round(self._size / 1e6, decimals)
Expand All @@ -102,6 +102,6 @@ def extra_state_attributes(self):
}

@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
Loading