mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-21 15:04:24 +01:00
added on off button to media page
This commit is contained in:
BIN
HMI/nspanel.HMI
BIN
HMI/nspanel.HMI
Binary file not shown.
BIN
HMI/nspanel.tft
BIN
HMI/nspanel.tft
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user