implemented speaker control on media page

This commit is contained in:
joBr99
2022-03-27 15:48:57 +02:00
parent 5aaf20b2f7
commit 3ad9fdb189
7 changed files with 15 additions and 7 deletions

View File

@@ -129,7 +129,7 @@ The following message can be used to update the content on the cardEntities Page
### cardMedia Page
`entityUpd,|*internalNameEntiy*|*heading*|*icon*|*title*|*author*|*volume*|*playpauseicon*`
`entityUpd,|*internalNameEntiy*|*heading*|*icon*|*title*|*author*|*volume*|*playpauseicon*|currentSpeaker|speakerList-seperated-by-?`
### cardAlarm Page

Binary file not shown.

Binary file not shown.

View File

@@ -178,13 +178,13 @@ class LuiController(object):
self._ha_api.get_entity(entity_id).call_service("media_previous_track")
if button_type == "media-pause":
self._ha_api.get_entity(entity_id).call_service("media_play_pause")
if button_type == "hvac_action":
self._ha_api.get_entity(entity_id).call_service("set_hvac_mode", hvac_mode=value)
if button_type == "volumeSlider":
pos = int(value)
# HA wants this value between 0 and 1 as float
pos = pos/100
self._ha_api.get_entity(entity_id).call_service("volume_set", volume_level=pos)
if button_type == "speaker-sel":
self._ha_api.get_entity(entity_id).call_service("select_source", source=value)
# for light detail page
if button_type == "brightnessSlider":
@@ -207,3 +207,5 @@ class LuiController(object):
if button_type == "tempUpd":
temp = int(value)/10
self._ha_api.get_entity(entity_id).call_service("set_temperature", temperature=temp)
if button_type == "hvac_action":
self._ha_api.get_entity(entity_id).call_service("set_hvac_mode", hvac_mode=value)

View File

@@ -265,7 +265,13 @@ class LuiPagesGen(object):
if "media_content_type" in entity.attributes:
if entity.attributes.media_content_type == "music":
icon = get_icon_id("music")
command = f"entityUpd,|{item}|{heading}|{icon}|{title}|{author}|{volume}|{iconplaypause}"
source = entity.attributes.get("source", "")
speakerlist = entity.attributes.get("source_list","")
if source in speakerlist:
speakerlist.remove(source)
speakerlist.append(source)
speakerlist = "?".join(speakerlist)
command = f"entityUpd,|{item}|{heading}|{icon}|{title}|{author}|{volume}|{iconplaypause}|{source}|{speakerlist}"
self._send_mqtt_msg(command)
def render_page(self, page, send_page_type=True):

View File

@@ -64,8 +64,8 @@ class NsPanelLovelaceUIManager(hass.Hass):
controller = LuiController(self, cfg, send_mqtt_msg)
desired_display_firmware_version = 19
desired_display_firmware_url = "http://nspanel.pky.eu/lovelace-ui/github/nspanel-v1.8.3.tft"
desired_display_firmware_version = 20
desired_display_firmware_url = "http://nspanel.pky.eu/lovelace-ui/github/nspanel-v1.9.0.tft"
desired_tasmota_driver_version = 3
desired_tasmota_driver_url = "https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

After

Width:  |  Height:  |  Size: 270 KiB