nixos-configs/devices/homie/modules/home-assistant/spotify.nix
matt1432 98c27b1051
All checks were successful
Discord / discord commits (push) Has been skipped
feat(hass): add PlayAlbum voice command
2024-10-08 02:07:05 -04:00

62 lines
1.4 KiB
Nix

{
config,
lib,
pkgs,
self,
...
}: let
inherit (lib) getExe;
inherit (pkgs.writers) writeYAML;
in {
systemd.services.home-assistant.preStart = let
WorkingDirectory = "/var/lib/hass";
creds = config.sops.secrets.spotifyd.path;
spotify = writeYAML "assist_spotify.yaml" (import ./spotify-sentences.nix);
in
getExe (pkgs.writeShellApplication {
name = "spotify-files";
text = ''
mkdir -p ${WorkingDirectory}/custom_sentences/en
cp -f ${spotify} ${WorkingDirectory}/custom_sentences/en/assist_spotify.yaml
cp -f ${creds} ${WorkingDirectory}/.storage/SpotifyWebApiPython_librespot_credentials.json
'';
});
services.home-assistant = {
customComponents = builtins.attrValues {
inherit
(self.legacyPackages.${pkgs.system}.hass-components)
spotifyplus
;
};
extraComponents = [
"spotify"
];
config.intent_script = {
PlayArtist = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_artist";
data.artist = "{{ artist }}";
}
];
};
PlayAlbum = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_album";
data = {
artist = "{{ artist }}";
album = "{{ album }}";
};
}
];
};
};
};
}