diff --git a/server/home-assistant/bathroom.nix b/server/home-assistant/bathroom.nix index 19e6b646..8d7d111b 100644 --- a/server/home-assistant/bathroom.nix +++ b/server/home-assistant/bathroom.nix @@ -1,30 +1,32 @@ -{ ... }: +{ lib, config, ... }: { - services.home-assistant.config = { - "automation" = [ - { - alias = "Towel Warmer Timer"; - trigger = { - type = "turned_on"; - device_id = "bf77f1611d1d9959e967b4e35ba5234c"; - entity_id = "b674ce8cc70a4d0c1bfba7c6946ab3e4"; - domain = "switch"; - trigger = "device"; - for = { - hours = 0; - minutes = 60; - seconds = 0; - }; - }; - action = [ - { - type = "turn_off"; + config = lib.mkIf config.server.home-assistant.enable { + services.home-assistant.config = { + "automation" = [ + { + alias = "Towel Warmer Timer"; + trigger = { + type = "turned_on"; device_id = "bf77f1611d1d9959e967b4e35ba5234c"; entity_id = "b674ce8cc70a4d0c1bfba7c6946ab3e4"; domain = "switch"; - } - ]; - } - ]; + trigger = "device"; + for = { + hours = 0; + minutes = 60; + seconds = 0; + }; + }; + action = [ + { + type = "turn_off"; + device_id = "bf77f1611d1d9959e967b4e35ba5234c"; + entity_id = "b674ce8cc70a4d0c1bfba7c6946ab3e4"; + domain = "switch"; + } + ]; + } + ]; + }; }; } diff --git a/server/home-assistant/heating.nix b/server/home-assistant/heating.nix index 822d717e..83cb9c54 100644 --- a/server/home-assistant/heating.nix +++ b/server/home-assistant/heating.nix @@ -1,16 +1,19 @@ -{...}: { - services.home-assistant.config.automation = [ - { - description = "Pause Heating when Window opens"; - alias = "Heating Pause"; - use_blueprint = { - path = "raffy-ops/hvac_pause.yaml"; - input = { - climate_device = "climate.shellyblutrv_286847ef7fc0"; - doors_windows = "binary_sensor.shelly_blu_door_window_3a5a_window"; - action_first = true; +{ lib, config, ... }: +{ + config = lib.mkIf config.server.home-assistant.enable { + services.home-assistant.config.automation = [ + { + description = "Pause Heating when Window opens"; + alias = "Heating Pause"; + use_blueprint = { + path = "raffy-ops/hvac_pause.yaml"; + input = { + climate_device = "climate.shellyblutrv_286847ef7fc0"; + doors_windows = "binary_sensor.shelly_blu_door_window_3a5a_window"; + action_first = true; + }; }; - }; - } - ]; + } + ]; + }; } diff --git a/server/home-assistant/lights.nix b/server/home-assistant/lights.nix index d93de989..28da3830 100644 --- a/server/home-assistant/lights.nix +++ b/server/home-assistant/lights.nix @@ -1,55 +1,58 @@ -{...}: { - services.home-assistant.config.automation = [ - { - alias = "Wake Up Light"; - description = "Turn on the light on alarm ringing"; - trigger = { +{ lib, config, ... }: +{ + config = lib.mkIf config.server.home-assistant.enable { + services.home-assistant.config.automation = [ + { + alias = "Wake Up Light"; + description = "Turn on the light on alarm ringing"; + trigger = { platform = "time"; at = "sensor.lilith_phone_next_alarm"; - }; - condition = []; - action = [ - { - action = "light.turn_on"; - metadata = {}; - data = { - transition = 3; - kelvin = 3000; - brightness_pct = 100; - }; - target = { - device_id = "7d40ebcac890a2743d7dc2a6dc4ca797"; - }; - } - ]; - mode = "single"; - } - { - alias = "Automatic Light Off"; - description = "Turn off the light after 15 minutes once Liv leaves the house"; - trigger = { - platform = "state"; - entity_id = "person.liv_benstem"; - from = "home"; - to = "not_home"; - for = { - hours = 0; - minutes = 10; - seconds = 0; }; - }; - condition = []; - action = [ - { - action = "light.turn_off"; - metadata = {}; - data = {}; - target = { - area_id = "bedroom"; + condition = [ ]; + action = [ + { + action = "light.turn_on"; + metadata = { }; + data = { + transition = 3; + kelvin = 3000; + brightness_pct = 100; + }; + target = { + device_id = "7d40ebcac890a2743d7dc2a6dc4ca797"; + }; + } + ]; + mode = "single"; + } + { + alias = "Automatic Light Off"; + description = "Turn off the light after 15 minutes once Liv leaves the house"; + trigger = { + platform = "state"; + entity_id = "person.liv_benstem"; + from = "home"; + to = "not_home"; + for = { + hours = 0; + minutes = 10; + seconds = 0; }; - } - ]; - mode = "single"; - } - ]; + }; + condition = [ ]; + action = [ + { + action = "light.turn_off"; + metadata = { }; + data = { }; + target = { + area_id = "bedroom"; + }; + } + ]; + mode = "single"; + } + ]; + }; } diff --git a/server/home-assistant/mosquitto.nix b/server/home-assistant/mosquitto.nix index 232a7c02..abb3d6e3 100644 --- a/server/home-assistant/mosquitto.nix +++ b/server/home-assistant/mosquitto.nix @@ -1,20 +1,23 @@ -{ sops, config, ...}: { +{ lib, config, ... }: +{ + config = lib.mkIf config.server.home-assistant.enable { - sops.secrets."home-assistant/mosquitto/hass" = {}; + sops.secrets."home-assistant/mosquitto/hass" = { }; - services.mosquitto = { - enable = true; - listeners = [ - { - address = "192.168.178.111"; - port = 1883; - users.hass = { - acl = [ "readwrite #" ]; - hashedPasswordFile = config.sops.secrets."home-assistant/mosquitto/hass".path; - }; - } - ]; + services.mosquitto = { + enable = true; + listeners = [ + { + address = "192.168.178.111"; + port = 1883; + users.hass = { + acl = [ "readwrite #" ]; + hashedPasswordFile = config.sops.secrets."home-assistant/mosquitto/hass".path; + }; + } + ]; + }; + + networking.firewall.allowedTCPPorts = [ 1883 ]; }; - - networking.firewall.allowedTCPPorts = [ 1883 ]; } diff --git a/server/home-assistant/wyoming.nix b/server/home-assistant/wyoming.nix deleted file mode 100644 index a58947e9..00000000 --- a/server/home-assistant/wyoming.nix +++ /dev/null @@ -1,19 +0,0 @@ -{...}: { - services.wyoming = { - piper.servers = { - alba = { - enable=true; - uri="tcp://localhost:12001"; - voice="en_GB-alba-medium"; - }; - }; - faster-whisper.servers = { - tiny = { - enable=true; - uri="tcp://localhost:12002"; - model="tiny-int8"; - language="en"; - }; - }; - }; -}