Skip to content

Commit

Permalink
add kodi entity in meta
Browse files Browse the repository at this point in the history
  • Loading branch information
jtbgroup committed Feb 8, 2024
1 parent 81a955c commit d72b87f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ def __init__(
self,
unique_id,
kodi: Kodi,
kodi_entity_id,
config: KodiConfig,
event_manager: MediaSensorEventManager,
) -> None:
super().__init__()
self._unique_id = unique_id
self._kodi = kodi
self._kodi_entity_id = kodi_entity_id
self._event_manager = event_manager
self._define_base_url(config)
self._state = STATE_OFF
Expand Down Expand Up @@ -218,6 +220,7 @@ def init_meta(self, event_id):
self.purge_meta(event_id)
self._meta[0]["update_time"] = ds
self._meta[0]["sensor_entity_id"] = self.domain_unique_id
self._meta[0]["kodi_entity_id"] = self._kodi_entity_id
self._meta[0]["service_domain"] = DOMAIN
self.build_attrs()
_LOGGER.debug("Init metadata (event %s)", event_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ def __init__(
event_manager: MediaSensorEventManager,
):
super().__init__(
_UNIQUE_ID_PREFIX + config_unique_id, kodi, config, event_manager
_UNIQUE_ID_PREFIX + config_unique_id,
kodi,
kodi_entity_id,
config,
event_manager,
)

self._hass = hass
self._kodi_entity_id = kodi_entity_id

homeassistant.helpers.event.async_track_state_change_event(
hass, kodi_entity_id, self.__handle_event
Expand Down Expand Up @@ -249,7 +252,6 @@ async def _update_meta(self, event_id):
player = players[0]
player_id = player["playerid"]
self.add_meta("playlist_id", player_id)
self.add_meta("kodi_entity_id", self._kodi_entity_id)
self.add_meta("playlist_type", player["type"])

props_item_playing = await self._kodi.get_playing_item_properties(
Expand Down Expand Up @@ -332,7 +334,7 @@ async def kodi_get_playlist(self):
# )
# value["api_image"] = url

return result
# return result

async def kodi_get_playlist_light(self, playlistid):
limits = {"start": 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ def __init__(
event_manager: MediaSensorEventManager,
):
super().__init__(
_UNIQUE_ID_PREFIX + config_unique_id, kodi, config, event_manager
_UNIQUE_ID_PREFIX + config_unique_id,
kodi,
kodi_entity_id,
config,
event_manager,
)

self._hass = hass
Expand Down

0 comments on commit d72b87f

Please sign in to comment.