Skip to content

Commit

Permalink
Merge pull request #27 from jshtz4/device_id-to-assist
Browse files Browse the repository at this point in the history
Get device_id for assist if not set
  • Loading branch information
AlexxIT committed May 23, 2024
2 parents 0fc5e66 + 0232b70 commit 0d29e43
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/stream_assist/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, config_entry: ConfigEntry):
self._attr_is_on = False
self._attr_should_poll = False

self.options = config_entry.options
self.options = config_entry.options.copy()
self.uid = init_entity(self, "mic", config_entry)

def event_callback(self, event: PipelineEvent):
Expand All @@ -44,6 +44,9 @@ def event_callback(self, event: PipelineEvent):

async_dispatcher_send(self.hass, f"{self.uid}-{name}", state, event.data)

async def async_added_to_hass(self) -> None:
self.options["assist"] = {"device_id": self.device_entry.id}

async def async_turn_on(self) -> None:
if self._attr_is_on:
return
Expand All @@ -56,7 +59,7 @@ async def async_turn_on(self) -> None:

self.on_close = run_forever(
self.hass,
self.options.copy(),
self.options,
context=self._context,
event_callback=self.event_callback,
)
Expand Down

0 comments on commit 0d29e43

Please sign in to comment.