{ pkgs, config, lib, ... }: { services.homeAssistantConfig = { group.view_overview.entities = [ "media_player.kodi" ]; media_player = [{ platform = "kodi"; host = "127.0.0.1"; }]; shell_command = { start_kodi = "sudo ${pkgs.systemd}/bin/systemctl start display-manager"; stop_kodi = "sudo ${pkgs.systemd}/bin/systemctl stop display-manager"; }; automation = [ { alias = "turn kodi on once the tv is turned on"; trigger = { platform = "state"; entity_id = "group.tv"; from = "off"; to = "on"; for.seconds = 60; }; action = [{ service = "shell_command.start_kodi"; }]; } { alias = "turn off kodi on once the tv is turned off"; trigger = { platform = "state"; entity_id = "group.tv"; from = "on"; to = "off"; }; action = [{ service = "shell_command.stop_kodi"; }]; } ]; }; 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 ''; }