From 5082f67435def0730f51a4e600482beb322ea991 Mon Sep 17 00:00:00 2001 From: amadeo-alex <68441479+amadeo-alex@users.noreply.github.com> Date: Sat, 13 Jul 2024 12:38:48 +0200 Subject: [PATCH] Feature: quick action button press (#126) https://github.com/hass-agent/HASS.Agent/pull/126 --- .../HASS.Agent.Shared/Enums/HassAction.cs | 7 ++++++- .../HASS.Agent.Shared/Enums/HassDomain.cs | 7 ++++++- .../Localization/Languages.Designer.cs | 18 ++++++++++++++++++ .../Resources/Localization/Languages.de.resx | 6 ++++++ .../Resources/Localization/Languages.en.resx | 6 ++++++ .../Resources/Localization/Languages.es.resx | 6 ++++++ .../Resources/Localization/Languages.fr.resx | 6 ++++++ .../Resources/Localization/Languages.nl.resx | 6 ++++++ .../Resources/Localization/Languages.pl.resx | 6 ++++++ .../Localization/Languages.pt-br.resx | 6 ++++++ .../Resources/Localization/Languages.resx | 6 ++++++ .../Resources/Localization/Languages.ru.resx | 6 ++++++ .../Resources/Localization/Languages.sl.resx | 6 ++++++ .../Resources/Localization/Languages.tr.resx | 6 ++++++ .../Forms/QuickActions/QuickActionsMod.cs | 8 ++++++++ .../HASS.Agent/HomeAssistant/HassApiManager.cs | 3 +++ .../Localization/Languages.Designer.cs | 18 ++++++++++++++++++ .../Resources/Localization/Languages.de.resx | 6 ++++++ .../Resources/Localization/Languages.en.resx | 6 ++++++ .../Resources/Localization/Languages.es.resx | 6 ++++++ .../Resources/Localization/Languages.fr.resx | 6 ++++++ .../Resources/Localization/Languages.nl.resx | 6 ++++++ .../Resources/Localization/Languages.pl.resx | 6 ++++++ .../Localization/Languages.pt-br.resx | 6 ++++++ .../Resources/Localization/Languages.resx | 6 ++++++ .../Resources/Localization/Languages.ru.resx | 6 ++++++ .../Resources/Localization/Languages.sl.resx | 6 ++++++ .../Resources/Localization/Languages.tr.resx | 6 ++++++ 28 files changed, 191 insertions(+), 2 deletions(-) diff --git a/src/HASS.Agent/HASS.Agent.Shared/Enums/HassAction.cs b/src/HASS.Agent/HASS.Agent.Shared/Enums/HassAction.cs index cf0f6b0a..6bead640 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Enums/HassAction.cs +++ b/src/HASS.Agent/HASS.Agent.Shared/Enums/HassAction.cs @@ -50,6 +50,11 @@ public enum HassAction [LocalizedDescription("HassAction_Trigger", typeof(Languages))] [Category("trigger")] [EnumMember(Value = "Trigger")] - Trigger + Trigger, + + [LocalizedDescription("HassAction_Press", typeof(Languages))] + [Category("press")] + [EnumMember(Value = "Press")] + Press } } \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Enums/HassDomain.cs b/src/HASS.Agent/HASS.Agent.Shared/Enums/HassDomain.cs index 2d153255..4b453b34 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Enums/HassDomain.cs +++ b/src/HASS.Agent/HASS.Agent.Shared/Enums/HassDomain.cs @@ -57,6 +57,11 @@ public enum HassDomain [LocalizedDescription("HassDomain_Switch", typeof(Languages))] [Category("switch")] [EnumMember(Value = "Switch")] - Switch + Switch, + + [LocalizedDescription("HassDomain_Button", typeof(Languages))] + [Category("button")] + [EnumMember(Value = "Button")] + Button } } \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.Designer.cs b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.Designer.cs index 4faf9516..931858fa 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.Designer.cs +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.Designer.cs @@ -3362,6 +3362,15 @@ internal static string HassAction_Play { } } + /// + /// Looks up a localized string similar to Press. + /// + internal static string HassAction_Press { + get { + return ResourceManager.GetString("HassAction_Press", resourceCulture); + } + } + /// /// Looks up a localized string similar to Stop. /// @@ -3479,6 +3488,15 @@ internal static string HassDomain_Automation { } } + /// + /// Looks up a localized string similar to Button. + /// + internal static string HassDomain_Button { + get { + return ResourceManager.GetString("HassDomain_Button", resourceCulture); + } + } + /// /// Looks up a localized string similar to Climate. /// diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.de.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.de.resx index b38b81b2..c5179acd 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.de.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.de.resx @@ -3370,4 +3370,10 @@ Willst Du den Runtime Installer herunterladen? Auslösen + + Knopf + + + Presse + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.en.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.en.resx index 7e73bd49..f881bf80 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.en.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.en.resx @@ -3246,4 +3246,10 @@ Do you want to download the runtime installer? Trigger + + Press + + + Button + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.es.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.es.resx index 0ae04d4f..2ea0d91a 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.es.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.es.resx @@ -3246,4 +3246,10 @@ Oculta, Maximizada, Minimizada, Normal y Desconocida. Desencadenar + + Botón + + + Prensa + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.fr.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.fr.resx index a4b1bac5..27c3ec38 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.fr.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.fr.resx @@ -3279,4 +3279,10 @@ Do you want to download the runtime installer? Déclencher + + Knop + + + Presse + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.nl.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.nl.resx index 787d2fe9..3a9871c4 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.nl.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.nl.resx @@ -3268,4 +3268,10 @@ Wil je de runtime installatie downloaden? Activering + + Knop + + + Pers + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pl.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pl.resx index 08a6a802..6947c51d 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pl.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pl.resx @@ -3356,4 +3356,10 @@ Czy chcesz pobrać plik instalacyjny? Wyzwól + + Przycisk + + + Naciśnij + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pt-br.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pt-br.resx index c2a18493..a7b67ecb 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pt-br.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.pt-br.resx @@ -3293,4 +3293,10 @@ Deseja baixar o Microsoft WebView2 runtime? Acionar + + Botão + + + Imprensa + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.resx index eb13eb78..8fc95014 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.resx @@ -3229,4 +3229,10 @@ Do you want to download the runtime installer? Trigger + + Press + + + Button + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.ru.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.ru.resx index f731ff08..6f5d7c6e 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.ru.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.ru.resx @@ -3314,4 +3314,10 @@ Home Assistant. Вызывать + + Button + + + Нажимать + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.sl.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.sl.resx index 7de61d8e..1edd421c 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.sl.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.sl.resx @@ -3395,4 +3395,10 @@ Ali želite prenesti runtime installer? Sprožilec + + Gumb + + + Pritisnite + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.tr.resx b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.tr.resx index 703db654..28956a1c 100644 --- a/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.tr.resx +++ b/src/HASS.Agent/HASS.Agent.Shared/Resources/Localization/Languages.tr.resx @@ -2853,4 +2853,10 @@ Lütfen aracınız için credentialları sağlayın, HA Mosquitto eklentisini ku Tetiklemek + + Buton + + + Basmak + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Forms/QuickActions/QuickActionsMod.cs b/src/HASS.Agent/HASS.Agent/Forms/QuickActions/QuickActionsMod.cs index 827c5c06..dcb776fb 100644 --- a/src/HASS.Agent/HASS.Agent/Forms/QuickActions/QuickActionsMod.cs +++ b/src/HASS.Agent/HASS.Agent/Forms/QuickActions/QuickActionsMod.cs @@ -388,6 +388,14 @@ private void LoadEntityList() CbEntity.Items.Add(item.EntityName); } break; + + case HassDomain.Button: + foreach (var item in HassApiManager.ButtonList) + { + CbEntity.AutoCompleteCustomSource.Add(item); + CbEntity.Items.Add(item); + } + break; } } diff --git a/src/HASS.Agent/HASS.Agent/HomeAssistant/HassApiManager.cs b/src/HASS.Agent/HASS.Agent/HomeAssistant/HassApiManager.cs index 524e6a4d..36a49af8 100644 --- a/src/HASS.Agent/HASS.Agent/HomeAssistant/HassApiManager.cs +++ b/src/HASS.Agent/HASS.Agent/HomeAssistant/HassApiManager.cs @@ -43,6 +43,7 @@ internal static class HassApiManager internal static List CoverList = new(); internal static List ClimateList = new(); internal static List MediaPlayerList = new(); + internal static List ButtonList = new(); private static readonly string[] OnStates = { "on", "playing", "open", "opening" }; private static readonly string[] OffStates = { "off", "idle", "paused", "stopped", "closed", "closing" }; @@ -389,6 +390,7 @@ private static async Task LoadEntitiesAsync(bool clearCurrent = false) CoverList.Clear(); ClimateList.Clear(); MediaPlayerList.Clear(); + ButtonList.Clear(); } try @@ -402,6 +404,7 @@ private static async Task LoadEntitiesAsync(bool clearCurrent = false) await LoadDomain("cover", CoverList); await LoadDomain("climate", ClimateList); await LoadDomain("media_player", MediaPlayerList); + await LoadDomain("button", ButtonList); if (ManagerStatus != HassManagerStatus.Failed) return; diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.Designer.cs b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.Designer.cs index ea0b00cd..269df973 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.Designer.cs +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.Designer.cs @@ -3671,6 +3671,15 @@ internal static string HassAction_Play { } } + /// + /// Looks up a localized string similar to Press. + /// + internal static string HassAction_Press { + get { + return ResourceManager.GetString("HassAction_Press", resourceCulture); + } + } + /// /// Looks up a localized string similar to Stop. /// @@ -3788,6 +3797,15 @@ internal static string HassDomain_Automation { } } + /// + /// Looks up a localized string similar to Button. + /// + internal static string HassDomain_Button { + get { + return ResourceManager.GetString("HassDomain_Button", resourceCulture); + } + } + /// /// Looks up a localized string similar to Climate. /// diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.de.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.de.resx index e1737ea8..63a460db 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.de.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.de.resx @@ -3522,4 +3522,10 @@ Muss unter „Konfiguration -> Tray-Icon“ konfiguriert werden. Auslösen + + Knopf + + + Presse + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.en.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.en.resx index 615a5750..8dc6f1b7 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.en.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.en.resx @@ -3427,4 +3427,10 @@ Requires it to be configured in "Configuration -> Tray Icon" Trigger + + Button + + + Press + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.es.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.es.resx index 7a8fa344..16b9e7d7 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.es.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.es.resx @@ -3398,4 +3398,10 @@ Requiere que se configure en "Configuración -> Icono de la bandeja" Desencadenar + + Botón + + + Prensa + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.fr.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.fr.resx index bbf2e98c..1bfdf5df 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.fr.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.fr.resx @@ -3431,4 +3431,10 @@ Nécessite sa configuration dans « Configuration -> Icône de la barre d'ét Déclencher + + Knop + + + Presse + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.nl.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.nl.resx index 8d767c18..ea161750 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.nl.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.nl.resx @@ -3419,4 +3419,10 @@ Vereist dat het geconfigureerd is in "Configuratie -> Tray Icon" Activering + + Knop + + + Pers + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pl.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pl.resx index 4326d1e4..b8a5706d 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pl.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pl.resx @@ -3508,4 +3508,10 @@ Wymaga konfiguracji w „Configuration -> Tray Icon” Wyzwól + + Przycisk + + + Naciśnij + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pt-br.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pt-br.resx index 535978b8..f171b0c2 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pt-br.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.pt-br.resx @@ -3444,4 +3444,10 @@ Requer que seja configurado em "Configuration -> Tray Icon" Acionar + + Botão + + + Imprensa + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.resx index 16c55408..da531004 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.resx @@ -3420,4 +3420,10 @@ Requires it to be configured in "Configuration -> Tray Icon" Trigger + + Press + + + Button + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.ru.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.ru.resx index 20e97fb9..24b2bb4f 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.ru.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.ru.resx @@ -3467,4 +3467,10 @@ Home Assistant. Вызывать + + Button + + + Нажимать + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.sl.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.sl.resx index 5057bb6e..0c0728a7 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.sl.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.sl.resx @@ -3547,4 +3547,10 @@ Zahteva, da je konfiguriran v "Konfiguracija -> Ikona pladnja" Sprožilec + + Gumb + + + Pritisnite + \ No newline at end of file diff --git a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.tr.resx b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.tr.resx index f2da35f2..e1d3413b 100644 --- a/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.tr.resx +++ b/src/HASS.Agent/HASS.Agent/Resources/Localization/Languages.tr.resx @@ -3014,4 +3014,10 @@ Not: Uydu hizmetinde kullanılırsa kullanıcı alanı uygulamalarını algılam Tetiklemek + + Buton + + + Basmak + \ No newline at end of file