added on off button to media page

This commit is contained in:
joBr99
2022-03-28 21:37:53 +02:00
parent 4f01f9cdc4
commit f070511e5f
4 changed files with 14 additions and 6 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -181,10 +181,12 @@ class LuiController(object):
if button_type == "media-back":
self._ha_api.get_entity(entity_id).call_service("media_previous_track")
if button_type == "media-pause":
player = self._ha_api.get_entity(entity_id)
self._ha_api.get_entity(entity_id).call_service("media_play_pause")
if button_type == "media-OnOff":
if player.state == "off":
player.call_service("turn_on")
player.call_service("media_play_pause")
self._ha_api.get_entity(entity_id).call_service("turn_on")
else:
self._ha_api.get_entity(entity_id).call_service("turn_off")
if button_type == "volumeSlider":
pos = int(value)
# HA wants this value between 0 and 1 as float

View File

@@ -249,10 +249,16 @@ class LuiPagesGen(object):
if len(speakerlist) == 1:
speakerlist = []
speakerlist = "?".join(speakerlist)
supported_features = entity.attributes.supported_features
command = f"entityUpd,|{item}|{heading}|{icon}|{title}|{author}|{volume}|{iconplaypause}|{source}|{speakerlist}|{supported_features}"
bits = entity.attributes.supported_features
onoffbutton = "disable"
if bits & 0b01000000:
if entity.state == "off"
onoffbutton = 1374
else:
onoffbutton = rgb_dec565([255,255,255])
command = f"entityUpd,|{item}|{heading}|{icon}|{title}|{author}|{volume}|{iconplaypause}|{source}|{speakerlist}|{onoffbutton}"
self._send_mqtt_msg(command)
def generate_alarm_page(self, item):
if not self._ha_api.entity_exists(item):
command = f"entityUpd,{item},Not found,Not found,Check your,Check your,apps.,apps.,yaml,yaml,0,,0"