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/radarr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def name(self):
return "{} {}".format("Radarr", self._name)

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

Expand All @@ -137,7 +137,7 @@ def available(self):
return self._available

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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/rainbird/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def update(self) -> None:
"""Get the latest data and updates the states."""
_LOGGER.debug("Updating sensor: %s", self.name)
if self.entity_description.key == SENSOR_TYPE_RAINSENSOR:
self._attr_state = self._controller.get_rain_sensor_state()
self._attr_native_value = self._controller.get_rain_sensor_state()
elif self.entity_description.key == SENSOR_TYPE_RAINDELAY:
self._attr_state = self._controller.get_rain_delay()
self._attr_native_value = self._controller.get_rain_delay()
4 changes: 2 additions & 2 deletions homeassistant/components/raincloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class RainCloudSensor(RainCloudEntity, SensorEntity):
"""A sensor implementation for raincloud device."""

@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 units of measurement."""
return UNIT_OF_MEASUREMENT_MAP.get(self._sensor_type)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/rainforest_eagle/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ def __init__(self, eagle_data, sensor_type):
self._type = sensor_type
sensor_info = SENSORS[sensor_type]
self._attr_name = sensor_info.name
self._attr_unit_of_measurement = sensor_info.unit_of_measurement
self._attr_native_unit_of_measurement = sensor_info.unit_of_measurement
self._attr_device_class = sensor_info.device_class
self._attr_state_class = sensor_info.state_class
self._attr_last_reset = sensor_info.last_reset

def update(self):
"""Get the energy information from the Rainforest Eagle."""
self.eagle_data.update()
self._attr_state = self.eagle_data.get_state(self._type)
self._attr_native_value = self.eagle_data.get_state(self._type)


class EagleData:
Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/rainmachine/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(
self._attr_entity_registry_enabled_default = enabled_by_default
self._attr_icon = icon
self._attr_name = name
self._attr_unit_of_measurement = unit
self._attr_native_unit_of_measurement = unit


class ProvisionSettingsSensor(RainMachineSensor):
Expand All @@ -144,7 +144,7 @@ class ProvisionSettingsSensor(RainMachineSensor):
def update_from_latest_data(self) -> None:
"""Update the state."""
if self._entity_type == TYPE_FLOW_SENSOR_CLICK_M3:
self._attr_state = self.coordinator.data["system"].get(
self._attr_native_value = self.coordinator.data["system"].get(
"flowSensorClicksPerCubicMeter"
)
elif self._entity_type == TYPE_FLOW_SENSOR_CONSUMED_LITERS:
Expand All @@ -154,15 +154,15 @@ def update_from_latest_data(self) -> None:
)

if clicks and clicks_per_m3:
self._attr_state = (clicks * 1000) / clicks_per_m3
self._attr_native_value = (clicks * 1000) / clicks_per_m3
else:
self._attr_state = None
self._attr_native_value = None
elif self._entity_type == TYPE_FLOW_SENSOR_START_INDEX:
self._attr_state = self.coordinator.data["system"].get(
self._attr_native_value = self.coordinator.data["system"].get(
"flowSensorStartIndex"
)
elif self._entity_type == TYPE_FLOW_SENSOR_WATERING_CLICKS:
self._attr_state = self.coordinator.data["system"].get(
self._attr_native_value = self.coordinator.data["system"].get(
"flowSensorWateringClicks"
)

Expand All @@ -174,4 +174,4 @@ class UniversalRestrictionsSensor(RainMachineSensor):
def update_from_latest_data(self) -> None:
"""Update the state."""
if self._entity_type == TYPE_FREEZE_TEMP:
self._attr_state = self.coordinator.data["freezeProtectTemp"]
self._attr_native_value = self.coordinator.data["freezeProtectTemp"]
4 changes: 2 additions & 2 deletions homeassistant/components/random/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def name(self):
return self._name

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

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

@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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/recollect_waste/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ def update_from_latest_data(self) -> None:
ATTR_NEXT_PICKUP_DATE: as_utc(next_pickup_event.date).isoformat(),
}
)
self._attr_state = as_utc(pickup_event.date).isoformat()
self._attr_native_value = as_utc(pickup_event.date).isoformat()
2 changes: 1 addition & 1 deletion homeassistant/components/reddit/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def name(self):
return f"reddit_{self._subreddit}"

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

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

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return TIME_MINUTES

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/repetier/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ 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 SENSOR_TYPES[self._sensor_type][1]

Expand All @@ -92,7 +92,7 @@ def should_poll(self):
return False

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

Expand Down Expand Up @@ -134,7 +134,7 @@ class RepetierTempSensor(RepetierSensor):
"""Represent a Repetier temp sensor."""

@property
def state(self):
def native_value(self):
"""Return sensor state."""
if self._state is None:
return None
Expand All @@ -156,7 +156,7 @@ class RepetierJobSensor(RepetierSensor):
"""Represent a Repetier job sensor."""

@property
def state(self):
def native_value(self):
"""Return sensor state."""
if self._state is None:
return None
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/rest/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ def __init__(
self._json_attrs_path = json_attrs_path

@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 of the device."""
return self._state

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/rflink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ async def async_added_to_hass(self):
self.handle_event_callback(self._initial_event)

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return measurement unit."""
return self._unit_of_measurement

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

Expand Down
46 changes: 23 additions & 23 deletions homeassistant/components/rfxtrx/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,92 +78,92 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):
key="Barameter",
device_class=DEVICE_CLASS_PRESSURE,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=PRESSURE_HPA,
native_unit_of_measurement=PRESSURE_HPA,
),
RfxtrxSensorEntityDescription(
key="Battery numeric",
device_class=DEVICE_CLASS_BATTERY,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=PERCENTAGE,
native_unit_of_measurement=PERCENTAGE,
convert=_battery_convert,
),
RfxtrxSensorEntityDescription(
key="Current",
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
),
RfxtrxSensorEntityDescription(
key="Current Ch. 1",
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
),
RfxtrxSensorEntityDescription(
key="Current Ch. 2",
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
),
RfxtrxSensorEntityDescription(
key="Current Ch. 3",
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
),
RfxtrxSensorEntityDescription(
key="Energy usage",
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=POWER_WATT,
native_unit_of_measurement=POWER_WATT,
),
RfxtrxSensorEntityDescription(
key="Humidity",
device_class=DEVICE_CLASS_HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=PERCENTAGE,
native_unit_of_measurement=PERCENTAGE,
),
RfxtrxSensorEntityDescription(
key="Rssi numeric",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
convert=_rssi_convert,
),
RfxtrxSensorEntityDescription(
key="Temperature",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=TEMP_CELSIUS,
),
RfxtrxSensorEntityDescription(
key="Temperature2",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=TEMP_CELSIUS,
),
RfxtrxSensorEntityDescription(
key="Total usage",
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_MEASUREMENT,
last_reset=dt.utc_from_timestamp(0),
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
),
RfxtrxSensorEntityDescription(
key="Voltage",
device_class=DEVICE_CLASS_VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
),
RfxtrxSensorEntityDescription(
key="Wind direction",
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=DEGREE,
native_unit_of_measurement=DEGREE,
),
RfxtrxSensorEntityDescription(
key="Rain rate",
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR,
native_unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR,
),
RfxtrxSensorEntityDescription(
key="Sound",
Expand All @@ -175,34 +175,34 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):
key="Count",
state_class=STATE_CLASS_MEASUREMENT,
last_reset=dt.utc_from_timestamp(0),
unit_of_measurement="count",
native_unit_of_measurement="count",
),
RfxtrxSensorEntityDescription(
key="Counter value",
state_class=STATE_CLASS_MEASUREMENT,
last_reset=dt.utc_from_timestamp(0),
unit_of_measurement="count",
native_unit_of_measurement="count",
),
RfxtrxSensorEntityDescription(
key="Chill",
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=TEMP_CELSIUS,
),
RfxtrxSensorEntityDescription(
key="Wind average speed",
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=SPEED_METERS_PER_SECOND,
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
),
RfxtrxSensorEntityDescription(
key="Wind gust",
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=SPEED_METERS_PER_SECOND,
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
),
RfxtrxSensorEntityDescription(
key="Rain total",
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=LENGTH_MILLIMETERS,
native_unit_of_measurement=LENGTH_MILLIMETERS,
),
RfxtrxSensorEntityDescription(
key="Forecast",
Expand All @@ -216,7 +216,7 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):
RfxtrxSensorEntityDescription(
key="UV",
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement=UV_INDEX,
native_unit_of_measurement=UV_INDEX,
),
)

Expand Down Expand Up @@ -313,7 +313,7 @@ async def async_added_to_hass(self):
self._apply_event(get_rfx_object(event))

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
if not self._event:
return None
Expand Down
Loading