From 93fa05acd8d4ca4c3197b4d80dc23bddad88cefa Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 10 May 2020 23:58:19 +0200 Subject: [PATCH] home-assistant: worked on kodi and wifi --- configs/pepe/home-assistant/kodi.nix | 85 ++++++------------- .../home-assistant/zigbee2mqtt/service.nix | 2 +- configs/pepe/kodi.nix | 8 +- configs/pepe/wifi-access-point.nix | 4 +- 4 files changed, 33 insertions(+), 66 deletions(-) diff --git a/configs/pepe/home-assistant/kodi.nix b/configs/pepe/home-assistant/kodi.nix index 619f82c..388a89e 100644 --- a/configs/pepe/home-assistant/kodi.nix +++ b/configs/pepe/home-assistant/kodi.nix @@ -7,71 +7,36 @@ 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"; + start_kodi = "sudo ${pkgs.systemd}/bin/systemctl start display-manager"; + stop_kodi = "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.seconds = 20; } - { - 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" "script.test_display" ]; + 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"; }]; + } + ]; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/service.nix b/configs/pepe/home-assistant/zigbee2mqtt/service.nix index 62ee4f8..b5cca78 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/service.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/service.nix @@ -60,7 +60,7 @@ in { 16 numbers between 0 and 255 see https://www.zigbee2mqtt.io/how_tos/how_to_secure_network.html ''; - example = [7 3 5 7 9 11 13 15 0 2 4 6 8 11 12 13]; + example = [ 7 3 5 7 9 11 13 15 0 2 4 6 8 11 12 13 ]; }; devices = mkOption { type = with types; attrs; diff --git a/configs/pepe/kodi.nix b/configs/pepe/kodi.nix index 180880e..646e92f 100644 --- a/configs/pepe/kodi.nix +++ b/configs/pepe/kodi.nix @@ -4,10 +4,10 @@ enable = true; autorun = false; videoDrivers = [ "intel" ]; - deviceSection = '' - Option "DRI" "2" - Option "TearFree" "true" - ''; + #deviceSection = '' + # Option "DRI" "2" + # Option "TearFree" "true" + #''; desktopManager = { kodi.enable = true; default = "kodi"; diff --git a/configs/pepe/wifi-access-point.nix b/configs/pepe/wifi-access-point.nix index f9952ae..a602201 100644 --- a/configs/pepe/wifi-access-point.nix +++ b/configs/pepe/wifi-access-point.nix @@ -1,7 +1,9 @@ { lib, pkgs, ... }: let - wifi = "wlp0s29u1u1"; + # you find this device using `ifconfig -a` or `ip link` + wifi = "wlp0s26u1u2"; + #wifi = "wlp3s0-ifb"; ipAddress = "10.23.45.1"; prefixLength = 24; servedAddressRange = "10.23.45.2,10.23.45.150,12h";