Merge pull request #22 from Mattie112/patch-3

Added support for scenes
This commit is contained in:
Johannes
2022-03-07 20:58:51 +01:00
committed by GitHub
2 changed files with 15 additions and 2 deletions

View File

@@ -246,6 +246,13 @@ nspanel-1:
- button.example_button
- input_button.example_input_button
- light.light_example
- delete # To make sure we don't keep buttons from previous page (read this as 'empty')
- type: cardEntities
heading: Example Page 3
items:
- scene.some_scene
- scene.moodlights
- delete
- delete
- type: cardThermo
heading: Exmaple Thermostat

View File

@@ -179,6 +179,9 @@ class NsPanelLovelanceUI:
self.api.get_entity(entity_id).call_service("close_cover")
if(btype == "button"):
if(entity_id.startswith('scene')):
self.api.get_entity(entity_id).call_service("turn_on")
else:
self.api.get_entity(entity_id).call_service("press")
if(btype == "media-next"):
@@ -300,8 +303,11 @@ class NsPanelLovelanceUI:
value = entity.state + " " + entity.attributes.unit_of_measurement
return "entityUpd,{0},{1},{2},{3},{4},{5}".format(item_nr, "text", item, icon_id, name, value)
if item_type == "button":
return "entityUpd,{0},{1},{2},{3},{4},{5}".format(item_nr, item_type, item, 3, name, "PRESS")
if item_type == "button" or item_type == "input_button":
return "entityUpd,{0},{1},{2},{3},{4},{5}".format(item_nr, "button", item, 3, name, "PRESS")
if item_type == "scene":
return "entityUpd,{0},{1},{2},{3},{4},{5}".format(item_nr, "button", item, 5, name, "ACTIVATE")
def generate_thermo_page(self, item):
entity = self.api.get_entity(item)