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/iammeter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, coordinator, uid, sensor_name, unit, dev_name):
self.dev_name = dev_name

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

Expand All @@ -106,6 +106,6 @@ def icon(self):
return "mdi:flash"

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit of measurement."""
return self.unit
4 changes: 2 additions & 2 deletions homeassistant/components/iaqualink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def name(self) -> str:
return self.dev.label

@property
def unit_of_measurement(self) -> str | None:
def native_unit_of_measurement(self) -> str | None:
"""Return the measurement unit for the sensor."""
if self.dev.name.endswith("_temp"):
if self.dev.system.temp_unit == "F":
Expand All @@ -40,7 +40,7 @@ def unit_of_measurement(self) -> str | None:
return None

@property
def state(self) -> str | None:
def native_value(self) -> str | None:
"""Return the state of the sensor."""
if self.dev.state == "":
return None
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/icloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class IcloudDeviceBatterySensor(SensorEntity):
"""Representation of a iCloud device battery sensor."""

_attr_device_class = DEVICE_CLASS_BATTERY
_attr_unit_of_measurement = PERCENTAGE
_attr_native_unit_of_measurement = PERCENTAGE

def __init__(self, account: IcloudAccount, device: IcloudDevice) -> None:
"""Initialize the battery sensor."""
Expand All @@ -73,7 +73,7 @@ def name(self) -> str:
return f"{self._device.name} battery state"

@property
def state(self) -> int:
def native_value(self) -> int:
"""Battery state percentage."""
return self._device.battery_level

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/ihc/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def device_class(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 of this entity, if any."""
return self._unit_of_measurement

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

@property
def state(self):
def native_value(self):
"""Return the number of emails found."""
return self._email_count

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

@property
def state(self):
def native_value(self):
"""Return the current email state."""
return self._message

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/incomfort/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, client, heater, name) -> None:
self._unit_of_measurement = None

@property
def state(self) -> str | None:
def native_value(self) -> str | None:
"""Return the state of the sensor."""
return self._heater.status[self._state_attr]

Expand All @@ -69,7 +69,7 @@ def device_class(self) -> str | None:
return self._device_class

@property
def unit_of_measurement(self) -> str | None:
def native_unit_of_measurement(self) -> str | None:
"""Return the unit of measurement of the sensor."""
return self._unit_of_measurement

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

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

@property
def unit_of_measurement(self):
def native_unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement

Expand Down
10 changes: 7 additions & 3 deletions homeassistant/components/ios/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
SensorEntityDescription(
key="level",
name="Battery Level",
unit_of_measurement=PERCENTAGE,
native_unit_of_measurement=PERCENTAGE,
),
SensorEntityDescription(
key="state",
Expand Down Expand Up @@ -114,12 +114,16 @@ def icon(self):
def _update(self, device):
"""Get the latest state of the sensor."""
self._device = device
self._attr_state = self._device[ios.ATTR_BATTERY][self.entity_description.key]
self._attr_native_value = self._device[ios.ATTR_BATTERY][
self.entity_description.key
]
self.async_write_ha_state()

async def async_added_to_hass(self) -> None:
"""Added to hass so need to register to dispatch."""
self._attr_state = self._device[ios.ATTR_BATTERY][self.entity_description.key]
self._attr_native_value = self._device[ios.ATTR_BATTERY][
self.entity_description.key
]
device_id = self._device[ios.ATTR_DEVICE_ID]
self.async_on_remove(
async_dispatcher_connect(self.hass, f"{DOMAIN}.{device_id}", self._update)
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/iota/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def name(self):
return f"{self._name} Balance"

@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 "IOTA"

Expand Down Expand Up @@ -81,7 +81,7 @@ def name(self):
return "IOTA Node"

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

@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

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/ipp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
"""Initialize IPP sensor."""
self._key = key
self._attr_unique_id = f"{unique_id}_{key}"
self._attr_unit_of_measurement = unit_of_measurement
self._attr_native_unit_of_measurement = unit_of_measurement

super().__init__(
entry_id=entry_id,
Expand Down Expand Up @@ -123,7 +123,7 @@ def extra_state_attributes(self) -> dict[str, Any] | None:
}

@property
def state(self) -> int | None:
def native_value(self) -> int | None:
"""Return the state of the sensor."""
level = self.coordinator.data.markers[self.marker_index].level

Expand Down Expand Up @@ -164,7 +164,7 @@ def extra_state_attributes(self) -> dict[str, Any] | None:
}

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

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

@property
def state(self) -> str:
def native_value(self) -> str:
"""Return the state of the sensor."""
uptime = utcnow() - timedelta(seconds=self.coordinator.data.info.uptime)
return uptime.replace(microsecond=0).isoformat()
2 changes: 1 addition & 1 deletion homeassistant/components/iqvia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self, coordinator, entry, sensor_type, name, icon):
self._attr_icon = icon
self._attr_name = name
self._attr_unique_id = f"{entry.data[CONF_ZIP_CODE]}_{sensor_type}"
self._attr_unit_of_measurement = "index"
self._attr_native_unit_of_measurement = "index"
self._entry = entry
self._type = sensor_type

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/iqvia/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def update_from_latest_data(self):
if i["minimum"] <= average <= i["maximum"]
]

