diff --git a/homeassistant/components/geo_location/__init__.py b/homeassistant/components/geo_location/__init__.py index 743bc3ede71dbc..35a5f5c1a51ad0 100644 --- a/homeassistant/components/geo_location/__init__.py +++ b/homeassistant/components/geo_location/__init__.py @@ -7,7 +7,11 @@ from propcache.api import cached_property from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE # noqa: F401 +from homeassistant.const import ( # noqa: F401 + ATTR_LATITUDE, + ATTR_LONGITUDE, + EntityStateAttribute, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from homeassistant.helpers.entity import Entity @@ -105,7 +109,7 @@ def state_attributes(self) -> dict[str, Any]: """Return the state attributes of this external event.""" data: dict[str, Any] = {GeolocationEntityStateAttribute.SOURCE: self.source} if self.latitude is not None: - data[GeolocationEntityStateAttribute.LATITUDE] = round(self.latitude, 5) + data[EntityStateAttribute.LATITUDE] = round(self.latitude, 5) if self.longitude is not None: - data[GeolocationEntityStateAttribute.LONGITUDE] = round(self.longitude, 5) + data[EntityStateAttribute.LONGITUDE] = round(self.longitude, 5) return data diff --git a/homeassistant/components/geo_location/const.py b/homeassistant/components/geo_location/const.py index 8cd7194e855187..6d1513ccb71436 100644 --- a/homeassistant/components/geo_location/const.py +++ b/homeassistant/components/geo_location/const.py @@ -2,10 +2,19 @@ from enum import StrEnum +from homeassistant.helpers.deprecation import EnumWithDeprecatedMembers -class GeolocationEntityStateAttribute(StrEnum): + +class GeolocationEntityStateAttribute( + StrEnum, + metaclass=EnumWithDeprecatedMembers, + deprecated={ + "LATITUDE": ("EntityStateAttribute.LATITUDE", "2027.2.0"), + "LONGITUDE": ("EntityStateAttribute.LONGITUDE", "2027.2.0"), + }, +): """State attributes for geolocation entities.""" SOURCE = "source" - LATITUDE = "latitude" - LONGITUDE = "longitude" + LATITUDE = "latitude" # Deprecated, replaced with EntityStateAttribute.LATITUDE + LONGITUDE = "longitude" # Deprecated, replaced with EntityStateAttribute.LONGITUDE diff --git a/homeassistant/components/imgw_pib/manifest.json b/homeassistant/components/imgw_pib/manifest.json index 2ff27cbb0259c1..8cc18fbd7dd0bc 100644 --- a/homeassistant/components/imgw_pib/manifest.json +++ b/homeassistant/components/imgw_pib/manifest.json @@ -7,5 +7,5 @@ "integration_type": "service", "iot_class": "cloud_polling", "quality_scale": "platinum", - "requirements": ["imgw_pib==2.4.0"] + "requirements": ["imgw_pib==2.4.3"] } diff --git a/homeassistant/components/owntracks/__init__.py b/homeassistant/components/owntracks/__init__.py index d76d07a8b82eb7..6f3ba4b48511fd 100644 --- a/homeassistant/components/owntracks/__init__.py +++ b/homeassistant/components/owntracks/__init__.py @@ -10,14 +10,9 @@ import voluptuous as vol from homeassistant.components import cloud, mqtt, webhook +from homeassistant.components.device_tracker import TrackerEntityStateAttribute from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_GPS_ACCURACY, - ATTR_LATITUDE, - ATTR_LONGITUDE, - CONF_WEBHOOK_ID, - Platform, -) +from homeassistant.const import CONF_WEBHOOK_ID, EntityStateAttribute, Platform from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.dispatcher import ( @@ -194,13 +189,14 @@ async def handle_webhook( response = [ { "_type": "location", - "lat": person.attributes["latitude"], - "lon": person.attributes["longitude"], + "lat": person.attributes[EntityStateAttribute.LATITUDE], + "lon": person.attributes[EntityStateAttribute.LONGITUDE], "tid": "".join(p[0] for p in person.name.split(" ")[:2]), "tst": int(person.last_updated.timestamp()), } for person in hass.states.async_all("person") - if "latitude" in person.attributes and "longitude" in person.attributes + if EntityStateAttribute.LATITUDE in person.attributes + and EntityStateAttribute.LONGITUDE in person.attributes ] if message["_type"] == "encrypted" and context.secret: @@ -297,9 +293,11 @@ def async_see_beacons(self, hass, dev_id, kwargs_param): device_tracker_state = hass.states.get(f"device_tracker.{dev_id}") if device_tracker_state is not None: - acc = device_tracker_state.attributes.get(ATTR_GPS_ACCURACY) - lat = device_tracker_state.attributes.get(ATTR_LATITUDE) - lon = device_tracker_state.attributes.get(ATTR_LONGITUDE) + acc = device_tracker_state.attributes.get( + TrackerEntityStateAttribute.GPS_ACCURACY + ) + lat = device_tracker_state.attributes.get(EntityStateAttribute.LATITUDE) + lon = device_tracker_state.attributes.get(EntityStateAttribute.LONGITUDE) if lat is not None and lon is not None: kwargs["gps"] = (lat, lon) diff --git a/homeassistant/components/owntracks/device_tracker.py b/homeassistant/components/owntracks/device_tracker.py index 3711b60f9cfe2f..477bf74c4cfa8e 100644 --- a/homeassistant/components/owntracks/device_tracker.py +++ b/homeassistant/components/owntracks/device_tracker.py @@ -4,18 +4,14 @@ from typing import Any, override from homeassistant.components.device_tracker import ( - ATTR_SOURCE_TYPE, DOMAIN as DEVICE_TRACKER_DOMAIN, + DeviceTrackerEntityStateAttribute, SourceType, TrackerEntity, + TrackerEntityStateAttribute, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_BATTERY_LEVEL, - ATTR_GPS_ACCURACY, - ATTR_LATITUDE, - ATTR_LONGITUDE, -) +from homeassistant.const import ATTR_BATTERY_LEVEL, EntityStateAttribute from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import device_registry as dr from homeassistant.helpers.device_registry import DeviceInfo @@ -177,10 +173,13 @@ async def async_added_to_hass(self) -> None: self._data = { "host_name": state.name, - "gps": (attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)), - "gps_accuracy": attr.get(ATTR_GPS_ACCURACY), + "gps": ( + attr.get(EntityStateAttribute.LATITUDE), + attr.get(EntityStateAttribute.LONGITUDE), + ), + "gps_accuracy": attr.get(TrackerEntityStateAttribute.GPS_ACCURACY), "battery": attr.get(ATTR_BATTERY_LEVEL), - "source_type": attr.get(ATTR_SOURCE_TYPE), + "source_type": attr.get(DeviceTrackerEntityStateAttribute.SOURCE_TYPE), "attributes": attributes, } diff --git a/homeassistant/components/owntracks/messages.py b/homeassistant/components/owntracks/messages.py index b59ec84749d872..668b1351548159 100644 --- a/homeassistant/components/owntracks/messages.py +++ b/homeassistant/components/owntracks/messages.py @@ -8,7 +8,8 @@ from homeassistant.components import zone as zone_comp from homeassistant.components.device_tracker import SourceType -from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, STATE_HOME +from homeassistant.components.zone import ZoneEntityStateAttribute +from homeassistant.const import STATE_HOME, EntityStateAttribute from homeassistant.util import decorator, dt as dt_util, slugify from .const import ( @@ -108,10 +109,10 @@ def _set_gps_from_zone(kwargs, location, zone): """ if zone is not None: kwargs["gps"] = ( - zone.attributes[ATTR_LATITUDE], - zone.attributes[ATTR_LONGITUDE], + zone.attributes[EntityStateAttribute.LATITUDE], + zone.attributes[EntityStateAttribute.LONGITUDE], ) - kwargs["gps_accuracy"] = zone.attributes["radius"] + kwargs["gps_accuracy"] = zone.attributes[ZoneEntityStateAttribute.RADIUS] kwargs["location_name"] = location return kwargs diff --git a/homeassistant/components/steam_online/const.py b/homeassistant/components/steam_online/const.py index 89d305419b8495..c5f1233d3723ea 100644 --- a/homeassistant/components/steam_online/const.py +++ b/homeassistant/components/steam_online/const.py @@ -6,7 +6,6 @@ CONF_ACCOUNTS = "accounts" DATA_KEY_COORDINATOR = "coordinator" -DEFAULT_NAME = "Steam" DOMAIN: Final = "steam_online" diff --git a/homeassistant/components/steam_online/entity.py b/homeassistant/components/steam_online/entity.py index ac62ce76ca4598..2c2732ebfa7a65 100644 --- a/homeassistant/components/steam_online/entity.py +++ b/homeassistant/components/steam_online/entity.py @@ -4,7 +4,7 @@ from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import DEFAULT_NAME, DOMAIN +from .const import DOMAIN from .coordinator import SteamDataUpdateCoordinator @@ -28,6 +28,7 @@ def __init__( configuration_url=str(coordinator.data[steamid].profileurl), entry_type=DeviceEntryType.SERVICE, identifiers={(DOMAIN, steamid)}, - manufacturer=DEFAULT_NAME, + model="Steam", + manufacturer="Valve", name=str(coordinator.data[steamid].personaname), ) diff --git a/homeassistant/components/tesla_fleet/manifest.json b/homeassistant/components/tesla_fleet/manifest.json index 8929dc0be85b55..300c29ad0b3a03 100644 --- a/homeassistant/components/tesla_fleet/manifest.json +++ b/homeassistant/components/tesla_fleet/manifest.json @@ -8,5 +8,5 @@ "integration_type": "hub", "iot_class": "cloud_polling", "loggers": ["tesla-fleet-api"], - "requirements": ["tesla-fleet-api==1.7.1"] + "requirements": ["tesla-fleet-api==1.7.2"] } diff --git a/homeassistant/components/teslemetry/device_tracker.py b/homeassistant/components/teslemetry/device_tracker.py index 4e8c360080f195..97dcd8b1515d10 100644 --- a/homeassistant/components/teslemetry/device_tracker.py +++ b/homeassistant/components/teslemetry/device_tracker.py @@ -13,6 +13,7 @@ TrackerEntity, TrackerEntityDescription, ) +from homeassistant.const import EntityStateAttribute from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity @@ -147,8 +148,8 @@ async def async_added_to_hass(self) -> None: """Handle entity which will be added.""" await super().async_added_to_hass() if (state := await self.async_get_last_state()) is not None: - self._attr_latitude = state.attributes.get("latitude") - self._attr_longitude = state.attributes.get("longitude") + self._attr_latitude = state.attributes.get(EntityStateAttribute.LATITUDE) + self._attr_longitude = state.attributes.get(EntityStateAttribute.LONGITUDE) self.async_on_remove( self.entity_description.value_listener( self.vehicle.stream_vehicle, self._location_callback diff --git a/homeassistant/components/teslemetry/manifest.json b/homeassistant/components/teslemetry/manifest.json index e8ac86c3076da2..a446a43e20bf22 100644 --- a/homeassistant/components/teslemetry/manifest.json +++ b/homeassistant/components/teslemetry/manifest.json @@ -9,5 +9,5 @@ "iot_class": "cloud_polling", "loggers": ["tesla_fleet_api", "teslemetry_stream"], "quality_scale": "platinum", - "requirements": ["tesla-fleet-api==1.7.1", "teslemetry-stream==0.9.1"] + "requirements": ["tesla-fleet-api==1.7.2", "teslemetry-stream==0.9.1"] } diff --git a/homeassistant/components/teslemetry/media_player.py b/homeassistant/components/teslemetry/media_player.py index dbe684963022e0..5c1d332c103de8 100644 --- a/homeassistant/components/teslemetry/media_player.py +++ b/homeassistant/components/teslemetry/media_player.py @@ -10,6 +10,7 @@ MediaPlayerDeviceClass, MediaPlayerEntity, MediaPlayerEntityFeature, + MediaPlayerEntityStateAttribute, MediaPlayerState, ) from homeassistant.core import HomeAssistant @@ -201,14 +202,30 @@ async def async_added_to_hass(self) -> None: self._attr_state = MediaPlayerState(state.state) except ValueError: self._attr_state = None - self._attr_volume_level = state.attributes.get("volume_level") - self._attr_media_title = state.attributes.get("media_title") - self._attr_media_artist = state.attributes.get("media_artist") - self._attr_media_album_name = state.attributes.get("media_album_name") - self._attr_media_playlist = state.attributes.get("media_playlist") - self._attr_media_duration = state.attributes.get("media_duration") - self._attr_media_position = state.attributes.get("media_position") - self._attr_source = state.attributes.get("source") + self._attr_volume_level = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_VOLUME_LEVEL + ) + self._attr_media_title = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_TITLE + ) + self._attr_media_artist = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_ARTIST + ) + self._attr_media_album_name = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_ALBUM_NAME + ) + self._attr_media_playlist = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_PLAYLIST + ) + self._attr_media_duration = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_DURATION + ) + self._attr_media_position = state.attributes.get( + MediaPlayerEntityStateAttribute.MEDIA_POSITION + ) + self._attr_source = state.attributes.get( + MediaPlayerEntityStateAttribute.INPUT_SOURCE + ) self.async_write_ha_state() diff --git a/homeassistant/components/teslemetry/update.py b/homeassistant/components/teslemetry/update.py index d3e552883d7efb..c592070bba43c0 100644 --- a/homeassistant/components/teslemetry/update.py +++ b/homeassistant/components/teslemetry/update.py @@ -6,7 +6,11 @@ from tesla_fleet_api.const import Scope from tesla_fleet_api.teslemetry import Vehicle -from homeassistant.components.update import UpdateEntity, UpdateEntityFeature +from homeassistant.components.update import ( + UpdateEntity, + UpdateEntityFeature, + UpdateEntityStateAttribute, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity @@ -154,10 +158,18 @@ async def async_added_to_hass(self) -> None: """Handle entity which will be added.""" await super().async_added_to_hass() if (state := await self.async_get_last_state()) is not None: - self._attr_in_progress = state.attributes.get("in_progress", False) - self._attr_update_percentage = state.attributes.get("update_percentage") - self._attr_installed_version = state.attributes.get("installed_version") - self._attr_latest_version = state.attributes.get("latest_version") + self._attr_in_progress = state.attributes.get( + UpdateEntityStateAttribute.IN_PROGRESS, False + ) + self._attr_update_percentage = state.attributes.get( + UpdateEntityStateAttribute.UPDATE_PERCENTAGE + ) + self._attr_installed_version = state.attributes.get( + UpdateEntityStateAttribute.INSTALLED_VERSION + ) + self._attr_latest_version = state.attributes.get( + UpdateEntityStateAttribute.LATEST_VERSION + ) self._attr_supported_features = UpdateEntityFeature( state.attributes.get( "supported_features", self._attr_supported_features diff --git a/homeassistant/components/tessie/manifest.json b/homeassistant/components/tessie/manifest.json index 0a37f0856c2eec..f47f3a18f8dc3f 100644 --- a/homeassistant/components/tessie/manifest.json +++ b/homeassistant/components/tessie/manifest.json @@ -8,5 +8,5 @@ "iot_class": "cloud_polling", "loggers": ["tessie", "tesla-fleet-api"], "quality_scale": "silver", - "requirements": ["tessie-api==0.1.3", "tesla-fleet-api==1.7.1"] + "requirements": ["tessie-api==0.1.3", "tesla-fleet-api==1.7.2"] } diff --git a/requirements_all.txt b/requirements_all.txt index 6abecac0a27b51..78b7681db0cafc 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1347,7 +1347,7 @@ ihcsdk==2.8.12 imeon_inverter_api==0.4.0 # homeassistant.components.imgw_pib -imgw_pib==2.4.0 +imgw_pib==2.4.3 # homeassistant.components.incomfort incomfort-client==0.7.0 @@ -3162,7 +3162,7 @@ temperusb==1.6.1 # homeassistant.components.tesla_fleet # homeassistant.components.teslemetry # homeassistant.components.tessie -tesla-fleet-api==1.7.1 +tesla-fleet-api==1.7.2 # homeassistant.components.powerwall tesla-powerwall==0.5.3 diff --git a/tests/components/steam_online/snapshots/test_init.ambr b/tests/components/steam_online/snapshots/test_init.ambr index 62d11b8f6b6d6a..9cec5ffc35b05a 100644 --- a/tests/components/steam_online/snapshots/test_init.ambr +++ b/tests/components/steam_online/snapshots/test_init.ambr @@ -19,8 +19,8 @@ }), 'labels': set({ }), - 'manufacturer': 'Steam', - 'model': None, + 'manufacturer': 'Valve', + 'model': 'Steam', 'model_id': None, 'name': 'testaccount1', 'name_by_user': None,