implemented buttons #81 and triggered state

This commit is contained in:
Johannes
2022-03-28 17:31:57 +02:00
parent 4fd2d3b260
commit a27bc617a2
8 changed files with 172 additions and 16 deletions

View File

@@ -44,7 +44,8 @@ icons = [
"shield-off",
"shield",
"shield-lock",
"shield-airplane"
"shield-airplane",
"bell-ring"
]

View File

@@ -47,3 +47,4 @@ ID | MD Icon Name | Icon
40 | shield | ![shield](https://raw.githubusercontent.com/Templarian/MaterialDesign-SVG/0aeb4d612644d80d9d1fe242f705f362985de5dc/svg/shield.svg)
41 | shield-lock | ![shield-lock](https://raw.githubusercontent.com/Templarian/MaterialDesign-SVG/0aeb4d612644d80d9d1fe242f705f362985de5dc/svg/shield-lock.svg)
42 | shield-airplane | ![shield-airplane](https://raw.githubusercontent.com/Templarian/MaterialDesign-SVG/0aeb4d612644d80d9d1fe242f705f362985de5dc/svg/shield-airplane.svg)
43 | bell-ring | ![bell-ring](https://raw.githubusercontent.com/Templarian/MaterialDesign-SVG/0aeb4d612644d80d9d1fe242f705f362985de5dc/svg/bell-ring.svg)

Binary file not shown.

Binary file not shown.

View File

@@ -216,3 +216,7 @@ class LuiController(object):
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)
# for alarm page
if button_type in ["disarm", "arm_home", "arm_away", "arm_night", "arm_vacation"]:
self._ha_api.get_entity(entity_id).call_service(f"alarm_{button_type}", code=value)

View File

@@ -42,6 +42,7 @@ icons = {
'shield': 40,
'shield-lock': 41,
'shield-airplane': 42,
'bell-ring': 43,
}
def get_icon_id(ma_name):

View File

@@ -7,6 +7,13 @@ translations = {
'fan': "Waaier",
'idle': "Onaktief",
'off': "Af",
'arm_away': "Bewapen weg",
'arm_custom_bypass': "Pasgemaakte omseil",
'arm_home': "Bewapen Huis",
'arm_night': "Nag alarm",
'clear_code': "Maak skoon",
'code': "Kode",
'disarm': "Skakel Af",
},
'ca_ES': {
'PRESS': "Prem",
@@ -17,6 +24,14 @@ translations = {
'fan': "Ventilació",
'idle': "Inactiu",
'off': "OFF",
'arm_away': "Activar, fora",
'arm_custom_bypass': "Bypass personalitzat",
'arm_home': "Activar, a casa",
'arm_night': "Activar, nocturn",
'arm_vacation': "Activa en mode vacances",
'clear_code': "Borrar",
'code': "Codi",
'disarm': "Desactivar",
},
'cs_CZ': {
'PRESS': "Stisknutí",
@@ -27,10 +42,21 @@ translations = {
'fan': "Ventilátor",
'idle': "Nečinný",
'off': "Vypnuto",
'arm_away': "Aktivovat režim nepřítomnost",
'arm_custom_bypass': "Vlastní obejítí",
'arm_home': "Aktivovat režim domov",
'arm_night': "Aktivovat noční režim",
'arm_vacation': "Aktivovat režim dovolená",
'clear_code': "Zrušit",
'code': "Kód",
'disarm': "Odbezpečit",
},
'cy_GB': {
'ACTIVATE': "Actifadu",
'off': "I ffwrdd",
'arm_custom_bypass': "Ffordd osgoi personol",
'arm_night': "Larwm nos",
'code': "Cod dilysu dwy-ffactor",
},
'da_DK': {
'PRESS': "Tryk",
@@ -41,6 +67,14 @@ translations = {
'fan': "Blæser",
'idle': "Inaktiv",
'off': "Fra",
'arm_away': "Tilkobl ude",
'arm_custom_bypass': "Brugerdefineret bypass",
'arm_home': "Tilkobl hjemme",
'arm_night': "Tilkoblet nat",
'arm_vacation': "Tilkobl ferie",
'clear_code': "Ryd",
'code': "Kode",
'disarm': "Frakobl",
},
'de_DE': {
'PRESS': "Drücken",
@@ -51,8 +85,14 @@ translations = {
'fan': "Ventilator",
'idle': "Leerlauf",
'off': "Aus",
},
'en_GB': {
'arm_away': "Aktivieren - Unterwegs",
'arm_custom_bypass': "Benutzerdefinierter Bypass",
'arm_home': "Aktivieren - Zuhause",
'arm_night': "Aktivieren - Nacht",
'arm_vacation': "Aktiviere Urlaub",
'clear_code': "Löschen",
'code': "Code",
'disarm': "Deaktivieren",
},
'en_US': {
'PRESS': "Press",
@@ -63,6 +103,14 @@ translations = {
'fan': "Fan",
'idle': "Idle",
'off': "Off",
'arm_away': "Arm away",
'arm_custom_bypass': "Custom bypass",
'arm_home': "Arm home",
'arm_night': "Arm night",
'arm_vacation': "Arm vacation",
'clear_code': "Clear",
'code': "Code",
'disarm': "Disarm",
},
'es_ES': {
'PRESS': "Pulsa",
@@ -73,6 +121,14 @@ translations = {
'fan': "Ventilador",
'idle': "Inactivo",
'off': "Apagado",
'arm_away': "Armar ausente",
'arm_custom_bypass': "Bypass personalizada",
'arm_home': "Armar en casa",
'arm_night': "Armar noche",
'arm_vacation': "Armar por vacaciones",
'clear_code': "Limpiar",
'code': "Código",
'disarm': "Desarmar",
},
'et_EE': {
'PRESS': "Vajuta nuppu",
@@ -83,10 +139,20 @@ translations = {
'fan': "Ventilaator",
'idle': "Ootel",
'off': "Väljas",
'arm_away': "Valvesta eemal",
'arm_custom_bypass': "Eranditega",
'arm_home': "Valvesta kodus",
'arm_night': "Valvesta öine",
'arm_vacation': "Valvesta puhkuse režiimis",
'clear_code': "Puhasta",
'code': "Kood",
'disarm': "Valvest maha",
},
'eu_ES': {
'ACTIVATE': "Aktibatu",
'off': "Itzalita",
'clear_code': "Garbitu",
'code': "Kodea",
},
'fi_FI': {
'PRESS': "Paina",
@@ -97,6 +163,14 @@ translations = {
'fan': "Tuuletin",
'idle': "Lepotilassa",
'off': "Pois",
'arm_away': "Viritä (poissa)",
'arm_custom_bypass': "Mukautettu ohitus",
'arm_home': "Viritä (kotona)",
'arm_night': "Viritä yöksi",
'arm_vacation': "Aktivoi lomatila",
'clear_code': "Tyhjennä",
'code': "Koodi",
'disarm': "Poista hälytys",
},
'fr_FR': {
'PRESS': "Appui",
@@ -107,6 +181,14 @@ translations = {
'fan': "Ventilateur",
'idle': "Inactif",
'off': "Off",
'arm_away': "Armer (absent)",
'arm_custom_bypass': "Bypass personnalisé",
'arm_home': "Armer (présent)",
'arm_night': "Armer nuit",
'arm_vacation': "Armer vacances",
'clear_code': "Effacer",
'code': "Code",
'disarm': "Désarmer",
},
'fy_DE': {
'off': "Út",
@@ -122,6 +204,13 @@ translations = {
'fan': "Ventilator",
'idle': "Neaktivan",
'off': "Isključen",
'arm_away': "Aktiviran odsutno",
'arm_custom_bypass': "Prilagođena premosnica",
'arm_home': "Aktiviran doma",
'arm_night': "Aktiviran nočni",
'clear_code': "Vedro",
'code': "Kod",
'disarm': "Deaktiviraj",
},
'id_ID': {
'PRESS': "Tekan",
@@ -132,6 +221,14 @@ translations = {
'fan': "Kipas",
'idle': "Diam",
'off': "Mati",
'arm_away': "Aktifkan utk keluar",
'arm_custom_bypass': "Diaktifkan khusus",
'arm_home': "Aktifkan utk di rumah",
'arm_night': "Aktifkan utk malam",
'arm_vacation': "Aktifkan utk liburan",
'clear_code': "Hapus",
'code': "Kode",
'disarm': "Nonaktifkan",
},
'is_IS': {
'PRESS': "Ýttu á",
@@ -141,6 +238,14 @@ translations = {
'fan': "Vifta",
'idle': "Aðgerðalaus",
'off': "Slökkt",
'arm_away': "Vörður úti",
'arm_custom_bypass': "Sérsniðin hjáleið",
'arm_home': "Vörður heima",
'arm_night': "Vörður nótt",
'arm_vacation': "Vörður frí",
'clear_code': "Hreinsa",
'code': "Kóði",
'disarm': "Taka af verði",
},
'it_IT': {
'PRESS': "Premi",
@@ -151,6 +256,14 @@ translations = {
'fan': "Ventilatore",
'idle': "Inattivo",
'off': "Spento",
'arm_away': "Attiva fuori casa",
'arm_custom_bypass': "Bypass personalizzato",
'arm_home': "Attiva in casa",
'arm_night': "Attiva notte",
'arm_vacation': "Attiva in vacanza",
'clear_code': "Canc",
'code': "Codice",
'disarm': "Disattiva",
},
'nl_NL': {
'PRESS': "Klik",
@@ -161,6 +274,14 @@ translations = {
'fan': "Ventilator",
'idle': "Inactief",
'off': "Uit",
'arm_away': "Inschakelen voor vertrek",
'arm_custom_bypass': "Inschakelen met overbrugging",
'arm_home': "Inschakelen voor thuis",
'arm_night': "Inschakelen voor 's nachts",
'arm_vacation': "Inschakelen voor vakantie",
'clear_code': "Wis",
'code': "Code",
'disarm': "Uitschakelen",
},
'nn_NO': {
'ACTIVATE': "Aktiver",
@@ -170,6 +291,14 @@ translations = {
'fan': "Vifte",
'idle': "Tomgang",
'off': "Av",
'arm_away': "Bortemodus",
'arm_custom_bypass': "Tilpassa bypass",
'arm_home': "Heimemodus",
'arm_night': "Aktiver natt",
'arm_vacation': "Armert feriemodus",
'clear_code': "Slett alt",
'code': "Kode",
'disarm': "Skru av",
},
'pt_PT': {
'PRESS': "Pressione",
@@ -180,6 +309,13 @@ translations = {
'fan': "Ventoinha",
'idle': "Em espera",
'off': "Desligado",
'arm_away': "Armado ausente",
'arm_custom_bypass': "Desvio personalizado",
'arm_home': "Armado casa",
'arm_night': "Armado noite",
'clear_code': "Apagar",
'code': "Código",
'disarm': "Desarmar",
},
'sr_RS': {
'PRESS': "Pritisnite taster",
@@ -195,6 +331,14 @@ translations = {
'fan': "Fläkt",
'idle': "Inaktiv",
'off': "Av",
'arm_away': "Larma bortaläge",
'arm_custom_bypass': "Larm förbikopplat",
'arm_home': "Larma hemmaläge",
'arm_night': "Larma nattläge",
'arm_vacation': "Larma semesterläge",
'clear_code': "Rensa",
'code': "Kod",
'disarm': "Larma från",
},
}
@@ -202,4 +346,4 @@ def get_translation(locale, input):
if locale in translations:
return translations.get(locale).get(input, input)
else:
return translations.get("en_US").get(input, input)
return translations.get("en_US").get(input, input)

View File

@@ -264,26 +264,24 @@ class LuiPagesGen(object):
if entity.state == "disarmed":
color = rgb_dec565([13,160,53])
icon = get_icon_id("shield-off")
if entity.attributes.get("code_arm_required", "false") == "false":
test = entity.attributes.get("code_arm_required", "false")
if not entity.attributes.get("code_arm_required", False):
numpad = "disable"
bits = entity.attributes.supported_features
if bits & 0b000001:
supported_modes.append("ARM HOME")
supported_modes.append("arm_home")
if bits & 0b000010:
supported_modes.append("ARM AWAY")
supported_modes.append("arm_away")
if bits & 0b000100:
supported_modes.append("ARM NIGHT")
supported_modes.append("arm_night")
if bits & 0b100000:
supported_modes.append("ARM VACATION")
supported_modes.append("arm_vacation")
else:
supported_modes.append("DISARM")
supported_modes.append("disarm")
if entity.state == "armed_home":
color = rgb_dec565([223,76,30])
icon = get_icon_id("shield-home")
if entity.state == "arming":
color = rgb_dec565([243,179,0])
icon = get_icon_id("shield")
if entity.state == "armed_away":
color = rgb_dec565([223,76,30])
icon = get_icon_id("shield-lock")
@@ -294,15 +292,22 @@ class LuiPagesGen(object):
color = rgb_dec565([223,76,30])
icon = get_icon_id("shield-airplane")
if entity.state in ["arming", "pending"]:
color = rgb_dec565([243,179,0])
icon = get_icon_id("shield")
if entity.state == "triggered":
color = rgb_dec565([223,76,30])
icon = get_icon_id("bell-ring")
# add padding to arm buttons
arm_buttons = ""
for b in supported_modes:
arm_buttons += f",{b},{b}"
arm_buttons += f",{get_translation(self._locale, b)},{b}"
if len(supported_modes) < 4:
arm_buttons += ","*((4-len(supported_modes))*2)
command = f"entityUpd,{item}{arm_buttons},{icon},{color},0"
command = f"entityUpd,{item}{arm_buttons},{icon},{color},{numpad}"
self._send_mqtt_msg(command)
def render_page(self, page, send_page_type=True):
config = page.data
page_type = config["type"]