nixos-config/configs/porani/home-assistant/kodi.nix
Ingolf Wagner 54bab918d7
init
2019-10-24 02:24:33 +02:00

85 lines
2 KiB
Nix

{ pkgs, config, lib, ... }:
{
services.homeAssistantConfig = {
group.view_overview.entities = [
"media_player.kodi"
];
media_player = [
{
platform = "kodi";
host = "127.0.0.1";
turn_on_action.service = "script.watch_tv";
turn_off_action.service = "script.stop_watch_tv";
}
];
shell_command = {
start_display = "sudo ${pkgs.systemd}/bin/systemctl start display-manager";
stop_display = "sudo ${pkgs.systemd}/bin/systemctl stop display-manager";
};
script = {
turn_all_off.sequence = [
# todo : use the shell_command here
{
alias = "turn off tv";
service = "switch.turn_off";
data.entity_id = "group.tv";
}
{
alias = "stop kodi";
service = "shell_command.stop_display";
}
];
test_display.sequence = [
{ service = "shell_command.start_display"; }
{ delay.seconds = 20; }
{ service = "shell_command.stop_display"; }
];
watch_tv = {
alias = "Watch TV";
sequence = [
{
alias = "turn on tv";
service = "switch.turn_on";
data.entity_id = "group.tv";
}
{ delay.minutes = 1;}
{
alias = "start kodi";
service = "shell_command.start_display";
}
];
};
stop_watch_tv = {
alias = "Stop TV";
sequence = [
{
alias = "turn off tv";
service = "switch.turn_off";
data.entity_id = "group.tv";
}
{
alias = "stop kodi";
service = "shell_command.stop_display";
}
];
};
};
group.tv.entities = [ "script.watch_tv" "script.stop_watch_tv" ];
};
security.sudo.extraConfig = ''
hass ALL= (root) NOPASSWD: ${pkgs.systemd}/bin/systemctl start display-manager
hass ALL= (root) NOPASSWD: ${pkgs.systemd}/bin/systemctl stop display-manager
'';
}