Control play/pause and next/prev track with buttons on media screens
This commit is contained in:
11
api.py
11
api.py
@@ -70,6 +70,15 @@ class Api:
|
|||||||
else: dir = "down"
|
else: dir = "down"
|
||||||
self.__post(f"/api/services/media_player/volume_{dir}", {"entity_id": entity_id})
|
self.__post(f"/api/services/media_player/volume_{dir}", {"entity_id": entity_id})
|
||||||
self.__post(f"/api/services/media_player/volume_{dir}", {"entity_id": entity_id})
|
self.__post(f"/api/services/media_player/volume_{dir}", {"entity_id": entity_id})
|
||||||
|
|
||||||
|
def nextTrack(self, entity_id: str) -> None:
|
||||||
|
self.__post("/api/services/media_player/media_next_track", {"entity_id": entity_id})
|
||||||
|
|
||||||
|
def prevTrack(self, entity_id: str) -> None:
|
||||||
|
self.__post("/api/services/media_player/media_previous_track", {"entity_id": entity_id})
|
||||||
|
|
||||||
|
def playPause(self, entity_id: str) -> None:
|
||||||
|
self.__post("/api/services/media_player/media_play_pause", {"entity_id": entity_id})
|
||||||
|
|
||||||
def toggleLight(self, entity_id: str) -> None:
|
def toggleLight(self, entity_id: str) -> None:
|
||||||
self.__post(f"/api/services/light/toggle", {"entity_id": entity_id})
|
self.__post("/api/services/light/toggle", {"entity_id": entity_id})
|
||||||
|
|||||||
17
app.py
17
app.py
@@ -212,15 +212,28 @@ class App:
|
|||||||
def __handleMediaScreenButtons(self) -> bool:
|
def __handleMediaScreenButtons(self) -> bool:
|
||||||
up = self.lcd.up["v"]
|
up = self.lcd.up["v"]
|
||||||
down = self.lcd.down["v"]
|
down = self.lcd.down["v"]
|
||||||
|
keyA = self.lcd.keyA["v"]
|
||||||
|
keyX = self.lcd.keyX["v"]
|
||||||
|
keyY = self.lcd.keyY["v"]
|
||||||
self.lcd.up["v"] = False
|
self.lcd.up["v"] = False
|
||||||
self.lcd.down["v"] = False
|
self.lcd.down["v"] = False
|
||||||
|
self.lcd.keyA["v"] = False
|
||||||
|
self.lcd.keyX["v"] = False
|
||||||
|
self.lcd.keyY["v"] = False
|
||||||
a = False
|
a = False
|
||||||
|
e = SCREENS[self.screen]["entity"]
|
||||||
if (up):
|
if (up):
|
||||||
self.api.changeVolume(SCREENS[self.screen]["entity"])
|
self.api.changeVolume(e)
|
||||||
a = True
|
a = True
|
||||||
elif (down):
|
elif (down):
|
||||||
self.api.changeVolume(SCREENS[self.screen]["entity"], False)
|
self.api.changeVolume(e, False)
|
||||||
a = True
|
a = True
|
||||||
|
if (keyX):
|
||||||
|
self.api.nextTrack(e)
|
||||||
|
elif (keyY):
|
||||||
|
self.api.prevTrack(e)
|
||||||
|
if (keyA):
|
||||||
|
self.api.playPause(e)
|
||||||
return a
|
return a
|
||||||
# if (a): self.__handleMediaScreenButtons()
|
# if (a): self.__handleMediaScreenButtons()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user