diff --git a/homeassistant/components/starline/sensor.py b/homeassistant/components/starline/sensor.py index e7996befad3..92c6acbab0b 100644 --- a/homeassistant/components/starline/sensor.py +++ b/homeassistant/components/starline/sensor.py @@ -69,7 +69,7 @@ class StarlineSensor(StarlineEntity, SensorEntity): 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 @@ -90,7 +90,7 @@ class StarlineSensor(StarlineEntity, SensorEntity): 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 "₽" diff --git a/homeassistant/components/starlingbank/sensor.py b/homeassistant/components/starlingbank/sensor.py index 77f5ab307cb..ae1ac2d4987 100644 --- a/homeassistant/components/starlingbank/sensor.py +++ b/homeassistant/components/starlingbank/sensor.py @@ -79,12 +79,12 @@ class StarlingBalanceSensor(SensorEntity): ) @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 diff --git a/homeassistant/components/startca/sensor.py b/homeassistant/components/startca/sensor.py index 661e00ed494..d4124ec3d7c 100644 --- a/homeassistant/components/startca/sensor.py +++ b/homeassistant/components/startca/sensor.py @@ -93,12 +93,12 @@ class StartcaSensor(SensorEntity): return f"{self.client_name} {self._name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement diff --git a/homeassistant/components/statistics/sensor.py b/homeassistant/components/statistics/sensor.py index de32603c207..ea90346fe7c 100644 --- a/homeassistant/components/statistics/sensor.py +++ b/homeassistant/components/statistics/sensor.py @@ -203,12 +203,12 @@ class StatisticsSensor(SensorEntity): 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 diff --git a/homeassistant/components/steam_online/sensor.py b/homeassistant/components/steam_online/sensor.py index 45ae1a6c70a..18f7c6cc447 100644 --- a/homeassistant/components/steam_online/sensor.py +++ b/homeassistant/components/steam_online/sensor.py @@ -99,7 +99,7 @@ class SteamSensor(SensorEntity): return f"sensor.steam_{self._account}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/streamlabswater/sensor.py b/homeassistant/components/streamlabswater/sensor.py index ba722d0a4f2..3af87b8a3f8 100644 --- a/homeassistant/components/streamlabswater/sensor.py +++ b/homeassistant/components/streamlabswater/sensor.py @@ -87,12 +87,12 @@ class StreamLabsDailyUsage(SensorEntity): 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 @@ -110,7 +110,7 @@ class StreamLabsMonthlyUsage(StreamLabsDailyUsage): 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() @@ -124,6 +124,6 @@ class StreamLabsYearlyUsage(StreamLabsDailyUsage): 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() diff --git a/homeassistant/components/subaru/sensor.py b/homeassistant/components/subaru/sensor.py index ff1d8b715d7..7aeab66b929 100644 --- a/homeassistant/components/subaru/sensor.py +++ b/homeassistant/components/subaru/sensor.py @@ -203,7 +203,7 @@ class SubaruSensor(SubaruEntity, SensorEntity): return None @property - def state(self): + def native_value(self): """Return the state of the sensor.""" self.current_value = self.get_current_value() @@ -238,7 +238,7 @@ class SubaruSensor(SubaruEntity, SensorEntity): 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 diff --git a/homeassistant/components/suez_water/sensor.py b/homeassistant/components/suez_water/sensor.py index 7170e0b8a67..c9c125e8e7e 100644 --- a/homeassistant/components/suez_water/sensor.py +++ b/homeassistant/components/suez_water/sensor.py @@ -62,12 +62,12 @@ class SuezSensor(SensorEntity): 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 diff --git a/homeassistant/components/supervisord/sensor.py b/homeassistant/components/supervisord/sensor.py index f701df2d6c3..5db8680f1c9 100644 --- a/homeassistant/components/supervisord/sensor.py +++ b/homeassistant/components/supervisord/sensor.py @@ -50,7 +50,7 @@ class SupervisorProcessSensor(SensorEntity): return self._info.get("name") @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._info.get("statename") diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index fbc8222f292..922bfa84515 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -60,7 +60,7 @@ class SureBattery(SensorEntity): 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" ) @@ -75,11 +75,11 @@ class SureBattery(SensorEntity): 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 diff --git a/homeassistant/components/swiss_hydrological_data/sensor.py b/homeassistant/components/swiss_hydrological_data/sensor.py index 1d77410f031..3daa7161869 100644 --- a/homeassistant/components/swiss_hydrological_data/sensor.py +++ b/homeassistant/components/swiss_hydrological_data/sensor.py @@ -94,14 +94,14 @@ class SwissHydrologicalDataSensor(SensorEntity): 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) diff --git a/homeassistant/components/swiss_public_transport/sensor.py b/homeassistant/components/swiss_public_transport/sensor.py index a971524c22b..0f0ac28d530 100644 --- a/homeassistant/components/swiss_public_transport/sensor.py +++ b/homeassistant/components/swiss_public_transport/sensor.py @@ -84,7 +84,7 @@ class SwissPublicTransportSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return ( self._opendata.connections[0]["departure"] diff --git a/homeassistant/components/switcher_kis/sensor.py b/homeassistant/components/switcher_kis/sensor.py index 705c6f0a2b6..e070bd52d0d 100644 --- a/homeassistant/components/switcher_kis/sensor.py +++ b/homeassistant/components/switcher_kis/sensor.py @@ -110,7 +110,7 @@ class SwitcherSensorEntity(CoordinatorEntity, SensorEntity): # 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 @@ -122,6 +122,6 @@ class SwitcherSensorEntity(CoordinatorEntity, SensorEntity): } @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] diff --git a/homeassistant/components/syncthing/sensor.py b/homeassistant/components/syncthing/sensor.py index 5e8ea2f88c2..924f8aaf669 100644 --- a/homeassistant/components/syncthing/sensor.py +++ b/homeassistant/components/syncthing/sensor.py @@ -105,7 +105,7 @@ class FolderSensor(SensorEntity): 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"] diff --git a/homeassistant/components/syncthru/sensor.py b/homeassistant/components/syncthru/sensor.py index 2b559e0a15f..cc832f77f0a 100644 --- a/homeassistant/components/syncthru/sensor.py +++ b/homeassistant/components/syncthru/sensor.py @@ -124,7 +124,7 @@ class SyncThruSensor(CoordinatorEntity, SensorEntity): 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 @@ -148,7 +148,7 @@ class SyncThruMainSensor(SyncThruSensor): 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()] @@ -182,7 +182,7 @@ class SyncThruTonerSensor(SyncThruSensor): 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") @@ -204,7 +204,7 @@ class SyncThruDrumSensor(SyncThruSensor): 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") @@ -225,7 +225,7 @@ class SyncThruInputTraySensor(SyncThruSensor): 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") @@ -251,7 +251,7 @@ class SyncThruOutputTraySensor(SyncThruSensor): 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") diff --git a/homeassistant/components/synology_dsm/sensor.py b/homeassistant/components/synology_dsm/sensor.py index 5942ce4a5b1..1ddc79c0afc 100644 --- a/homeassistant/components/synology_dsm/sensor.py +++ b/homeassistant/components/synology_dsm/sensor.py @@ -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 @@ -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): @@ -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: @@ -166,7 +166,7 @@ class SynoDSMInfoSensor(SynoDSMSensor, SensorEntity): 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: diff --git a/homeassistant/components/system_bridge/sensor.py b/homeassistant/components/system_bridge/sensor.py index ed3c569f10f..acfcc54f05c 100644 --- a/homeassistant/components/system_bridge/sensor.py +++ b/homeassistant/components/system_bridge/sensor.py @@ -92,7 +92,7 @@ class SystemBridgeSensor(SystemBridgeDeviceEntity, SensorEntity): return self._device_class @property - def unit_of_measurement(self) -> str | None: + def native_unit_of_measurement(self) -> str | None: """Return the unit this state is expressed in.""" return self._unit_of_measurement @@ -113,7 +113,7 @@ class SystemBridgeBatterySensor(SystemBridgeSensor): ) @property - def state(self) -> float: + def native_value(self) -> float: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return bridge.battery.percent @@ -135,7 +135,7 @@ class SystemBridgeBatteryTimeRemainingSensor(SystemBridgeSensor): ) @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data if bridge.battery.timeRemaining is None: @@ -159,7 +159,7 @@ class SystemBridgeCpuSpeedSensor(SystemBridgeSensor): ) @property - def state(self) -> float: + def native_value(self) -> float: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return bridge.cpu.currentSpeed.avg @@ -181,7 +181,7 @@ class SystemBridgeCpuTemperatureSensor(SystemBridgeSensor): ) @property - def state(self) -> float: + def native_value(self) -> float: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return bridge.cpu.temperature.main @@ -203,7 +203,7 @@ class SystemBridgeCpuVoltageSensor(SystemBridgeSensor): ) @property - def state(self) -> float: + def native_value(self) -> float: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return bridge.cpu.cpu.voltage @@ -229,7 +229,7 @@ class SystemBridgeFilesystemSensor(SystemBridgeSensor): self._fs_key = key @property - def state(self) -> float: + def native_value(self) -> float: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return ( @@ -268,7 +268,7 @@ class SystemBridgeMemoryFreeSensor(SystemBridgeSensor): ) @property - def state(self) -> float | None: + def native_value(self) -> float | None: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return ( @@ -294,7 +294,7 @@ class SystemBridgeMemoryUsedSensor(SystemBridgeSensor): ) @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return ( @@ -320,7 +320,7 @@ class SystemBridgeMemoryUsedPercentageSensor(SystemBridgeSensor): ) @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return ( @@ -346,7 +346,7 @@ class SystemBridgeKernelSensor(SystemBridgeSensor): ) @property - def state(self) -> str: + def native_value(self) -> str: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return bridge.os.kernel @@ -368,7 +368,7 @@ class SystemBridgeOsSensor(SystemBridgeSensor): ) @property - def state(self) -> str: + def native_value(self) -> str: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return f"{bridge.os.distro} {bridge.os.release}" @@ -390,7 +390,7 @@ class SystemBridgeProcessesLoadSensor(SystemBridgeSensor): ) @property - def state(self) -> float | None: + def native_value(self) -> float | None: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return ( @@ -431,7 +431,7 @@ class SystemBridgeBiosVersionSensor(SystemBridgeSensor): ) @property - def state(self) -> str: + def native_value(self) -> str: """Return the state of the sensor.""" bridge: Bridge = self.coordinator.data return bridge.system.bios.version diff --git a/homeassistant/components/systemmonitor/sensor.py b/homeassistant/components/systemmonitor/sensor.py index bc3e922a923..687e9e8e521 100644 --- a/homeassistant/components/systemmonitor/sensor.py +++ b/homeassistant/components/systemmonitor/sensor.py @@ -331,12 +331,12 @@ class SystemMonitorSensor(SensorEntity): return self.sensor_type[SENSOR_TYPE_ICON] # type: ignore[no-any-return] @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the device.""" return self.data.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.sensor_type[SENSOR_TYPE_UOM] # type: ignore[no-any-return] diff --git a/homeassistant/components/tado/sensor.py b/homeassistant/components/tado/sensor.py index e1219b5620b..537e094bfd2 100644 --- a/homeassistant/components/tado/sensor.py +++ b/homeassistant/components/tado/sensor.py @@ -127,7 +127,7 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity): return f"{self._tado.home_name} {self.home_variable}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -137,7 +137,7 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity): return self._state_attributes @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" if self.home_variable in ["temperature", "outdoor temperature"]: return TEMP_CELSIUS @@ -232,7 +232,7 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity): return f"{self.zone_name} {self.zone_variable}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -242,7 +242,7 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity): return self._state_attributes @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" if self.zone_variable == "temperature": return self.hass.config.units.temperature_unit diff --git a/homeassistant/components/tahoma/sensor.py b/homeassistant/components/tahoma/sensor.py index 47e6d300414..35a51b03805 100644 --- a/homeassistant/components/tahoma/sensor.py +++ b/homeassistant/components/tahoma/sensor.py @@ -35,12 +35,12 @@ class TahomaSensor(TahomaDevice, SensorEntity): super().__init__(tahoma_device, controller) @property - def state(self): + def native_value(self): """Return the name 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.""" if self.tahoma_device.type == "io:TemperatureIOSystemSensor": return TEMP_CELSIUS diff --git a/homeassistant/components/tank_utility/sensor.py b/homeassistant/components/tank_utility/sensor.py index 379819cf65e..93794ce0c50 100644 --- a/homeassistant/components/tank_utility/sensor.py +++ b/homeassistant/components/tank_utility/sensor.py @@ -81,7 +81,7 @@ class TankUtilitySensor(SensorEntity): return self._device @property - def state(self): + def native_value(self): """Return the state of the device.""" return self._state @@ -91,7 +91,7 @@ class TankUtilitySensor(SensorEntity): return self._name @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 diff --git a/homeassistant/components/tankerkoenig/sensor.py b/homeassistant/components/tankerkoenig/sensor.py index 5c1898e02a9..166e1da7060 100644 --- a/homeassistant/components/tankerkoenig/sensor.py +++ b/homeassistant/components/tankerkoenig/sensor.py @@ -110,12 +110,12 @@ class FuelPriceSensor(CoordinatorEntity, SensorEntity): return ICON @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return unit of measurement.""" return CURRENCY_EURO @property - def state(self): + def native_value(self): """Return the state of the device.""" # key Fuel_type is not available when the fuel station is closed, use "get" instead of "[]" to avoid exceptions return self.coordinator.data[self._station_id].get(self._fuel_type) diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index b756d656921..29144370ae7 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -258,7 +258,7 @@ class TasmotaSensor(TasmotaAvailability, TasmotaDiscoveryUpdate, SensorEntity): return class_or_icon.get(ICON) @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the entity.""" if self._state_timestamp and self.device_class == DEVICE_CLASS_TIMESTAMP: return self._state_timestamp.isoformat() @@ -270,6 +270,6 @@ class TasmotaSensor(TasmotaAvailability, TasmotaDiscoveryUpdate, SensorEntity): return True @property - def unit_of_measurement(self) -> str | None: + def native_unit_of_measurement(self) -> str | None: """Return the unit this state is expressed in.""" return SENSOR_UNIT_MAP.get(self._tasmota_entity.unit, self._tasmota_entity.unit) diff --git a/homeassistant/components/tautulli/sensor.py b/homeassistant/components/tautulli/sensor.py index c50efb00ed7..67df02cb15d 100644 --- a/homeassistant/components/tautulli/sensor.py +++ b/homeassistant/components/tautulli/sensor.py @@ -114,7 +114,7 @@ class TautulliSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self.sessions.get("stream_count") @@ -124,7 +124,7 @@ class TautulliSensor(SensorEntity): return "mdi:plex" @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" return "Watching" diff --git a/homeassistant/components/tcp/sensor.py b/homeassistant/components/tcp/sensor.py index d282974fd4c..4db511e1f57 100644 --- a/homeassistant/components/tcp/sensor.py +++ b/homeassistant/components/tcp/sensor.py @@ -31,11 +31,11 @@ class TcpSensor(TcpEntity, SensorEntity): """Implementation of a TCP socket based sensor.""" @property - def state(self) -> StateType: + def native_value(self) -> StateType: """Return the state of the device.""" 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.""" return self._config[CONF_UNIT_OF_MEASUREMENT] diff --git a/homeassistant/components/ted5000/sensor.py b/homeassistant/components/ted5000/sensor.py index 6732014c747..a7162ee9c63 100644 --- a/homeassistant/components/ted5000/sensor.py +++ b/homeassistant/components/ted5000/sensor.py @@ -79,12 +79,12 @@ class Ted5000Sensor(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 @property - def state(self): + def native_value(self): """Return the state of the resources.""" with suppress(KeyError): return self._gateway.data[self._mtu][self._unit] diff --git a/homeassistant/components/tellduslive/sensor.py b/homeassistant/components/tellduslive/sensor.py index a86b487afd2..35fc6809523 100644 --- a/homeassistant/components/tellduslive/sensor.py +++ b/homeassistant/components/tellduslive/sensor.py @@ -111,7 +111,7 @@ class TelldusLiveSensor(TelldusLiveEntity, SensorEntity): return "{} {}".format(super().name, self.quantity_name or "").strip() @property - def state(self): + def native_value(self): """Return the state of the sensor.""" if not self.available: return None @@ -129,7 +129,7 @@ class TelldusLiveSensor(TelldusLiveEntity, SensorEntity): return SENSOR_TYPES[self._type][0] if self._type in SENSOR_TYPES else None @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return SENSOR_TYPES[self._type][1] if self._type in SENSOR_TYPES else None diff --git a/homeassistant/components/tellstick/sensor.py b/homeassistant/components/tellstick/sensor.py index 599c19388d6..74548f94d1b 100644 --- a/homeassistant/components/tellstick/sensor.py +++ b/homeassistant/components/tellstick/sensor.py @@ -154,12 +154,12 @@ class TellstickSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._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_of_measurement diff --git a/homeassistant/components/temper/sensor.py b/homeassistant/components/temper/sensor.py index 7d447d3f9ea..ffb5660109c 100644 --- a/homeassistant/components/temper/sensor.py +++ b/homeassistant/components/temper/sensor.py @@ -77,12 +77,12 @@ class TemperSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the entity.""" 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.temp_unit diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index a887890510a..d51b18e294b 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -255,7 +255,7 @@ class SensorTemplate(TemplateEntity, SensorEntity): except template.TemplateError: pass - self._attr_unit_of_measurement = unit_of_measurement + self._attr_native_unit_of_measurement = unit_of_measurement self._template = state_template self._attr_device_class = device_class self._attr_state_class = state_class @@ -264,7 +264,7 @@ class SensorTemplate(TemplateEntity, SensorEntity): async def async_added_to_hass(self): """Register callbacks.""" self.add_template_attribute( - "_attr_state", self._template, None, self._update_state + "_attr_native_value", self._template, None, self._update_state ) if self._friendly_name_template and not self._friendly_name_template.is_static: self.add_template_attribute("_attr_name", self._friendly_name_template) @@ -274,7 +274,7 @@ class SensorTemplate(TemplateEntity, SensorEntity): @callback def _update_state(self, result): super()._update_state(result) - self._attr_state = None if isinstance(result, TemplateError) else result + self._attr_native_value = None if isinstance(result, TemplateError) else result class TriggerSensorEntity(TriggerEntity, SensorEntity): @@ -284,7 +284,7 @@ class TriggerSensorEntity(TriggerEntity, SensorEntity): extra_template_keys = (CONF_STATE,) @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return state of the sensor.""" return self._rendered.get(CONF_STATE) diff --git a/homeassistant/components/tesla/sensor.py b/homeassistant/components/tesla/sensor.py index ad585082b48..60e3e19047d 100644 --- a/homeassistant/components/tesla/sensor.py +++ b/homeassistant/components/tesla/sensor.py @@ -38,7 +38,7 @@ class TeslaSensor(TeslaDevice, SensorEntity): self._unique_id = f"{super().unique_id}_{self.type}" @property - def state(self) -> float | None: + def native_value(self) -> float | None: """Return the state of the sensor.""" if self.tesla_device.type == "temperature sensor": if self.type == "outside": @@ -57,7 +57,7 @@ class TeslaSensor(TeslaDevice, SensorEntity): return self.tesla_device.get_value() @property - def unit_of_measurement(self) -> str | None: + def native_unit_of_measurement(self) -> str | None: """Return the unit_of_measurement of the device.""" units = self.tesla_device.measurement if units == "F": diff --git a/homeassistant/components/thermoworks_smoke/sensor.py b/homeassistant/components/thermoworks_smoke/sensor.py index 4b14c9a9305..2e4ef6e56ec 100644 --- a/homeassistant/components/thermoworks_smoke/sensor.py +++ b/homeassistant/components/thermoworks_smoke/sensor.py @@ -120,7 +120,7 @@ class ThermoworksSmokeSensor(SensorEntity): return self._unique_id @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -130,7 +130,7 @@ class ThermoworksSmokeSensor(SensorEntity): return self._attributes @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this sensor.""" return self._unit_of_measurement diff --git a/homeassistant/components/thethingsnetwork/sensor.py b/homeassistant/components/thethingsnetwork/sensor.py index 2e139eae63d..089d1eda2ee 100644 --- a/homeassistant/components/thethingsnetwork/sensor.py +++ b/homeassistant/components/thethingsnetwork/sensor.py @@ -76,7 +76,7 @@ class TtnDataSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the entity.""" if self._ttn_data_storage.data is not None: try: @@ -86,7 +86,7 @@ class TtnDataSensor(SensorEntity): return None @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" return self._unit_of_measurement diff --git a/homeassistant/components/thinkingcleaner/sensor.py b/homeassistant/components/thinkingcleaner/sensor.py index fa1dfd5988c..e7530636169 100644 --- a/homeassistant/components/thinkingcleaner/sensor.py +++ b/homeassistant/components/thinkingcleaner/sensor.py @@ -95,12 +95,12 @@ class ThinkingCleanerSensor(SensorEntity): return SENSOR_TYPES[self.type][2] @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 of this entity, if any.""" return self._unit_of_measurement diff --git a/homeassistant/components/tibber/sensor.py b/homeassistant/components/tibber/sensor.py index b5012cdc41d..6674f6829f9 100644 --- a/homeassistant/components/tibber/sensor.py +++ b/homeassistant/components/tibber/sensor.py @@ -71,39 +71,39 @@ RT_SENSOR_MAP: dict[str, TibberSensorEntityDescription] = { key="averagePower", name="average power", device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, ), "power": TibberSensorEntityDescription( key="power", name="power", device_class=DEVICE_CLASS_POWER, state_class=STATE_CLASS_MEASUREMENT, - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, ), "powerProduction": TibberSensorEntityDescription( key="powerProduction", name="power production", device_class=DEVICE_CLASS_POWER, state_class=STATE_CLASS_MEASUREMENT, - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, ), "minPower": TibberSensorEntityDescription( key="minPower", name="min power", device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, ), "maxPower": TibberSensorEntityDescription( key="maxPower", name="max power", device_class=DEVICE_CLASS_POWER, - unit_of_measurement=POWER_WATT, + native_unit_of_measurement=POWER_WATT, ), "accumulatedConsumption": TibberSensorEntityDescription( key="accumulatedConsumption", name="accumulated consumption", 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, reset_type=ResetType.DAILY, ), @@ -111,7 +111,7 @@ RT_SENSOR_MAP: dict[str, TibberSensorEntityDescription] = { key="accumulatedConsumptionLastHour", name="accumulated consumption current hour", 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, reset_type=ResetType.HOURLY, ), @@ -119,7 +119,7 @@ RT_SENSOR_MAP: dict[str, TibberSensorEntityDescription] = { key="accumulatedProduction", name="accumulated production", 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, reset_type=ResetType.DAILY, ), @@ -127,7 +127,7 @@ RT_SENSOR_MAP: dict[str, TibberSensorEntityDescription] = { key="accumulatedProductionLastHour", name="accumulated production current hour", 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, reset_type=ResetType.HOURLY, ), @@ -135,63 +135,63 @@ RT_SENSOR_MAP: dict[str, TibberSensorEntityDescription] = { key="lastMeterConsumption", name="last meter consumption", 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, ), "lastMeterProduction": TibberSensorEntityDescription( key="lastMeterProduction", name="last meter production", 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, ), "voltagePhase1": TibberSensorEntityDescription( key="voltagePhase1", name="voltage phase1", device_class=DEVICE_CLASS_VOLTAGE, - unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, state_class=STATE_CLASS_MEASUREMENT, ), "voltagePhase2": TibberSensorEntityDescription( key="voltagePhase2", name="voltage phase2", device_class=DEVICE_CLASS_VOLTAGE, - unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, state_class=STATE_CLASS_MEASUREMENT, ), "voltagePhase3": TibberSensorEntityDescription( key="voltagePhase3", name="voltage phase3", device_class=DEVICE_CLASS_VOLTAGE, - unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, state_class=STATE_CLASS_MEASUREMENT, ), "currentL1": TibberSensorEntityDescription( key="currentL1", name="current L1", device_class=DEVICE_CLASS_CURRENT, - unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, state_class=STATE_CLASS_MEASUREMENT, ), "currentL2": TibberSensorEntityDescription( key="currentL2", name="current L2", device_class=DEVICE_CLASS_CURRENT, - unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, state_class=STATE_CLASS_MEASUREMENT, ), "currentL3": TibberSensorEntityDescription( key="currentL3", name="current L3", device_class=DEVICE_CLASS_CURRENT, - unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, state_class=STATE_CLASS_MEASUREMENT, ), "signalStrength": TibberSensorEntityDescription( key="signalStrength", name="signal strength", device_class=DEVICE_CLASS_SIGNAL_STRENGTH, - unit_of_measurement=SIGNAL_STRENGTH_DECIBELS, + native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS, state_class=STATE_CLASS_MEASUREMENT, ), "accumulatedReward": TibberSensorEntityDescription( @@ -212,7 +212,7 @@ RT_SENSOR_MAP: dict[str, TibberSensorEntityDescription] = { key="powerFactor", name="power factor", device_class=DEVICE_CLASS_POWER_FACTOR, - unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=PERCENTAGE, state_class=STATE_CLASS_MEASUREMENT, ), } @@ -350,13 +350,13 @@ class TibberSensorElPrice(TibberSensor): return res = self._tibber_home.current_price_data() - self._attr_state, price_level, self._last_updated = res + self._attr_native_value, price_level, self._last_updated = res self._attr_extra_state_attributes["price_level"] = price_level attrs = self._tibber_home.current_attributes() self._attr_extra_state_attributes.update(attrs) - self._attr_available = self._attr_state is not None - self._attr_unit_of_measurement = self._tibber_home.price_unit + self._attr_available = self._attr_native_value is not None + self._attr_native_unit_of_measurement = self._tibber_home.price_unit @Throttle(MIN_TIME_BETWEEN_UPDATES) async def _fetch_data(self): @@ -394,11 +394,11 @@ class TibberSensorRT(TibberSensor): self._device_name = f"{self._model} {self._home_name}" self._attr_name = f"{description.name} {self._home_name}" - self._attr_state = initial_state + self._attr_native_value = initial_state self._attr_unique_id = f"{self._tibber_home.home_id}_rt_{description.name}" if description.name in ("accumulated cost", "accumulated reward"): - self._attr_unit_of_measurement = tibber_home.currency + self._attr_native_unit_of_measurement = tibber_home.currency if description.reset_type == ResetType.NEVER: self._attr_last_reset = dt_util.utc_from_timestamp(0) elif description.reset_type == ResetType.DAILY: @@ -431,20 +431,20 @@ class TibberSensorRT(TibberSensor): def _set_state(self, state, timestamp): """Set sensor state.""" if ( - state < self._attr_state + state < self._attr_native_value and self.entity_description.reset_type == ResetType.DAILY ): self._attr_last_reset = dt_util.as_utc( timestamp.replace(hour=0, minute=0, second=0, microsecond=0) ) if ( - state < self._attr_state + state < self._attr_native_value and self.entity_description.reset_type == ResetType.HOURLY ): self._attr_last_reset = dt_util.as_utc( timestamp.replace(minute=0, second=0, microsecond=0) ) - self._attr_state = state + self._attr_native_value = state self.async_write_ha_state() diff --git a/homeassistant/components/time_date/sensor.py b/homeassistant/components/time_date/sensor.py index 08195e6dd3d..58582b3b139 100644 --- a/homeassistant/components/time_date/sensor.py +++ b/homeassistant/components/time_date/sensor.py @@ -65,7 +65,7 @@ class TimeDateSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/tmb/sensor.py b/homeassistant/components/tmb/sensor.py index 88471a86c27..d777fec38b6 100644 --- a/homeassistant/components/tmb/sensor.py +++ b/homeassistant/components/tmb/sensor.py @@ -85,7 +85,7 @@ class TMBSensor(SensorEntity): return ICON @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._unit @@ -95,7 +95,7 @@ class TMBSensor(SensorEntity): return f"{self._stop}_{self._line}" @property - def state(self): + def native_value(self): """Return the next departure time.""" return self._state diff --git a/homeassistant/components/tof/sensor.py b/homeassistant/components/tof/sensor.py index 45713dd8f77..631018f55cd 100644 --- a/homeassistant/components/tof/sensor.py +++ b/homeassistant/components/tof/sensor.py @@ -82,12 +82,12 @@ class VL53L1XSensor(SensorEntity): return self._name @property - def state(self) -> int: + def native_value(self) -> int: """Return the state of the sensor.""" return self._state @property - def unit_of_measurement(self) -> str: + def native_unit_of_measurement(self) -> str: """Return the unit of measurement.""" return self._unit_of_measurement diff --git a/homeassistant/components/toon/sensor.py b/homeassistant/components/toon/sensor.py index b16672674af..8d298c4a865 100644 --- a/homeassistant/components/toon/sensor.py +++ b/homeassistant/components/toon/sensor.py @@ -130,7 +130,7 @@ class ToonSensor(ToonEntity, SensorEntity): self._attr_last_reset = sensor.get(ATTR_LAST_RESET) self._attr_name = sensor[ATTR_NAME] self._attr_state_class = sensor.get(ATTR_STATE_CLASS) - self._attr_unit_of_measurement = sensor[ATTR_UNIT_OF_MEASUREMENT] + self._attr_native_unit_of_measurement = sensor[ATTR_UNIT_OF_MEASUREMENT] self._attr_device_class = sensor.get(ATTR_DEVICE_CLASS) self._attr_unique_id = ( # This unique ID is a bit ugly and contains unneeded information. @@ -139,7 +139,7 @@ class ToonSensor(ToonEntity, SensorEntity): ) @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the sensor.""" section = getattr( self.coordinator.data, SENSOR_ENTITIES[self.key][ATTR_SECTION] diff --git a/homeassistant/components/torque/sensor.py b/homeassistant/components/torque/sensor.py index 8e3053d9bd8..162dd5f437c 100644 --- a/homeassistant/components/torque/sensor.py +++ b/homeassistant/components/torque/sensor.py @@ -120,12 +120,12 @@ class TorqueSensor(SensorEntity): return self._name @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement.""" return self._unit @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/tradfri/sensor.py b/homeassistant/components/tradfri/sensor.py index 1f028849d32..f7f68b666ba 100644 --- a/homeassistant/components/tradfri/sensor.py +++ b/homeassistant/components/tradfri/sensor.py @@ -30,7 +30,7 @@ class TradfriSensor(TradfriBaseDevice, SensorEntity): """The platform class required by Home Assistant.""" _attr_device_class = DEVICE_CLASS_BATTERY - _attr_unit_of_measurement = PERCENTAGE + _attr_native_unit_of_measurement = PERCENTAGE def __init__(self, device, api, gateway_id): """Initialize the device.""" @@ -38,6 +38,6 @@ class TradfriSensor(TradfriBaseDevice, SensorEntity): self._unique_id = f"{gateway_id}-{device.id}" @property - def state(self): + def native_value(self): """Return the current state of the device.""" return self._device.device_info.battery_level diff --git a/homeassistant/components/trafikverket_train/sensor.py b/homeassistant/components/trafikverket_train/sensor.py index 5e541045266..cd5cdf29521 100644 --- a/homeassistant/components/trafikverket_train/sensor.py +++ b/homeassistant/components/trafikverket_train/sensor.py @@ -189,7 +189,7 @@ class TrainSensor(SensorEntity): return ICON @property - def state(self): + def native_value(self): """Return the departure state.""" state = self._state if state is not None: diff --git a/homeassistant/components/trafikverket_weatherstation/sensor.py b/homeassistant/components/trafikverket_weatherstation/sensor.py index 1ae090ea231..1435da6a988 100644 --- a/homeassistant/components/trafikverket_weatherstation/sensor.py +++ b/homeassistant/components/trafikverket_weatherstation/sensor.py @@ -185,12 +185,12 @@ class TrafikverketWeatherStation(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 of this entity, if any.""" return self._unit diff --git a/homeassistant/components/transmission/sensor.py b/homeassistant/components/transmission/sensor.py index b00ccfc68c0..e5f827d1e52 100644 --- a/homeassistant/components/transmission/sensor.py +++ b/homeassistant/components/transmission/sensor.py @@ -62,7 +62,7 @@ class TransmissionSensor(SensorEntity): return f"{self._tm_client.api.host}-{self.name}" @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -95,7 +95,7 @@ class TransmissionSpeedSensor(TransmissionSensor): """Representation of a Transmission speed sensor.""" @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return DATA_RATE_MEGABYTES_PER_SECOND @@ -145,7 +145,7 @@ class TransmissionTorrentsSensor(TransmissionSensor): } @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return "Torrents" diff --git a/homeassistant/components/transport_nsw/sensor.py b/homeassistant/components/transport_nsw/sensor.py index be76999ec3f..0ebb2b39cb8 100644 --- a/homeassistant/components/transport_nsw/sensor.py +++ b/homeassistant/components/transport_nsw/sensor.py @@ -81,7 +81,7 @@ class TransportNSWSensor(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 TransportNSWSensor(SensorEntity): } @property - def unit_of_measurement(self): + def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" return TIME_MINUTES diff --git a/homeassistant/components/travisci/sensor.py b/homeassistant/components/travisci/sensor.py index 82b158aa0ec..c4c68197677 100644 --- a/homeassistant/components/travisci/sensor.py +++ b/homeassistant/components/travisci/sensor.py @@ -113,12 +113,12 @@ class TravisCISensor(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 SENSOR_TYPES[self._sensor_type][1] @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/twentemilieu/sensor.py b/homeassistant/components/twentemilieu/sensor.py index cc17bf6f1a2..0069c3db93c 100644 --- a/homeassistant/components/twentemilieu/sensor.py +++ b/homeassistant/components/twentemilieu/sensor.py @@ -132,7 +132,7 @@ class TwenteMilieuSensor(SensorEntity): self.async_schedule_update_ha_state(True) @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/twitch/sensor.py b/homeassistant/components/twitch/sensor.py index cfabcf1045f..15581e11c28 100644 --- a/homeassistant/components/twitch/sensor.py +++ b/homeassistant/components/twitch/sensor.py @@ -77,7 +77,7 @@ class TwitchSensor(SensorEntity): return self._channel.display_name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/uk_transport/sensor.py b/homeassistant/components/uk_transport/sensor.py index c66db9bb24b..69e4f0df99b 100644 --- a/homeassistant/components/uk_transport/sensor.py +++ b/homeassistant/components/uk_transport/sensor.py @@ -93,7 +93,7 @@ class UkTransportSensor(SensorEntity): TRANSPORT_API_URL_BASE = "https://transportapi.com/v3/uk/" _attr_icon = "mdi:train" - _attr_unit_of_measurement = TIME_MINUTES + _attr_native_unit_of_measurement = TIME_MINUTES def __init__(self, name, api_app_id, api_app_key, url): """Initialize the sensor.""" @@ -110,7 +110,7 @@ class UkTransportSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state diff --git a/homeassistant/components/unifi/sensor.py b/homeassistant/components/unifi/sensor.py index 338f695a2b4..6a009415163 100644 --- a/homeassistant/components/unifi/sensor.py +++ b/homeassistant/components/unifi/sensor.py @@ -86,7 +86,7 @@ class UniFiBandwidthSensor(UniFiClient, SensorEntity): DOMAIN = DOMAIN - _attr_unit_of_measurement = DATA_MEGABYTES + _attr_native_unit_of_measurement = DATA_MEGABYTES @property def name(self) -> str: @@ -105,7 +105,7 @@ class UniFiRxBandwidthSensor(UniFiBandwidthSensor): TYPE = RX_SENSOR @property - def state(self) -> int: + def native_value(self) -> int: """Return the state of the sensor.""" if self._is_wired: return self.client.wired_rx_bytes / 1000000 @@ -118,7 +118,7 @@ class UniFiTxBandwidthSensor(UniFiBandwidthSensor): TYPE = TX_SENSOR @property - def state(self) -> int: + def native_value(self) -> int: """Return the state of the sensor.""" if self._is_wired: return self.client.wired_tx_bytes / 1000000 @@ -167,7 +167,7 @@ class UniFiUpTimeSensor(UniFiClient, SensorEntity): return f"{super().name} {self.TYPE.capitalize()}" @property - def state(self) -> datetime: + def native_value(self) -> datetime: """Return the uptime of the client.""" if self.client.uptime < 1000000000: return (dt_util.now() - timedelta(seconds=self.client.uptime)).isoformat() diff --git a/homeassistant/components/upnp/sensor.py b/homeassistant/components/upnp/sensor.py index 54744490a86..82df1f59469 100644 --- a/homeassistant/components/upnp/sensor.py +++ b/homeassistant/components/upnp/sensor.py @@ -161,7 +161,7 @@ class UpnpSensor(CoordinatorEntity, SensorEntity): return f"{self._device.udn}_{self._sensor_type['unique_id']}" @property - def unit_of_measurement(self) -> str: + def native_unit_of_measurement(self) -> str: """Return the unit of measurement of this entity, if any.""" return self._sensor_type["unit"] @@ -180,7 +180,7 @@ class RawUpnpSensor(UpnpSensor): """Representation of a UPnP/IGD sensor.""" @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the device.""" device_value_key = self._sensor_type["device_value_key"] value = self.coordinator.data[device_value_key] @@ -209,7 +209,7 @@ class DerivedUpnpSensor(UpnpSensor): return f"{self._device.udn}_{self._sensor_type['derived_unique_id']}" @property - def unit_of_measurement(self) -> str: + def native_unit_of_measurement(self) -> str: """Return the unit of measurement of this entity, if any.""" return self._sensor_type["derived_unit"] @@ -218,7 +218,7 @@ class DerivedUpnpSensor(UpnpSensor): return current_value < self._last_value @property - def state(self) -> str | None: + def native_value(self) -> str | None: """Return the state of the device.""" # Can't calculate any derivative if we have only one value. device_value_key = self._sensor_type["device_value_key"] diff --git a/homeassistant/components/uptime/sensor.py b/homeassistant/components/uptime/sensor.py index 5b31b2e81d0..db06b09ea18 100644 --- a/homeassistant/components/uptime/sensor.py +++ b/homeassistant/components/uptime/sensor.py @@ -50,4 +50,4 @@ class UptimeSensor(SensorEntity): self._attr_name: str = name self._attr_device_class: str = DEVICE_CLASS_TIMESTAMP self._attr_should_poll: bool = False - self._attr_state: str = dt_util.now().isoformat() + self._attr_native_value: str = dt_util.now().isoformat() diff --git a/homeassistant/components/uscis/sensor.py b/homeassistant/components/uscis/sensor.py index bd261aba4fb..c0c2d1ae165 100644 --- a/homeassistant/components/uscis/sensor.py +++ b/homeassistant/components/uscis/sensor.py @@ -54,7 +54,7 @@ class UscisSensor(SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state.""" return self._state diff --git a/homeassistant/components/utility_meter/sensor.py b/homeassistant/components/utility_meter/sensor.py index 509c0562f97..1ff201aaceb 100644 --- a/homeassistant/components/utility_meter/sensor.py +++ b/homeassistant/components/utility_meter/sensor.py @@ -321,7 +321,7 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity): return self._name @property - def state(self): + def native_value(self): """Return the state of the sensor.""" return self._state @@ -336,7 +336,7 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity): return STATE_CLASS_MEASUREMENT @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