Skip to content

Commit

Permalink
Feature: quick action button press (hass-agent#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
amadeo-alex authored Jul 13, 2024
1 parent 6b474c2 commit 5082f67
Show file tree
Hide file tree
Showing 28 changed files with 191 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/HASS.Agent/HASS.Agent.Shared/Enums/HassAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
7 changes: 6 additions & 1 deletion src/HASS.Agent/HASS.Agent.Shared/Enums/HassDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3370,4 +3370,10 @@ Willst Du den Runtime Installer herunterladen?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Auslösen</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Knopf</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Presse</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3246,4 +3246,10 @@ Do you want to download the runtime installer?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Trigger</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Press</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Button</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3246,4 +3246,10 @@ Oculta, Maximizada, Minimizada, Normal y Desconocida.</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Desencadenar</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Botón</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Prensa</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3279,4 +3279,10 @@ Do you want to download the runtime installer?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Déclencher</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Knop</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Presse</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3268,4 +3268,10 @@ Wil je de runtime installatie downloaden?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Activering</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Knop</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Pers</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3356,4 +3356,10 @@ Czy chcesz pobrać plik instalacyjny?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Wyzwól</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Przycisk</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Naciśnij</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3293,4 +3293,10 @@ Deseja baixar o Microsoft WebView2 runtime?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Acionar</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Botão</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Imprensa</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3229,4 +3229,10 @@ Do you want to download the runtime installer?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Trigger</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Press</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Button</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3314,4 +3314,10 @@ Home Assistant.
<data name="HassAction_Trigger" xml:space="preserve">
<value>Вызывать</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Button</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Нажимать</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3395,4 +3395,10 @@ Ali želite prenesti runtime installer?</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Sprožilec</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Gumb</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Pritisnite</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2853,4 +2853,10 @@ Lütfen aracınız için credentialları sağlayın, HA Mosquitto eklentisini ku
<data name="HassAction_Trigger" xml:space="preserve">
<value>Tetiklemek</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Buton</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Basmak</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/HASS.Agent/HASS.Agent/HomeAssistant/HassApiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ internal static class HassApiManager
internal static List<string> CoverList = new();
internal static List<string> ClimateList = new();
internal static List<string> MediaPlayerList = new();
internal static List<string> ButtonList = new();

private static readonly string[] OnStates = { "on", "playing", "open", "opening" };
private static readonly string[] OffStates = { "off", "idle", "paused", "stopped", "closed", "closing" };
Expand Down Expand Up @@ -389,6 +390,7 @@ private static async Task LoadEntitiesAsync(bool clearCurrent = false)
CoverList.Clear();
ClimateList.Clear();
MediaPlayerList.Clear();
ButtonList.Clear();
}

try
Expand All @@ -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;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3522,4 +3522,10 @@ Muss unter „Konfiguration -&gt; Tray-Icon“ konfiguriert werden.</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Auslösen</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Knopf</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Presse</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3427,4 +3427,10 @@ Requires it to be configured in "Configuration -&gt; Tray Icon"</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Trigger</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Button</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Press</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3398,4 +3398,10 @@ Requiere que se configure en "Configuración -&gt; Icono de la bandeja"</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Desencadenar</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Botón</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Prensa</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3431,4 +3431,10 @@ Nécessite sa configuration dans « Configuration -&gt; Icône de la barre d'ét
<data name="HassAction_Trigger" xml:space="preserve">
<value>Déclencher</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Knop</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Presse</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3419,4 +3419,10 @@ Vereist dat het geconfigureerd is in "Configuratie -&gt; Tray Icon"</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Activering</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Knop</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Pers</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3508,4 +3508,10 @@ Wymaga konfiguracji w „Configuration -&gt; Tray Icon”</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Wyzwól</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Przycisk</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Naciśnij</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3444,4 +3444,10 @@ Requer que seja configurado em "Configuration -&gt; Tray Icon"</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Acionar</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Botão</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Imprensa</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3420,4 +3420,10 @@ Requires it to be configured in "Configuration -&gt; Tray Icon"</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Trigger</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Press</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Button</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3467,4 +3467,10 @@ Home Assistant.
<data name="HassAction_Trigger" xml:space="preserve">
<value>Вызывать</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Button</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Нажимать</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3547,4 +3547,10 @@ Zahteva, da je konfiguriran v "Konfiguracija -&gt; Ikona pladnja"</value>
<data name="HassAction_Trigger" xml:space="preserve">
<value>Sprožilec</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Gumb</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Pritisnite</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -3014,4 +3014,10 @@ Not: Uydu hizmetinde kullanılırsa kullanıcı alanı uygulamalarını algılam
<data name="HassAction_Trigger" xml:space="preserve">
<value>Tetiklemek</value>
</data>
<data name="HassDomain_Button" xml:space="preserve">
<value>Buton</value>
</data>
<data name="HassAction_Press" xml:space="preserve">
<value>Basmak</value>
</data>
</root>

0 comments on commit 5082f67

Please sign in to comment.