2024-10-05 02:57:07 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
self,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit (lib) getExe;
|
2024-10-07 15:15:29 -04:00
|
|
|
inherit (pkgs.writers) writeYAML;
|
2024-10-05 02:57:07 -04:00
|
|
|
in {
|
|
|
|
systemd.services.home-assistant.preStart = let
|
|
|
|
WorkingDirectory = "/var/lib/hass";
|
|
|
|
creds = config.sops.secrets.spotifyd.path;
|
2024-10-07 15:15:29 -04:00
|
|
|
spotify = writeYAML "assist_spotify.yaml" (import ./spotify-sentences.nix);
|
2024-10-05 02:57:07 -04:00
|
|
|
in
|
|
|
|
getExe (pkgs.writeShellApplication {
|
2024-10-07 15:15:29 -04:00
|
|
|
name = "spotify-files";
|
2024-10-05 02:57:07 -04:00
|
|
|
text = ''
|
2024-10-07 15:15:29 -04:00
|
|
|
mkdir -p ${WorkingDirectory}/custom_sentences/en
|
2024-10-08 02:07:05 -04:00
|
|
|
cp -f ${spotify} ${WorkingDirectory}/custom_sentences/en/assist_spotify.yaml
|
2024-10-05 02:57:07 -04:00
|
|
|
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"
|
|
|
|
];
|
2024-10-07 15:15:29 -04:00
|
|
|
|
|
|
|
config.intent_script = {
|
2024-10-09 00:34:58 -04:00
|
|
|
PlayAlbum = {
|
|
|
|
async_action = "false";
|
|
|
|
action = [
|
|
|
|
{
|
|
|
|
service = "netdaemon.spotify_play_album";
|
|
|
|
data = {
|
|
|
|
artist = "{{ artist }}";
|
|
|
|
album = "{{ album }}";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-10-07 15:15:29 -04:00
|
|
|
PlayArtist = {
|
|
|
|
async_action = "false";
|
|
|
|
action = [
|
|
|
|
{
|
|
|
|
service = "netdaemon.spotify_play_artist";
|
2024-10-08 02:07:05 -04:00
|
|
|
data.artist = "{{ artist }}";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-10-09 00:34:58 -04:00
|
|
|
PlayPlaylist = {
|
2024-10-08 02:07:05 -04:00
|
|
|
async_action = "false";
|
|
|
|
action = [
|
|
|
|
{
|
2024-10-09 00:34:58 -04:00
|
|
|
service = "netdaemon.spotify_play_playlist";
|
|
|
|
data.playlist = "{{ playlist }}";
|
2024-10-07 15:15:29 -04:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-10-09 11:01:53 -04:00
|
|
|
|
|
|
|
PlaySong = {
|
|
|
|
async_action = "false";
|
|
|
|
action = [
|
|
|
|
{
|
|
|
|
service = "netdaemon.spotify_play_song";
|
|
|
|
data = {
|
|
|
|
artist = "{{ artist }}";
|
|
|
|
song = "{{ song }}";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-10-07 15:15:29 -04:00
|
|
|
};
|
2024-10-05 02:57:07 -04:00
|
|
|
};
|
|
|
|
}
|