Add play/pause command support to HassUserClient with button component
This commit is contained in:
parent
77aa8b5b92
commit
2137378f07
1 changed files with 19 additions and 0 deletions
|
@ -175,3 +175,22 @@ class HassSystemClient(HassClient):
|
||||||
class HassUserClient(HassClient):
|
class HassUserClient(HassClient):
|
||||||
def __init__(self, node_id: str, config: Mapping[str, Any]) -> None:
|
def __init__(self, node_id: str, config: Mapping[str, Any]) -> None:
|
||||||
super().__init__(f"{node_id}_{getpass.getuser()}", config)
|
super().__init__(f"{node_id}_{getpass.getuser()}", config)
|
||||||
|
|
||||||
|
def do_command(self, payload: str) -> None:
|
||||||
|
super().do_command(payload)
|
||||||
|
|
||||||
|
match payload:
|
||||||
|
case "PLAY_PAUSE":
|
||||||
|
log.info("Toggling play/pause…")
|
||||||
|
run(["playerctl", "play-pause"])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def components(self) -> dict[str, dict[str, str]]:
|
||||||
|
return {
|
||||||
|
"play-pause": {
|
||||||
|
"unique_id": f"{self.node_id}_play_pause",
|
||||||
|
"p": "button",
|
||||||
|
"name": "Play/Pause",
|
||||||
|
"payload_press": "PLAY_PAUSE",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue