feat(hass): add android tv remote card
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-10-23 00:30:24 -04:00
parent 6fd7f5ed48
commit d481c4be32
7 changed files with 208 additions and 0 deletions

View file

@ -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";

View file

@ -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;
}
'';
}
];
}
];

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

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

View file

@ -13,4 +13,5 @@ in {
netdaemon = buildHassComponent ./netdaemon {};
spotifyplus = import ./spotifyplus ({inherit buildHassComponent;} // inputs);
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
];
}