Skip to content

Commit

Permalink
Merge pull request #10 from chatziko/run-satellite-start-stage
Browse files Browse the repository at this point in the history
add start_stage to run-satellite
  • Loading branch information
synesthesiam authored May 28, 2024
2 parents 3ef7ee0 + 08fbd3a commit e61742f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Play audio stream.
Control of one or more remote voice satellites connected to a central server.

* `run-satellite` - informs satellite that server is ready to run pipelines
* `start_stage` - request pipelines with a specific starting stage (string, optional)
* `pause-satellite` - informs satellite that server is not ready anymore to run pipelines
* `satellite-connected` - satellite has connected to the server
* `satellite-disconnected` - satellite has been disconnected from the server
Expand Down
18 changes: 16 additions & 2 deletions wyoming/satellite.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Satellite events."""
from dataclasses import dataclass
from typing import Any, Dict, Optional

from .event import Event, Eventable
from .pipeline import PipelineStage

_RUN_SATELLITE_TYPE = "run-satellite"
_PAUSE_SATELLITE_TYPE = "pause-satellite"
Expand All @@ -15,16 +17,28 @@
class RunSatellite(Eventable):
"""Informs the satellite that the server is ready to run a pipeline."""

start_stage: Optional[PipelineStage] = None

@staticmethod
def is_type(event_type: str) -> bool:
return event_type == _RUN_SATELLITE_TYPE

def event(self) -> Event:
return Event(type=_RUN_SATELLITE_TYPE)
data: Dict[str, Any] = {}

if self.start_stage is not None:
data["start_stage"] = self.start_stage.value

return Event(type=_RUN_SATELLITE_TYPE, data=data)

@staticmethod
def from_event(event: Event) -> "RunSatellite":
return RunSatellite()
# note: older versions don't send event.data
start_stage = None
if value := (event.data or {}).get("start_stage"):
start_stage = PipelineStage(value)

return RunSatellite(start_stage=start_stage)


@dataclass
Expand Down

0 comments on commit e61742f

Please sign in to comment.