1111from yarl import URL
1212
1313from homeassistant .components .binary_sensor import (
14+ DOMAIN as BINARY_SENSOR_DOMAIN ,
1415 BinarySensorEntity ,
1516 BinarySensorEntityDescription ,
1617)
1718from homeassistant .core import HomeAssistant , callback
1819from homeassistant .helpers .entity_platform import AddConfigEntryEntitiesCallback
1920
2021from .coordinator import XboxConfigEntry , XboxUpdateCoordinator
21- from .entity import XboxBaseEntity
22+ from .entity import XboxBaseEntity , check_deprecated_entity
2223
2324
2425class XboxBinarySensor (StrEnum ):
@@ -37,6 +38,7 @@ class XboxBinarySensorEntityDescription(BinarySensorEntityDescription):
3738
3839 is_on_fn : Callable [[Person ], bool | None ]
3940 entity_picture_fn : Callable [[Person ], str | None ] | None = None
41+ deprecated : bool | None = None
4042
4143
4244def profile_pic (person : Person ) -> str | None :
@@ -82,13 +84,8 @@ def in_game(person: Person) -> bool:
8284 ),
8385 XboxBinarySensorEntityDescription (
8486 key = XboxBinarySensor .IN_PARTY ,
85- translation_key = XboxBinarySensor .IN_PARTY ,
86- is_on_fn = (
87- lambda x : bool (x .multiplayer_summary .in_party )
88- if x .multiplayer_summary
89- else None
90- ),
91- entity_registry_enabled_default = False ,
87+ is_on_fn = lambda _ : None ,
88+ deprecated = True ,
9289 ),
9390 XboxBinarySensorEntityDescription (
9491 key = XboxBinarySensor .IN_GAME ,
@@ -97,13 +94,8 @@ def in_game(person: Person) -> bool:
9794 ),
9895 XboxBinarySensorEntityDescription (
9996 key = XboxBinarySensor .IN_MULTIPLAYER ,
100- translation_key = XboxBinarySensor .IN_MULTIPLAYER ,
101- is_on_fn = (
102- lambda x : bool (x .multiplayer_summary .in_multiplayer_session )
103- if x .multiplayer_summary
104- else None
105- ),
106- entity_registry_enabled_default = False ,
97+ is_on_fn = lambda _ : None ,
98+ deprecated = True ,
10799 ),
108100 XboxBinarySensorEntityDescription (
109101 key = XboxBinarySensor .HAS_GAME_PASS ,
@@ -121,7 +113,9 @@ async def async_setup_entry(
121113 """Set up Xbox Live friends."""
122114 coordinator = entry .runtime_data
123115
124- update_friends = partial (async_update_friends , coordinator , {}, async_add_entities )
116+ update_friends = partial (
117+ async_update_friends , hass , coordinator , {}, async_add_entities
118+ )
125119
126120 entry .async_on_unload (coordinator .async_add_listener (update_friends ))
127121
@@ -152,6 +146,7 @@ def entity_picture(self) -> str | None:
152146
153147@callback
154148def async_update_friends (
149+ hass : HomeAssistant ,
155150 coordinator : XboxUpdateCoordinator ,
156151 current : dict [str , list [XboxBinarySensorEntity ]],
157152 async_add_entities ,
@@ -163,10 +158,11 @@ def async_update_friends(
163158 # Process new favorites, add them to Home Assistant
164159 new_entities : list [XboxBinarySensorEntity ] = []
165160 for xuid in new_ids - current_ids :
166- current [xuid ] = [
167- XboxBinarySensorEntity (coordinator , xuid , description )
168- for description in SENSOR_DESCRIPTIONS
169- ]
161+ current [xuid ] = []
162+ for description in SENSOR_DESCRIPTIONS :
163+ entity = XboxBinarySensorEntity (coordinator , xuid , description )
164+ if check_deprecated_entity (hass , entity , BINARY_SENSOR_DOMAIN ):
165+ current [xuid ].append (entity )
170166 new_entities = new_entities + current [xuid ]
171167 if new_entities :
172168 async_add_entities (new_entities )
0 commit comments