Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1110ca5
Use shorthand attributes in geonetnz_volcano (#163596)
epenet Feb 20, 2026
12591a9
Use shorthand attributes in torque (#163597)
epenet Feb 20, 2026
5d818cd
Use shorthand attributes in transport_nsw (#163598)
epenet Feb 20, 2026
eccaac4
Use shorthand attributes in rmvtransport (#163599)
epenet Feb 20, 2026
63e4eaf
Use shorthand attributes in netdata (#163605)
epenet Feb 20, 2026
cff5a12
Use shorthand attributes in reddit (#163600)
epenet Feb 20, 2026
4937c65
Add type hint for icon property (#163609)
epenet Feb 20, 2026
f80e1dd
Use shorthand attributes in homematic (#163610)
epenet Feb 20, 2026
d6f3079
Use shorthand attributes in london_air (#163601)
epenet Feb 20, 2026
8a38bac
Add integration_type service to streamlabswater (#163642)
joostlek Feb 20, 2026
69db578
Add integration_type device to stiebel_eltron (#163641)
joostlek Feb 20, 2026
6a9fd67
Add integration_type hub to somfy_mylink (#163631)
joostlek Feb 20, 2026
c2ba5d8
Add integration_type hub to subaru (#163643)
joostlek Feb 20, 2026
03f5e6d
Add integration_type device to songpal (#163633)
joostlek Feb 20, 2026
522f63c
Add integration_type hub to sunricher_dali (#163645)
joostlek Feb 20, 2026
2bf5f67
Add integration_type service to suez_water (#163644)
joostlek Feb 20, 2026
9b6e6a6
Add integration_type service to swiss_public_transport (#163647)
joostlek Feb 20, 2026
04621a2
Add integration_type hub to switchbee (#163648)
joostlek Feb 20, 2026
3143d9c
Add integration_type hub to snoo (#163626)
joostlek Feb 20, 2026
8c3e72b
Add integration_type device to snooz (#163627)
joostlek Feb 20, 2026
d291858
Add integration_type device to solax (#163629)
joostlek Feb 20, 2026
8ff06f3
Add integration_type hub to soma (#163630)
joostlek Feb 20, 2026
47eba50
Add integration_type service to sonarr (#163632)
joostlek Feb 20, 2026
bf950e4
Add integration_type service to splunk (#163635)
joostlek Feb 20, 2026
34f1c4c
Add integration_type device to soundtouch (#163634)
joostlek Feb 20, 2026
c15a804
Add integration_type service to srp_energy (#163636)
joostlek Feb 20, 2026
a1f35ed
Add integration_type hub to switcher_kis (#163650)
joostlek Feb 20, 2026
88bc616
Add integration_type device to starlink (#163639)
joostlek Feb 20, 2026
03f81e4
Add integration_type hub to starline (#163638)
joostlek Feb 20, 2026
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/atag/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ def native_value(self):
return self.coordinator.atag.report[self._id].state

@property
def icon(self):
def icon(self) -> str:
"""Return icon."""
return self.coordinator.atag.report[self._id].icon
24 changes: 4 additions & 20 deletions homeassistant/components/geonetnz_volcano/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def async_add_sensor(feed_manager, external_id, unit_system):
class GeonetnzVolcanoSensor(SensorEntity):
"""Represents an external event with GeoNet NZ Volcano feed data."""

_attr_icon = DEFAULT_ICON
_attr_native_unit_of_measurement = "alert level"
_attr_should_poll = False

def __init__(self, config_entry_id, feed_manager, external_id, unit_system):
"""Initialize entity with data from feed entry."""
self._config_entry_id = config_entry_id
self._feed_manager = feed_manager
self._external_id = external_id
self._attr_unique_id = f"{config_entry_id}_{external_id}"
Expand All @@ -71,8 +72,6 @@ def __init__(self, config_entry_id, feed_manager, external_id, unit_system):
self._distance = None
self._latitude = None
self._longitude = None
self._attribution = None
self._alert_level = None
self._activity = None
self._hazards = None
self._feed_last_update = None
Expand Down Expand Up @@ -124,7 +123,7 @@ def _update_from_feed(self, feed_entry, last_update, last_update_successful):
self._latitude = round(feed_entry.coordinates[0], 5)
self._longitude = round(feed_entry.coordinates[1], 5)
self._attr_attribution = feed_entry.attribution
self._alert_level = feed_entry.alert_level
self._attr_native_value = feed_entry.alert_level
self._activity = feed_entry.activity
self._hazards = feed_entry.hazards
self._feed_last_update = dt_util.as_utc(last_update) if last_update else None
Expand All @@ -133,25 +132,10 @@ def _update_from_feed(self, feed_entry, last_update, last_update_successful):
)

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

@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return DEFAULT_ICON

@property
def name(self) -> str | None:
def name(self) -> str:
"""Return the name of the entity."""
return f"Volcano {self._title}"

@property
def native_unit_of_measurement(self):
"""Return the unit of measurement."""
return "alert level"

@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the device state attributes."""
Expand Down
26 changes: 6 additions & 20 deletions homeassistant/components/homematic/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ def __init__(
entity_description: EntityDescription | None = None,
) -> None:
"""Initialize a generic HomeMatic device."""
self._name = config.get(ATTR_NAME)
self._attr_name = config.get(ATTR_NAME)
self._address = config.get(ATTR_ADDRESS)
self._interface = config.get(ATTR_INTERFACE)
self._channel = config.get(ATTR_CHANNEL)
self._state = config.get(ATTR_PARAM)
self._unique_id = config.get(ATTR_UNIQUE_ID)
if unique_id := config.get(ATTR_UNIQUE_ID):
self._attr_unique_id = unique_id.replace(" ", "_")
self._data: dict[str, Any] = {}
self._connected = False
self._available = False
self._attr_available = False
self._channel_map: dict[str, str] = {}

if entity_description is not None:
Expand All @@ -67,21 +68,6 @@ async def async_added_to_hass(self) -> None:
"""Load data init callbacks."""
self._subscribe_homematic_events()

@property
def unique_id(self):
"""Return unique ID. HomeMatic entity IDs are unique by default."""
return self._unique_id.replace(" ", "_")

@property
def name(self):
"""Return the name of the device."""
return self._name

@property
def available(self) -> bool:
"""Return true if device is available."""
return self._available

@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return device specific state attributes."""
Expand Down Expand Up @@ -116,7 +102,7 @@ def update(self) -> None:
self._load_data_from_hm()

# Link events from pyhomematic
self._available = not self._hmdevice.UNREACH
self._attr_available = not self._hmdevice.UNREACH
except Exception as err: # noqa: BLE001
self._connected = False
_LOGGER.error("Exception while linking %s: %s", self._address, str(err))
Expand All @@ -132,7 +118,7 @@ def _hm_event_callback(self, device, caller, attribute, value):

# Availability has changed
if self.available != (not self._hmdevice.UNREACH):
self._available = not self._hmdevice.UNREACH
self._attr_available = not self._hmdevice.UNREACH
has_changed = True

# If it has changed data point, update Home Assistant
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homematic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,4 @@ def _init_data_struct(self) -> None:
if self._state:
self._data.update({self._state: None})
else:
_LOGGER.critical("Unable to initialize sensor: %s", self._name)
_LOGGER.critical("Unable to initialize sensor: %s", self.name)
2 changes: 1 addition & 1 deletion homeassistant/components/input_datetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def has_time(self) -> bool:
return self._config[CONF_HAS_TIME]

@property
def icon(self):
def icon(self) -> str | None:
"""Return the icon to be used for this entity."""
return self._config.get(CONF_ICON)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/input_number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def name(self):
return self._config.get(CONF_NAME)

@property
def icon(self):
def icon(self) -> str | None:
"""Return the icon to be used for this entity."""
return self._config.get(CONF_ICON)

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

@property
def icon(self):
def icon(self) -> str:
"""Return the icon to use in the frontend, if any."""
if self.selected is True:
return "mdi:volume-high"
Expand Down
26 changes: 5 additions & 21 deletions homeassistant/components/london_air/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,36 +107,20 @@ def update(self):
class AirSensor(SensorEntity):
"""Single authority air sensor."""

ICON = "mdi:cloud-outline"
_attr_icon = "mdi:cloud-outline"

def __init__(self, name, api_data):
"""Initialize the sensor."""
self._name = name
self._attr_name = self._key = name
self._api_data = api_data
self._site_data = None
self._state = None
self._updated = None

@property
def name(self):
"""Return the name of the sensor."""
return self._name

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

@property
def site_data(self):
"""Return the dict of sites data."""
return self._site_data

@property
def icon(self):
"""Icon to use in the frontend, if any."""
return self.ICON

@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return other details about the sensor state."""
Expand All @@ -151,7 +135,7 @@ def update(self) -> None:
sites_status: list = []
self._api_data.update()
if self._api_data.data:
self._site_data = self._api_data.data[self._name]
self._site_data = self._api_data.data[self._key]
self._updated = self._site_data[0]["updated"]
sites_status.extend(
site["pollutants_status"]
Expand All @@ -160,9 +144,9 @@ def update(self) -> None:
)

if sites_status:
self._state = max(set(sites_status), key=sites_status.count)
self._attr_native_value = max(set(sites_status), key=sites_status.count)
else:
self._state = None
self._attr_native_value = None


def parse_species(species_data):
Expand Down
63 changes: 16 additions & 47 deletions homeassistant/components/netdata/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,15 @@ class NetdataSensor(SensorEntity):
def __init__(self, netdata, name, sensor, sensor_name, element, icon, unit, invert):
"""Initialize the Netdata sensor."""
self.netdata = netdata
self._state = None
self._sensor = sensor
self._element = element
self._sensor_name = self._sensor if sensor_name is None else sensor_name
self._name = name
self._icon = icon
self._unit_of_measurement = unit
if sensor_name is None:
sensor_name = self._sensor
self._attr_name = f"{name} {sensor_name}"
self._attr_icon = icon
self._attr_native_unit_of_measurement = unit
self._invert = invert

@property
def name(self):
"""Return the name of the sensor."""
return f"{self._name} {self._sensor_name}"

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

@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
return self._icon

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

@property
def available(self) -> bool:
"""Could the resource be accessed during the last update call."""
Expand All @@ -151,9 +131,9 @@ async def async_update(self) -> None:
"""Get the latest data from Netdata REST API."""
await self.netdata.async_update()
resource_data = self.netdata.api.metrics.get(self._sensor)
self._state = round(resource_data["dimensions"][self._element]["value"], 2) * (
-1 if self._invert else 1
)
self._attr_native_value = round(
resource_data["dimensions"][self._element]["value"], 2
) * (-1 if self._invert else 1)


class NetdataAlarms(SensorEntity):
Expand All @@ -162,29 +142,18 @@ class NetdataAlarms(SensorEntity):
def __init__(self, netdata, name, host, port):
"""Initialize the Netdata alarm sensor."""
self.netdata = netdata
self._state = None
self._name = name
self._attr_name = f"{name} Alarms"
self._host = host
self._port = port

@property
def name(self):
"""Return the name of the sensor."""
return f"{self._name} Alarms"

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

@property
def icon(self):
def icon(self) -> str:
"""Status symbol if type is symbol."""
if self._state == "ok":
if self._attr_native_value == "ok":
return "mdi:check"
if self._state == "warning":
if self._attr_native_value == "warning":
return "mdi:alert-outline"
if self._state == "critical":
if self._attr_native_value == "critical":
return "mdi:alert"
return "mdi:crosshairs-question"

Expand All @@ -197,7 +166,7 @@ async def async_update(self) -> None:
"""Get the latest alarms from Netdata REST API."""
await self.netdata.async_update()
alarms = self.netdata.api.alarms["alarms"]
self._state = None
self._attr_native_value = None
number_of_alarms = len(alarms)
number_of_relevant_alarms = number_of_alarms

Expand All @@ -211,9 +180,9 @@ async def async_update(self) -> None:
):
number_of_relevant_alarms = number_of_relevant_alarms - 1
elif alarms[alarm]["status"] == "CRITICAL":
self._state = "critical"
self._attr_native_value = "critical"
return
self._state = "ok" if number_of_relevant_alarms == 0 else "warning"
self._attr_native_value = "ok" if number_of_relevant_alarms == 0 else "warning"


class NetdataData:
Expand Down
21 changes: 6 additions & 15 deletions homeassistant/components/reddit/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,19 @@ def setup_platform(
class RedditSensor(SensorEntity):
"""Representation of a Reddit sensor."""

_attr_icon = "mdi:reddit"

def __init__(self, reddit, subreddit: str, limit: int, sort_by: str) -> None:
"""Initialize the Reddit sensor."""
self._attr_name = f"reddit_{subreddit}"
self._attr_native_value = 0
self._reddit = reddit
self._subreddit = subreddit
self._limit = limit
self._sort_by = sort_by

self._subreddit_data: list = []

@property
def name(self):
"""Return the name of the sensor."""
return f"reddit_{self._subreddit}"

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

@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the state attributes."""
Expand All @@ -127,11 +121,6 @@ def extra_state_attributes(self) -> dict[str, Any]:
CONF_SORT_BY: self._sort_by,
}

@property
def icon(self):
"""Return the icon to use in the frontend."""
return "mdi:reddit"

def update(self) -> None:
"""Update data from Reddit API."""
self._subreddit_data = []
Expand All @@ -156,3 +145,5 @@ def update(self) -> None:

except praw.exceptions.PRAWException as err:
_LOGGER.error("Reddit error %s", err)

self._attr_native_value = len(self._subreddit_data)
Loading
Loading