nixos-configs/devices/homie/modules/home-assistant/spotify.nix
matt1432 a4d2b936d9
All checks were successful
Discord / discord commits (push) Has been skipped
feat(hass): add PlayPlaylist voice command
2024-10-09 00:34:58 -04:00

72 lines
1.6 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 = {
PlayAlbum = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_album";
data = {
artist = "{{ artist }}";
album = "{{ album }}";
};
}
];
};
PlayArtist = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_artist";
data.artist = "{{ artist }}";
}
];
};
PlayPlaylist = {
async_action = "false";
action = [
{
service = "netdaemon.spotify_play_playlist";
data.playlist = "{{ playlist }}";
}
];
};
};
};
}