implemented button events for cardEntities page

This commit is contained in:
joBr99
2022-03-05 16:48:04 +01:00
committed by GitHub
parent 3a0135195f
commit 725edc5f5c

View File

@@ -79,7 +79,22 @@ class NsPanelLovelanceUI:
if msg[1] == "buttonPress": if msg[1] == "buttonPress":
self.api.log("received buttonPress command") self.api.log("received buttonPress command")
# TODO: implement button press function entity_id = msg[4]
if(msg[6] == "OnOff"):
if(msg[7] == "1"):
self.api.turn_on(entity_id)
else:
self.api.turn_off(entity_id)
if(msg[6] == "up"):
self.api.get_entity(entity_id).call_service("open_cover")
if(msg[6] == "stop"):
self.api.get_entity(entity_id).call_service("stop_cover")
if(msg[6] == "down"):
self.api.get_entity(entity_id).call_service("close_cover")
if(msg[6] == "button"):
self.api.get_entity(entity_id).call_service("press")
if msg[1] == "pageOpenDetail": if msg[1] == "pageOpenDetail":
self.api.log("received pageOpenDetail command") self.api.log("received pageOpenDetail command")
@@ -167,4 +182,4 @@ class NsPanelLovelanceUI:
# Send page type # Send page type
self.send_mqtt_msg("pageType,{0}".format(page_type)) self.send_mqtt_msg("pageType,{0}".format(page_type))
command = self.generate_thermo_page(self.config["pages"][self.current_page_nr]["item"]) command = self.generate_thermo_page(self.config["pages"][self.current_page_nr]["item"])
self.send_mqtt_msg(command) self.send_mqtt_msg(command)