From 15f0b0e9b0a520d4ca59cc0c00481147909baf38 Mon Sep 17 00:00:00 2001 From: Tyler Starr Date: Sun, 3 Dec 2023 11:59:29 -0800 Subject: [PATCH] initial setup of HA with christmas lights --- provision/hosts/torus/configuration.nix | 5 +- .../torus/home-assistant/automations.nix | 50 +++++++++++++++++++ .../hosts/torus/home-assistant/default.nix | 26 ++++++++++ provision/hosts/torus/home-assistant/mqtt.nix | 15 ++++++ resources/tasmota/amysen_config | 1 + 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 provision/hosts/torus/home-assistant/automations.nix create mode 100644 provision/hosts/torus/home-assistant/default.nix create mode 100644 provision/hosts/torus/home-assistant/mqtt.nix create mode 100644 resources/tasmota/amysen_config diff --git a/provision/hosts/torus/configuration.nix b/provision/hosts/torus/configuration.nix index 5a9e1d9c..c6701441 100644 --- a/provision/hosts/torus/configuration.nix +++ b/provision/hosts/torus/configuration.nix @@ -8,6 +8,7 @@ ./obsidian-vault.nix ./share.nix ./rss.nix + ./home-assistant ]; nix = { @@ -117,8 +118,8 @@ "rss.tstarr.us" = (SSL // { locations."/".proxyPass = "http://localhost:8081/"; }); - "rss1.tstarr.us" = (SSL // { - locations."/".proxyPass = "http://localhost:8087/"; + "home.tstarr.us" = (SSL // { + locations."/".proxyPass = "http://localhost:8123/"; }); "media.tstarr.us" = (SSL // { locations."/".proxyPass = "http://localhost:8096/"; diff --git a/provision/hosts/torus/home-assistant/automations.nix b/provision/hosts/torus/home-assistant/automations.nix new file mode 100644 index 00000000..273c3933 --- /dev/null +++ b/provision/hosts/torus/home-assistant/automations.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, user, ... }: +{ + services.home-assistant.config = { + "automation manual" = [ + { + alias = "turn on christmas lights"; + trigger = { + platform = "time"; + at = "16:45"; + }; + action = [ + { + type = "turn_on"; + device_id = "32bf8baf1214391472566d4300c7d6fb"; + entity_id = "72c7694c3a3aed5d67499bfe0574346b"; + domain = "switch"; + } + { + type = "turn_on"; + device_id = "08db6bd9e7bf98d5bf1b08351b909c94"; + entity_id = "ecec82df2265c6b92c8474fe0c9fde6b"; + domain = "switch"; + } + ]; + } + { + alias = "turn off christmas lights"; + trigger = { + platform = "time"; + at = "23:59"; + }; + action = [ + { + type = "turn_off"; + device_id = "32bf8baf1214391472566d4300c7d6fb"; + entity_id = "72c7694c3a3aed5d67499bfe0574346b"; + domain = "switch"; + } + { + type = "turn_off"; + device_id = "08db6bd9e7bf98d5bf1b08351b909c94"; + entity_id = "ecec82df2265c6b92c8474fe0c9fde6b"; + domain = "switch"; + } + ]; + } + ]; + "automation ui" = "!include automations.yaml"; + }; +} diff --git a/provision/hosts/torus/home-assistant/default.nix b/provision/hosts/torus/home-assistant/default.nix new file mode 100644 index 00000000..4319bfde --- /dev/null +++ b/provision/hosts/torus/home-assistant/default.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, user, ... }: +{ + imports = [ + ./mqtt.nix + ./automations.nix + ]; + networking.firewall.allowedTCPPorts = [ 8123 ]; + networking.firewall.allowedUDPPorts = [ 8123 ]; + + services.home-assistant = { + enable = true; + extraComponents = [ + # Components required to complete the onboarding + "esphome" + "met" + "radio_browser" + "tasmota" + ]; + config = { + # Includes dependencies for a basic setup + # https://www.home-assistant.io/integrations/default_config/ + default_config = {}; + }; + }; + +} diff --git a/provision/hosts/torus/home-assistant/mqtt.nix b/provision/hosts/torus/home-assistant/mqtt.nix new file mode 100644 index 00000000..8aaab232 --- /dev/null +++ b/provision/hosts/torus/home-assistant/mqtt.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, user, ... }: +{ + networking.firewall.allowedTCPPorts = [ 1883 ]; + services.home-assistant.config.mqtt = { }; + + services.mosquitto = { + enable = true; + listeners = [{ + users.tstarr = { + acl = [ "readwrite #" ]; + hashedPassword = "$7$101$fWS64zbpdeUWd8fA$A31ESjDqooTB9BTYA9dvdU20Cwpxc3wmXfm7QLEJYZzd+UkbCVG1Ic7VsD9BBghka0WQZgkQczzag/t09BZ+5w=="; + }; + }]; + }; +} diff --git a/resources/tasmota/amysen_config b/resources/tasmota/amysen_config new file mode 100644 index 00000000..a794f13a --- /dev/null +++ b/resources/tasmota/amysen_config @@ -0,0 +1 @@ +{"NAME":"Amysen JSMWF02","GPIO":[0,17,0,0,0,0,0,0,0,56,21,0,0],"FLAG":0,"BASE":18}