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
10 changes: 7 additions & 3 deletions homeassistant/components/geo_location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
15 changes: 12 additions & 3 deletions homeassistant/components/geo_location/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion homeassistant/components/imgw_pib/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
24 changes: 11 additions & 13 deletions homeassistant/components/owntracks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 9 additions & 10 deletions homeassistant/components/owntracks/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}

Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/owntracks/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/steam_online/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
CONF_ACCOUNTS = "accounts"

DATA_KEY_COORDINATOR = "coordinator"
DEFAULT_NAME = "Steam"
DOMAIN: Final = "steam_online"


Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/steam_online/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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),
)
2 changes: 1 addition & 1 deletion homeassistant/components/tesla_fleet/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
5 changes: 3 additions & 2 deletions homeassistant/components/teslemetry/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/teslemetry/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
33 changes: 25 additions & 8 deletions homeassistant/components/teslemetry/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
MediaPlayerDeviceClass,
MediaPlayerEntity,
MediaPlayerEntityFeature,
MediaPlayerEntityStateAttribute,
MediaPlayerState,
)
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -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()

Expand Down
22 changes: 17 additions & 5 deletions homeassistant/components/teslemetry/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tessie/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
4 changes: 2 additions & 2 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/components/steam_online/snapshots/test_init.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
}),
'labels': set({
}),
'manufacturer': 'Steam',
'model': None,
'manufacturer': 'Valve',
'model': 'Steam',
'model_id': None,
'name': 'testaccount1',
'name_by_user': None,
Expand Down
Loading