self._attr_state = average
self._attr_native_value = average
self._attr_extra_state_attributes.update(
{
ATTR_CITY: data["City"].title(),
Expand Down Expand Up @@ -213,4 +213,4 @@ def update_from_latest_data(self):
f"{attrs['Name'].lower()}_index"
] = attrs["Index"]

self._attr_state = period["Index"]
self._attr_native_value = period["Index"]
4 changes: 2 additions & 2 deletions homeassistant/components/irish_rail_transport/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def name(self):
return self._name

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

Expand Down Expand Up @@ -114,7 +114,7 @@ def extra_state_attributes(self):
}

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

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
return (
self.client.prayer_times_info.get(self.sensor_type)
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/isy994/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def raw_unit_of_measurement(self) -> dict | str:
return UOM_FRIENDLY_NAME.get(uom)

@property
def state(self) -> str:
def native_value(self) -> str:
"""Get the state of the ISY994 sensor device."""
value = self._node.status
if value == ISY_VALUE_UNKNOWN:
Expand Down Expand Up @@ -97,7 +97,7 @@ def state(self) -> str:
return value

@property
def unit_of_measurement(self) -> str:
def native_unit_of_measurement(self) -> str:
"""Get the Home Assistant unit of measurement for the device."""
raw_units = self.raw_unit_of_measurement
# Check if this is a known index pair UOM
Expand All @@ -117,7 +117,7 @@ def __init__(self, vname: str, vobj: object) -> None:
self._name = vname

@property
def state(self):
def native_value(self):
"""Return the state of the variable."""
return convert_isy_value_to_hass(self._node.status, "", self._node.prec)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/jewish_calendar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, data, sensor, sensor_info):
self._holiday_attrs = {}

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
if isinstance(self._state, datetime):
return self._state.isoformat()
Expand Down Expand Up @@ -134,7 +134,7 @@ class JewishCalendarTimeSensor(JewishCalendarSensor):
_attr_device_class = DEVICE_CLASS_TIMESTAMP

@property
def state(self):
def native_value(self):
"""Return the state of the sensor."""
if self._state is None:
return None
Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/juicenet/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,40 @@
SensorEntityDescription(
key="temperature",
name="Temperature",
unit_of_measurement=TEMP_CELSIUS,
native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="voltage",
name="Voltage",
unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE,
),
SensorEntityDescription(
key="amps",
name="Amps",
unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="watts",
name="Watts",
unit_of_measurement=POWER_WATT,
native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="charge_time",
name="Charge time",
unit_of_measurement=TIME_SECONDS,
native_unit_of_measurement=TIME_SECONDS,
icon="mdi:timer-outline",
),
SensorEntityDescription(
key="energy_added",
name="Energy added",
unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
),
)
Expand Down Expand Up @@ -110,6 +110,6 @@ def icon(self):
return icon

@property
def state(self):
def native_value(self):
"""Return the state."""
return getattr(self.device, self.entity_description.key, None)
Loading