nixos-configs/devices/homie/modules/home-assistant/spotify.nix
matt1432 eb5f04096e
All checks were successful
Discord / discord commits (push) Has been skipped
feat(hass): use ha-fallback with custom sentences
2024-10-07 15:15:29 -04:00

49 lines
1.1 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
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.criteria = "{{ artist }}";
}
];
};
};
};
}