feat(hass): add android tv remote card

This commit is contained in:
matt1432 2024-10-23 00:30:24 -04:00
parent 6fd7f5ed48
commit d481c4be32
7 changed files with 233 additions and 3 deletions
devices/homie/modules/home-assistant
flake.lockflake.nixinputs.nix
legacyPackages/hass-components
default.nix
yamaha-soundbar

View file

@ -19,6 +19,7 @@
enable = true; enable = true;
extraComponents = [ extraComponents = [
"androidtv"
"androidtv_remote" "androidtv_remote"
"caldav" "caldav"
"cast" "cast"
@ -30,6 +31,13 @@
"yamaha_musiccast" "yamaha_musiccast"
]; ];
customComponents = builtins.attrValues {
inherit
(self.legacyPackages.${pkgs.system}.hass-components)
yamaha-soundbar
;
};
config = { config = {
homeassistant = { homeassistant = {
name = "Home"; name = "Home";
@ -40,6 +48,17 @@
external_url = "https://homie.nelim.org"; 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 # Proxy settings
http = { http = {
server_host = "0.0.0.0"; server_host = "0.0.0.0";

View file

@ -90,6 +90,7 @@ in {
inherit inherit
(pkgs.home-assistant-custom-lovelace-modules) (pkgs.home-assistant-custom-lovelace-modules)
card-mod card-mod
universal-remote-card
; ;
inherit inherit
@ -140,6 +141,166 @@ in {
"timer.assist_timer3" "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;
}
'';
}
]; ];
} }
]; ];

19
flake.lock generated
View file

@ -1719,7 +1719,8 @@
"tuya-local-src": "tuya-local-src", "tuya-local-src": "tuya-local-src",
"vimplugin-easytables-src": "vimplugin-easytables-src", "vimplugin-easytables-src": "vimplugin-easytables-src",
"vimplugin-ts-error-translator-src": "vimplugin-ts-error-translator-src", "vimplugin-ts-error-translator-src": "vimplugin-ts-error-translator-src",
"wakewords-src": "wakewords-src" "wakewords-src": "wakewords-src",
"yamaha-soundbar-src": "yamaha-soundbar-src"
} }
}, },
"scss-reset": { "scss-reset": {
@ -2104,6 +2105,22 @@
"repo": "xdg-desktop-portal-hyprland", "repo": "xdg-desktop-portal-hyprland",
"type": "github" "type": "github"
} }
},
"yamaha-soundbar-src": {
"flake": false,
"locked": {
"lastModified": 1720618370,
"narHash": "sha256-nVbWmzZZ7akqJGg/J5xBNgO2ky7iQgI0vDYRXCo6zR4=",
"owner": "osk2",
"repo": "yamaha-soundbar",
"rev": "ebb3949a31a9d8460aed38924ae3a311204a06a2",
"type": "github"
},
"original": {
"owner": "osk2",
"repo": "yamaha-soundbar",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -1,5 +1,4 @@
# Do not modify! This file is generated. # Do not modify! This file is generated.
{ {
inputs = { inputs = {
ags = { ags = {
@ -467,6 +466,12 @@
repo = "home-assistant-wakewords-collection"; repo = "home-assistant-wakewords-collection";
type = "github"; type = "github";
}; };
yamaha-soundbar-src = {
flake = false;
owner = "osk2";
repo = "yamaha-soundbar";
type = "github";
};
}; };
outputs = inputs: inputs.flakegen ./outputs.nix inputs; outputs = inputs: inputs.flakegen ./outputs.nix inputs;
} }

View file

@ -202,6 +202,11 @@ let
owner = "net-daemon"; owner = "net-daemon";
repo = "integration"; repo = "integration";
} }
{
owner = "osk2";
repo = "yamaha-soundbar";
}
### SpotifyPlus ### SpotifyPlus
{ {
name = "spotifyplus-src"; name = "spotifyplus-src";

View file

@ -13,4 +13,5 @@ in {
netdaemon = buildHassComponent ./netdaemon {}; netdaemon = buildHassComponent ./netdaemon {};
spotifyplus = import ./spotifyplus ({inherit buildHassComponent;} // inputs); spotifyplus = import ./spotifyplus ({inherit buildHassComponent;} // inputs);
tuya-local = buildHassComponent ./tuya-local {}; tuya-local = buildHassComponent ./tuya-local {};
yamaha-soundbar = buildHassComponent ./yamaha-soundbar {};
}) })

View file

@ -0,0 +1,22 @@
{
yamaha-soundbar-src,
buildHomeAssistantComponent,
python3Packages,
...
}: let
inherit (builtins) fromJSON readFile;
manifest = fromJSON (readFile "${yamaha-soundbar-src}/custom_components/yamaha_soundbar/manifest.json");
in
buildHomeAssistantComponent {
owner = "osk2";
inherit (manifest) domain version;
src = yamaha-soundbar-src;
propagatedBuildInputs = with python3Packages; [
async-upnp-client
chardet
validators
];
}