From d481c4be3232994b7dd0b099ca9664df76e2ebf0 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 23 Oct 2024 00:30:24 -0400 Subject: [PATCH] feat(hass): add android tv remote card --- .../homie/modules/home-assistant/default.nix | 19 +++ .../homie/modules/home-assistant/frontend.nix | 161 ++++++++++++++++++ flake.lock | Bin 57166 -> 57672 bytes flake.nix | Bin 11149 -> 11282 bytes inputs.nix | 5 + legacyPackages/hass-components/default.nix | 1 + .../yamaha-soundbar/default.nix | 22 +++ 7 files changed, 208 insertions(+) create mode 100644 legacyPackages/hass-components/yamaha-soundbar/default.nix diff --git a/devices/homie/modules/home-assistant/default.nix b/devices/homie/modules/home-assistant/default.nix index d2139335..9a364353 100644 --- a/devices/homie/modules/home-assistant/default.nix +++ b/devices/homie/modules/home-assistant/default.nix @@ -19,6 +19,7 @@ enable = true; extraComponents = [ + "androidtv" "androidtv_remote" "caldav" "cast" @@ -30,6 +31,13 @@ "yamaha_musiccast" ]; + customComponents = builtins.attrValues { + inherit + (self.legacyPackages.${pkgs.system}.hass-components) + yamaha-soundbar + ; + }; + config = { homeassistant = { name = "Home"; @@ -40,6 +48,17 @@ external_url = "https://homie.nelim.org"; }; + media_player = [ + { + platform = "yamaha_soundbar"; + host = "192.168.0.96"; + name = "Living Room Speaker"; + sources = { + HDMI = "TV"; + }; + } + ]; + # Proxy settings http = { server_host = "0.0.0.0"; diff --git a/devices/homie/modules/home-assistant/frontend.nix b/devices/homie/modules/home-assistant/frontend.nix index 2b9a93f8..8907d413 100644 --- a/devices/homie/modules/home-assistant/frontend.nix +++ b/devices/homie/modules/home-assistant/frontend.nix @@ -90,6 +90,7 @@ in { inherit (pkgs.home-assistant-custom-lovelace-modules) card-mod + universal-remote-card ; inherit @@ -140,6 +141,166 @@ in { "timer.assist_timer3" ]; } + + { + type = "custom:android-tv-card"; + + media_player_id = "media_player.living_room_speaker"; + keyboard_id = "remote.android_tv_192_168_0_106"; + remote_id = "remote.onn_4k_streaming_box"; + + rows = [ + "navigation_buttons" + [null "slider" null] + [null] + ["jellyfin" "home" "back" "keyboard"] + [null] + ]; + + custom_actions = [ + { + name = "center"; + type = "button"; + icon = "mdi:checkbox-blank-circle"; + + styles = '' + :host { + --icon-color: rgb(94, 94, 94); + --size: 200px; + background: rgb(31, 31, 31); + border-radius: 200px; + margin: -70px; + padding: 70px; + } + ''; + + tap_action = { + action = "key"; + key = "DPAD_CENTER"; + }; + } + + { + name = "up"; + type = "button"; + icon = "mdi:chevron-up"; + + styles = '' + :host { + --icon-color: rgb(197, 199, 197); + z-index: 2; + top: 25px; + height: 90px; + width: 300px; + } + ''; + + hold_action = {action = "repeat";}; + tap_action = { + action = "key"; + key = "DPAD_UP"; + }; + } + + { + name = "down"; + type = "button"; + icon = "mdi:chevron-down"; + + styles = '' + :host { + --icon-color: rgb(197, 199, 197); + z-index: 2; + bottom: 25px; + height: 90px; + width: 300px; + } + ''; + + hold_action = {action = "repeat";}; + tap_action = { + action = "key"; + key = "DPAD_DOWN"; + }; + } + + { + name = "left"; + type = "button"; + icon = "mdi:chevron-left"; + + styles = '' + :host { + --icon-color: rgb(197, 199, 197); + z-index: 2; + left: 30px; + height: 170px; + width: 90px; + } + ''; + + hold_action = {action = "repeat";}; + tap_action = { + action = "key"; + key = "DPAD_LEFT"; + }; + } + + { + name = "right"; + type = "button"; + icon = "mdi:chevron-right"; + + styles = '' + :host { + --icon-color: rgb(197, 199, 197); + z-index: 2; + right: 30px; + height: 170px; + width: 90px; + } + ''; + + hold_action = {action = "repeat";}; + tap_action = { + action = "key"; + key = "DPAD_RIGHT"; + }; + } + + { + name = "slider"; + type = "slider"; + icon = "mdi:volume-high"; + + range = [0 1]; + step = 0.01; + + tap_action = { + action = "perform-action"; + perform_action = "media_player.volume_set"; + data = { + volume_level = "{{ value | float }}"; + }; + }; + value_attribute = "volume_level"; + } + ]; + + styles = '' + #row-1 { + justify-content: center; + } + + #row-2 { + justify-content: center; + } + + #row-3 { + justify-content: center; + } + ''; + } ]; } ]; diff --git a/flake.lock b/flake.lock index 98689a69a8e5f93b7ba2e57a33821c4ab15e60e5..ae08525807a5a783afdfc8869ba4ba734873326e 100644 GIT binary patch delta 260 zcmX@NkNLzQ<_+h!n(A;VK!H+aVs2taqHb}1XVi0yg2vA9spxe!A5` zbFzXMJ3pGf$rrBruo;*cS{R#8R$L&bl^2#2o?8_aWuBN_=;fZS?`2xyMhQ_qR8uE!3=vUJO-eGhG_g!HHcYfku`n?+ sNK8#Jwy-oZNlY~c3K|+2m?RpQB~E5^Q<;20Py?4y4=-pn^#A|> delta 18 acmX?ci22+;<_+h!Zf4yUra4*up(X%a+6ejp diff --git a/flake.nix b/flake.nix index 5b56025036699a5d498a819ce6be357400e811b7..3e9b48c0ffb704f0d4232e88dd7b8240ff527788 100644 GIT binary patch delta 78 zcmeATpA<1cbEB53wxEJSWnyk(Mxt(UeraAxQex5MjjX!L`Ni2rO4eKoU{I7=kgs5? SpoFS$vY?{MWPfctMlJyIMHpQG delta 14 VcmbOf(HlNNbEAfu_T