diff options
Diffstat (limited to 'nixos/machine')
-rw-r--r-- | nixos/machine/errol.nix | 9 | ||||
-rw-r--r-- | nixos/machine/hass/light.nix | 13 | ||||
-rw-r--r-- | nixos/machine/hass/sensors.nix | 19 | ||||
-rw-r--r-- | nixos/machine/spt-mox.nix | 155 |
4 files changed, 8 insertions, 188 deletions
diff --git a/nixos/machine/errol.nix b/nixos/machine/errol.nix index 835999a..70bc8cf 100644 --- a/nixos/machine/errol.nix +++ b/nixos/machine/errol.nix @@ -79,13 +79,18 @@ with lib; port = 1883; username = "homeassistant"; password = "!secret mqtt_password"; - sensor = import ./hass/sensors.nix; - light = import ./hass/light.nix; + sensor = import ../modules/home-assistant/sensors.nix; + light = import ../modules/home-assistant/light.nix; }; met = {}; default_config = {}; }; extraComponents = []; + package = pkgs.home-assistant.override { + extraPackages = pkgs: with pkgs; [ + securetar + ]; + }; }; }; diff --git a/nixos/machine/hass/light.nix b/nixos/machine/hass/light.nix deleted file mode 100644 index a9d158b..0000000 --- a/nixos/machine/hass/light.nix +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - name = "RGB Osvětlení"; - command_topic = "homeassistant/led-strip"; - brightness_scale = 100; - brightness_command_topic = "bigclown/node/power-controller:0/led-strip/-/brightness/set"; - #brightness_state_topic = "bigclown/node/power-controller:0/led-strip/-/brightness/set"; - rgb_command_template = ''"#{{"%02x" % red}}{{"%02x" % green}}{{"%02x" % blue}}"''; - rgb_command_topic = "bigclown/node/power-controller:0/led-strip/-/color/set"; - #rgb_value_template = ''{{int(value[2:4],16)}},{{int(value[5:7],16)}},{{int(value[8:10],16)}}''; - #rgb_state_topic = "bigclown/node/power-controller:0/led-strip/-/color/set"; - } -] diff --git a/nixos/machine/hass/sensors.nix b/nixos/machine/hass/sensors.nix deleted file mode 100644 index fadd4eb..0000000 --- a/nixos/machine/hass/sensors.nix +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - name = "Teplota"; - state_class = "measurement"; - state_topic = "bigclown/node/climate-monitor:0/thermometer/0:0/temperature"; - unit_of_measurement = "°C"; - } - { - name = "Vlhkost"; - state_class = "measurement"; - state_topic = "bigclown/node/climate-monitor:0/hygrometer/0:4/relative-humidity"; - unit_of_measurement = "%"; - } - { - name = "Osvětlení"; - state_class = "measurement"; - state_topic = "bigclown/node/climate-monitor:0/lux-meter/0:0/illuminance"; - } -] diff --git a/nixos/machine/spt-mox.nix b/nixos/machine/spt-mox.nix index 87d720f..57573ef 100644 --- a/nixos/machine/spt-mox.nix +++ b/nixos/machine/spt-mox.nix @@ -6,6 +6,7 @@ with lib; { config = { + cynerd.home-assistant = true; environment.systemPackages = with pkgs; [ mosquitto @@ -62,160 +63,6 @@ with lib; dhcpcd.allowInterfaces = [ "brlan" ]; }; - services.mosquitto = { - enable = true; - listeners = [ - { - users = { - cynerd = { - acl = ["readwrite #"]; - passwordFile = "/run/secrets/mosquitto.cynerd.pass"; - }; - bigclown = { - acl = ["readwrite bigclown/#"]; - passwordFile = "/run/secrets/mosquitto.bigclown.pass"; - }; - homeassistant = { - acl = [ - "readwrite bigclown/#" - "readwrite homeassistant/#" - ]; - passwordFile = "/run/secrets/mosquitto.homeassistant.pass"; - }; - }; - } - ]; - }; - networking.firewall.allowedTCPPorts = [1883]; - - services.bigclown = { - gateway = { - enable = true; - device = "/dev/ttyUSB0"; - environmentFile = "/run/secrets/bigclown.env"; - baseTopicPrefix = "bigclown/"; - mqtt = { - username = "bigclown"; - password = "@PASS_MQTT@"; - }; - }; - mqtt2influxdb = { - enable = true; - environmentFile = "/run/secrets/bigclown.env"; - mqtt = { - username = "bigclown"; - password = "@PASS_MQTT@"; - }; - influxdb = { - host = "cynerd.cz"; - database = "bigclown"; - username = "bigclown"; - password = "@PASS_INFLUXDB@"; - ssl = true; - verify_ssl = false; - }; - points = [ - { - measurement = "temperature"; - topic = "bigclown/node/+/thermometer/+/temperature"; - fields.value = "$.payload"; - tags = { - id = "$.topic[2]"; - channel = "$.topic[4]"; - }; - } - { - measurement = "relative-humidity"; - topic = "bigclown/node/+/hygrometer/+/relative-humidity"; - fields.value = "$.payload"; - tags = { - id = "$.topic[2]"; - channel = "$.topic[4]"; - }; - } - { - measurement = "illuminance"; - topic = "bigclown/node/+/lux-meter/0:0/illuminance"; - fields.value = "$.payload"; - tags = { - id = "$.topic[2]"; - }; - } - { - measurement = "pressure"; - topic = "bigclown/node/+/barometer/0:0/pressure"; - fields.value = "$.payload"; - tags = { - id = "$.topic[2]"; - }; - } - { - measurement = "voltage"; - topic = "bigclown/node/+/battery/+/voltage"; - fields.value = "$.payload"; - tags = { - id = "$.topic[2]"; - }; - } - { - measurement = "button"; - topic = "bigclown/node/+/push-button/+/event-count"; - fields.value = "$.payload"; - tags = { - id = "$.topic[2]"; - channel = "$.topic[4]"; - }; - } - ]; - }; - }; - - systemd.services.bigclown-leds = { - description = "Bigclown LEDs control"; - wantedBy = ["multi-user.target"]; - wants = ["mosquitto.service"]; - serviceConfig.ExecStart = "${pkgs.bigclown-leds}/bin/bigclown-leds /run/secrets/bigclown-leds.ini"; - }; - - services.home-assistant = { - enable = false; - openFirewall = true; - configDir = "/var/lib/hass"; - config = { - homeassistant = { - name = "SPT"; - latitude = "!secret latitude"; - longitude = "!secret longitude"; - elevation = "!secret elevation"; - time_zone = "Europe/Prague"; - country = "CZ"; - }; - http.server_port = 8808; - mqtt = { - broker = config.cynerd.hosts.spt.mox; - port = 1883; - username = "homeassistant"; - password = "!secret mqtt_password"; - sensor = import ./hass/sensors.nix; - light = import ./hass/light.nix; - }; - met = {}; - default_config = {}; - }; - extraComponents = []; - package = pkgs.home-assistant.override { - packageOverrides = (self: super: { - scapy = super.scapy.override { - withPlottingSupport = false; - }; - s3transfer = super.s3transfer.overridePythonAttrs (oldAttrs: { - dontUsePytestCheck = true; - dontUseSetuptoolsCheck = true; - }); - }); - }; - }; - }; } |