From 4546840c0711f63a9e14efb8aafe46c58c7e3cc9 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Thu, 30 Jan 2025 20:52:22 -0800 Subject: [PATCH] rpi: remove configuration --- hosts/rpi/README.md | 132 ---- hosts/rpi/default.nix | 44 -- hosts/rpi/disko.nix | 65 -- hosts/rpi/hardware-configuration.nix | 28 - hosts/rpi/services/adguard.nix | 29 - hosts/rpi/services/caddy.nix | 24 - hosts/rpi/services/default.nix | 7 - hosts/rpi/services/home-assistant/abode.nix | 145 ----- hosts/rpi/services/home-assistant/backup.nix | 14 - hosts/rpi/services/home-assistant/blinds.nix | 186 ------ hosts/rpi/services/home-assistant/cloud.nix | 8 - hosts/rpi/services/home-assistant/default.nix | 93 --- hosts/rpi/services/home-assistant/esphome.nix | 13 - hosts/rpi/services/home-assistant/hvac.nix | 65 -- hosts/rpi/services/home-assistant/leak.nix | 31 - hosts/rpi/services/home-assistant/lights.nix | 127 ---- hosts/rpi/services/home-assistant/miele.nix | 49 -- hosts/rpi/services/home-assistant/mqtt.nix | 608 ------------------ hosts/rpi/services/home-assistant/notify.nix | 14 - hosts/rpi/services/home-assistant/people.nix | 72 --- .../rpi/services/home-assistant/recorder.nix | 6 - hosts/rpi/services/home-assistant/sonos.nix | 17 - hosts/rpi/services/home-assistant/unifi.nix | 44 -- .../home-assistant/waste-collection.nix | 45 -- hosts/rpi/services/home-assistant/weather.nix | 30 - 25 files changed, 1896 deletions(-) delete mode 100644 hosts/rpi/README.md delete mode 100644 hosts/rpi/default.nix delete mode 100644 hosts/rpi/disko.nix delete mode 100644 hosts/rpi/hardware-configuration.nix delete mode 100644 hosts/rpi/services/adguard.nix delete mode 100644 hosts/rpi/services/caddy.nix delete mode 100644 hosts/rpi/services/default.nix delete mode 100644 hosts/rpi/services/home-assistant/abode.nix delete mode 100644 hosts/rpi/services/home-assistant/backup.nix delete mode 100644 hosts/rpi/services/home-assistant/blinds.nix delete mode 100644 hosts/rpi/services/home-assistant/cloud.nix delete mode 100644 hosts/rpi/services/home-assistant/default.nix delete mode 100644 hosts/rpi/services/home-assistant/esphome.nix delete mode 100644 hosts/rpi/services/home-assistant/hvac.nix delete mode 100644 hosts/rpi/services/home-assistant/leak.nix delete mode 100644 hosts/rpi/services/home-assistant/lights.nix delete mode 100644 hosts/rpi/services/home-assistant/miele.nix delete mode 100644 hosts/rpi/services/home-assistant/mqtt.nix delete mode 100644 hosts/rpi/services/home-assistant/notify.nix delete mode 100644 hosts/rpi/services/home-assistant/people.nix delete mode 100644 hosts/rpi/services/home-assistant/recorder.nix delete mode 100644 hosts/rpi/services/home-assistant/sonos.nix delete mode 100644 hosts/rpi/services/home-assistant/unifi.nix delete mode 100644 hosts/rpi/services/home-assistant/waste-collection.nix delete mode 100644 hosts/rpi/services/home-assistant/weather.nix diff --git a/hosts/rpi/README.md b/hosts/rpi/README.md deleted file mode 100644 index 3d62cf1..0000000 --- a/hosts/rpi/README.md +++ /dev/null @@ -1,132 +0,0 @@ -# Raspberry Pi 4 - -This is a condensed and modified version of [the installation guide on nix.dev][1] for my specific setup. - -## Installation - -### Prerequisites - -The first part of the installation is to flash an SD card with a NixOS image. - -> [!NOTE] -> If you're using Windows, you'll need to use the [Raspberry Pi Imager][2] - -```bash -curl -Lo nixos-sd-image-aarch64.img.zst https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image.aarch64-linux/latest/download-by-type/file/sd-image -zstd -d nixos-sd-image-aarch64.img.zst -sudo dd if=nixos-sd-image-aarch64.img of=/dev/sdX bs=4096 conv=fsync status=progress -``` - -Once the image is flashed, you can move the SD card to the Raspberry Pi and boot. - -### First boot - -> [!IMPORTANT] -> Run `sudo -i` to get a root shell. -> Otherwise, you'll need to prefix all commands with `sudo`. - -### Getting an internet connection - -If you're using a wired connection, you can skip this step. - -```bash -wpa_supplicant -B -i wlan0 -c <(wpa_passphrase "SSID" "password") -``` - -Verify that you have an IP address: - -```bash -ip a -``` - -### Updating the firmware - -The firmware on the SD card is likely out of date, so we need to update it: - -```bash -nix-shell -p raspberrypi-eeprom -mount /dev/disk/by-label/FIRMWARE /mnt -BOOTFS=/mnt FIRMWARE_RELEASE_STATUS=stable rpi-eeprom-update -d -a -``` - -### Installing NixOS - -Set the hostname: - -```bash -hostname rpi -``` - -Clone the nix-config repo: - -```bash -nix-shell -p git -git clone https://github.com/JamieMagee/nix-config.git -``` - -Start a nix-shell: - -```bash -cd nix-config -nix-shell -``` - -Rebuild the system configuration: - -```bash -nixos-rebuild boot --flake . -``` - -Then set the password for the `root` user and reboot: - -```bash -passwd -reboot now -``` - -### Home-manager - -Login with the `root` user then set the password for the `jamie` user: - -```bash -passwd jamie -``` - -Logout and login with the `jamie` user. -Create the home-manager directory and remove the default fish config: - -```bash -mkdir -p ~/.local/state/nix/profiles -rm ~/.config/fish/config.fish -``` - -Clone the nix-config repository again: - -```bash -git clone https://github.com/JamieMagee/nix-config.git -``` - -Start a nix-shell: - -```bash -cd nix-config -nix-shell -``` - -Then install the home-manager configuration - -```bash -home-manager --flake . switch -``` - -Finally, login with tailscale: - -```bash -tailscale up --ssh -``` - -And disable the key expiry from the [Tailscale admin console][3] - -[1]: https://nix.dev/tutorials/nixos/installing-nixos-on-a-raspberry-pi -[2]: https://www.raspberrypi.com/software/ -[3]: https://login.tailscale.com/admin/machines diff --git a/hosts/rpi/default.nix b/hosts/rpi/default.nix deleted file mode 100644 index abd421b..0000000 --- a/hosts/rpi/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ inputs, ... }: -{ - imports = [ - inputs.hardware.nixosModules.raspberry-pi-4 - - ./hardware-configuration.nix - - ../common/global - ../common/users/jamie.nix - - ../common/optional/audit.nix - ../common/optional/earlyoom.nix - ../common/optional/vscode-server.nix - - ./services - ]; - - networking = { - hostName = "rpi"; - defaultGateway = { - address = "192.168.1.1"; - interface = "eth0"; - }; - interfaces.eth0 = { - wakeOnLan.enable = true; - ipv4.addresses = [ - { - address = "192.168.1.2"; - prefixLength = 24; - } - ]; - ipv6.addresses = [ - { - address = "fd63:e339:d9fc::2"; - prefixLength = 64; - } - ]; - }; - }; - - hardware.bluetooth.enable = true; - - system.stateVersion = "23.11"; -} diff --git a/hosts/rpi/disko.nix b/hosts/rpi/disko.nix deleted file mode 100644 index edbb69d..0000000 --- a/hosts/rpi/disko.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ - disko.devices = { - disk = { - sd-card = { - type = "disk"; - device = "/dev/mmcblk1"; - content = { - type = "gpt"; - partitions = { - ESP = { - size = "30M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/mnt"; - }; - }; - zfs = { - size = "100%"; - content = { - type = "zfs"; - pool = "zroot"; - }; - }; - }; - }; - }; - }; - zpool = { - zroot = { - type = "zpool"; - rootFsOptions = { - acltype = "posixacl"; - canmount = "off"; - compression = "zstd"; - devices = "off"; - dnodesize = "legacy"; - mountpoint = "none"; - normalization = "formD"; - relatime = "on"; - xattr = "sa"; - }; - - datasets = { - root = { - type = "zfs_fs"; - mountpoint = "/"; - options.mountpoint = "legacy"; - }; - nix = { - type = "zfs_fs"; - mountpoint = "/nix"; - options.mountpoint = "legacy"; - }; - home = { - type = "zfs_fs"; - mountpoint = "/home"; - options.mountpoint = "legacy"; - }; - }; - }; - }; - }; -} diff --git a/hosts/rpi/hardware-configuration.nix b/hosts/rpi/hardware-configuration.nix deleted file mode 100644 index 3b6fd2e..0000000 --- a/hosts/rpi/hardware-configuration.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, inputs, ... }: -{ - boot = { - initrd = { - availableKernelModules = [ - "xhci_pci" - "usbhid" - "usb_storage" - ]; - }; - loader = { - generic-extlinux-compatible.enable = true; - grub.enable = false; - }; - }; - - fileSystems = { - "/" = { - device = "/dev/disk/by-label/NIXOS_SD"; - fsType = "ext4"; - options = [ "noatime" ]; - }; - }; - - nixpkgs.hostPlatform.system = "aarch64-linux"; - - hardware.raspberry-pi."4".poe-hat.enable = true; -} diff --git a/hosts/rpi/services/adguard.nix b/hosts/rpi/services/adguard.nix deleted file mode 100644 index f522a0e..0000000 --- a/hosts/rpi/services/adguard.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - services.adguardhome = { - enable = true; - }; - - networking.firewall = { - allowedTCPPorts = [ - 53 - 853 - ]; - allowedUDPPorts = [ - 53 - 853 - ]; - }; - - services.caddy.virtualHosts."rpi.tailnet-0b15.ts.net" = { - extraConfig = '' - handle_path /dns* { - reverse_proxy http://[::1]:3000 - } - - @dns { - header Referer https://rpi.tailnet-0b15.ts.net/dns - } - reverse_proxy @dns http://[::1]:3000 - ''; - }; -} diff --git a/hosts/rpi/services/caddy.nix b/hosts/rpi/services/caddy.nix deleted file mode 100644 index cef90f0..0000000 --- a/hosts/rpi/services/caddy.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ config, ... }: -{ - services.caddy = { - enable = true; - virtualHosts."rpi.tailnet-0b15.ts.net".extraConfig = '' - header X-Content-Type-Options nosniff - header X-Frame-Options SAMEORIGIN - header -Server - ''; - }; - - networking.firewall.interfaces.tailscale0 = { - allowedTCPPorts = [ - 80 - 443 - ]; - allowedUDPPorts = [ - 80 - 443 - ]; - }; - - services.tailscale.permitCertUid = config.services.caddy.user; -} diff --git a/hosts/rpi/services/default.nix b/hosts/rpi/services/default.nix deleted file mode 100644 index 9609a74..0000000 --- a/hosts/rpi/services/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - imports = [ - ./adguard.nix - ./caddy.nix - ./home-assistant - ]; -} diff --git a/hosts/rpi/services/home-assistant/abode.nix b/hosts/rpi/services/home-assistant/abode.nix deleted file mode 100644 index e909aac..0000000 --- a/hosts/rpi/services/home-assistant/abode.nix +++ /dev/null @@ -1,145 +0,0 @@ -{ - services.home-assistant = { - extraComponents = [ "abode" ]; - - config = { - binary_sensor = [ - { - platform = "group"; - name = "Doors"; - entities = [ - "binary_sensor.front_door" - "binary_sensor.balcony_door" - "binary_sensor.garage_door" - ]; - } - { - platform = "group"; - name = "Windows"; - entities = [ "binary_sensor.front_window" ]; - } - ]; - - automation = [ - { - alias = "Notify on alarm change"; - id = "alarm_state_change"; - triggers = [ - { - trigger = "state"; - entity_id = "alarm_control_panel.abode_alarm"; - not_from = [ - "unknown" - "unavailable" - ]; - to = null; - } - ]; - condition = { - not = [ - { - condition = "state"; - entity_id = "alarm_control_panel.abode_alarm"; - state = "unavailable"; - } - ]; - }; - - actions = [ - { - action = "notify.everyone"; - data = { - title = "Alarm"; - message = '' - {%- if is_state("alarm_control_panel.abode_alarm", "armed_away") -%} - No-one is home. The alarm is armed - {%- elif is_state("alarm_control_panel.abode_alarm", "disarmed") -%} - Alarm disabled - {%- elif is_state("alarm_control_panel.abode_alarm", "armed_home") -%} - The alarm is armed home. - {%- endif %} - ''; - }; - } - ]; - } - { - alias = "Arm alarm at night"; - id = "arm_alarm_night"; - triggers = [ - { - trigger = "time"; - at = "22:00:00"; - } - ]; - conditions = [ - { - condition = "state"; - entity_id = [ - "person.jamie" - "person.kat" - ]; - state = "home"; - } - ]; - actions = [ - { - action = "alarm_control_panel.alarm_arm_home"; - entity_id = "alarm_control_panel.abode_alarm"; - } - ]; - } - { - alias = "Arm alarm when no-one home"; - id = "arm_alarm_no_one_home"; - triggers = [ - { - trigger = "state"; - entity_id = "zone.home"; - to = "0"; - for = { - minutes = 1; - }; - } - ]; - actions = [ - { - action = "alarm_control_panel.alarm_arm_away"; - entity_id = "alarm_control_panel.abode_alarm"; - } - ]; - } - { - alias = "Disarm alarm in the morning"; - id = "disarm_alarm_morning"; - triggers = [ - { - trigger = "time"; - at = "sensor.kat_s_pixel_next_alarm"; - } - { - trigger = "time"; - at = "sensor.jamie_pixel_8a_next_alarm"; - } - ]; - conditions = [ - { - condition = "zone"; - entity_id = [ - "person.jamie" - "person.kat" - ]; - zone = "zone.home"; - } - ]; - actions = [ - { - action = "alarm_control_panel.alarm_disarm"; - entity_id = "alarm_control_panel.abode_alarm"; - } - ]; - } - ]; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/backup.nix b/hosts/rpi/services/home-assistant/backup.nix deleted file mode 100644 index 8bfcf95..0000000 --- a/hosts/rpi/services/home-assistant/backup.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - services.home-assistant.config.automation = [ - { - alias = "Backup Home Assistant daily"; - triggers = { - trigger = "time"; - at = "03:00:00"; - }; - actions = { - action = "backup.create"; - }; - } - ]; -} diff --git a/hosts/rpi/services/home-assistant/blinds.nix b/hosts/rpi/services/home-assistant/blinds.nix deleted file mode 100644 index 607d6d5..0000000 --- a/hosts/rpi/services/home-assistant/blinds.nix +++ /dev/null @@ -1,186 +0,0 @@ -{ lib, ... }: -{ - services.home-assistant.config = { - cover = [ - { - platform = "group"; - name = "All blinds"; - entities = [ - "cover.homelab_zone_living_room_big_shade" - "cover.homelab_zone_living_room_small_shade" - "cover.homelab_zone_kitchen_shade" - "cover.homelab_zone_bedroom_big_shade" - "cover.homelab_zone_bedroom_small_shade" - "cover.homelab_zone_office_shade" - "cover.homelab_zone_bathroom_big_shade" - "cover.homelab_zone_bathroom_small_shade" - "cover.homelab_zone_upstairs_hallway_shade" - ]; - } - { - platform = "group"; - name = "Downstairs blinds"; - entities = [ - "cover.homelab_zone_living_room_big_shade" - "cover.homelab_zone_living_room_small_shade" - "cover.homelab_zone_kitchen_shade" - ]; - } - { - platform = "group"; - name = "Upstairs blinds"; - entities = [ - "cover.homelab_zone_bedroom_big_shade" - "cover.homelab_zone_bedroom_small_shade" - "cover.homelab_zone_office_shade" - "cover.homelab_zone_bathroom_big_shade" - "cover.homelab_zone_bathroom_small_shade" - "cover.homelab_zone_upstairs_hallway_shade" - ]; - } - { - platform = "group"; - name = "Bedroom blinds"; - entities = [ - "cover.homelab_zone_bedroom_big_shade" - "cover.homelab_zone_bedroom_small_shade" - ]; - } - { - platform = "group"; - name = "Bathroom blinds"; - entities = [ - "cover.homelab_zone_bathroom_big_shade" - "cover.homelab_zone_bathroom_small_shade" - ]; - } - ]; - - scene = [ - { - name = "Downstairs blinds daytime"; - icon = "mdi:blinds"; - entities = { - "cover.homelab_zone_living_room_big_shade" = { - current_position = 2; - state = "open"; - }; - "cover.homelab_zone_living_room_small_shade" = { - current_position = 2; - state = "open"; - }; - "cover.homelab_zone_kitchen_shade" = { - current_position = 4; - state = "open"; - }; - }; - } - { - name = "Upstairs blinds daytime"; - icon = "mdi:blinds"; - entities = - lib.genAttrs - [ - "cover.homelab_zone_office_shade" - "cover.homelab_zone_bathroom_big_shade" - "cover.homelab_zone_bathroom_small_shade" - "cover.homelab_zone_upstairs_hallway_shade" - ] - (_: { - current_position = 100; - state = "open"; - }); - } - { - name = "Morning blinds"; - icon = "mdi:blinds"; - entities = - lib.genAttrs - [ - "cover.homelab_zone_bathroom_big_shade" - "cover.homelab_zone_bathroom_small_shade" - "cover.homelab_zone_upstairs_hallway_shade" - ] - (_: { - current_position = 100; - state = "open"; - }); - } - ]; - - automation = [ - { - alias = "Close blinds at sunset"; - id = "close_blinds_sunset"; - triggers = [ - { - trigger = "sun"; - event = "sunset"; - } - { - trigger = "time"; - at = "18:00:00"; - } - ]; - actions = [ - { - action = "cover.close_cover"; - entity_id = "cover.all_blinds"; - } - ]; - } - { - alias = "Close blinds when no-one home"; - id = "close_blinds_no_one_home"; - triggers = [ - { - trigger = "state"; - entity_id = "zone.home"; - to = "0"; - for = { - minutes = 1; - }; - } - ]; - actions = [ - { - action = "cover.close_cover"; - entity_id = "cover.all_blinds"; - } - ]; - } - { - alias = "Open blinds in the morning"; - id = "open_blinds_morning"; - triggers = [ - { - trigger = "time"; - at = "sensor.kat_s_pixel_next_alarm"; - } - { - trigger = "time"; - at = "sensor.jamie_pixel_8a_next_alarm"; - } - ]; - conditions = [ - { - condition = "zone"; - entity_id = [ - "person.jamie" - "person.kat" - ]; - zone = "zone.home"; - } - ]; - actions = [ - { - action = "scene.turn_on"; - target = { - entity_id = "scene.morning_blinds"; - }; - } - ]; - } - ]; - }; -} diff --git a/hosts/rpi/services/home-assistant/cloud.nix b/hosts/rpi/services/home-assistant/cloud.nix deleted file mode 100644 index ec7e88a..0000000 --- a/hosts/rpi/services/home-assistant/cloud.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - services.home-assistant = { - extraComponents = [ "cloud" ]; - config = { - cloud = { }; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/default.nix b/hosts/rpi/services/home-assistant/default.nix deleted file mode 100644 index 1a81308..0000000 --- a/hosts/rpi/services/home-assistant/default.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ pkgs, config, ... }: -{ - imports = [ - ./abode.nix - ./backup.nix - ./blinds.nix - ./cloud.nix - ./esphome.nix - ./hvac.nix - ./leak.nix - ./lights.nix - ./miele.nix - ./mqtt.nix - ./notify.nix - ./people.nix - ./recorder.nix - ./sonos.nix - ./unifi.nix - ./waste-collection.nix - ./weather.nix - ]; - - services.home-assistant = { - enable = true; - extraComponents = [ - "adguard" - "aladdin_connect" - "androidtv_remote" - "august" - "cast" - "econet" - "google_translate" - "homekit_controller" - "met" - "mqtt" - "notify" - "opower" - "otp" - "plex" - "radarr" - "radio_browser" - "roborock" - "roomba" - "sabnzbd" - "sonarr" - "spotify" - "yalexs_ble" - "zeroconf" - ]; - customComponents = with pkgs.home-assistant-custom-components; [ - adaptive_lighting - spook - waste_collection_schedule - ]; - config = { - default_config = { }; - http = { - trusted_proxies = [ - "127.0.0.1" - "::1" - ]; - use_x_forwarded_for = true; - }; - homeassistant = { - auth_mfa_modules = [ - { type = "totp"; } - { type = "notify"; } - ]; - }; - "automation manual" = [ ]; - "automation ui" = "!include automations.yaml"; - "scene manual" = [ ]; - "scene ui" = "!include scenes.yaml"; - }; - }; - - services.caddy.virtualHosts."rpi.tailnet-0b15.ts.net" = { - extraConfig = '' - reverse_proxy http://[::1]:8123 - ''; - }; - - networking.firewall = { - allowedTCPPorts = [ 20163 ]; - allowedUDPPorts = [ 5353 ]; - }; - - systemd.tmpfiles.rules = [ - "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass" - "f ${config.services.home-assistant.configDir}/scenes.yaml 0755 hass hass" - "f ${config.services.home-assistant.configDir}/secrets.yaml 0755 hass hass" - ]; -} diff --git a/hosts/rpi/services/home-assistant/esphome.nix b/hosts/rpi/services/home-assistant/esphome.nix deleted file mode 100644 index c84839e..0000000 --- a/hosts/rpi/services/home-assistant/esphome.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - services = { - home-assistant = { - extraComponents = [ "esphome" ]; - }; - esphome = { - enable = true; - openFirewall = true; - address = "0.0.0.0"; - allowedDevices = [ "char-ttyS" ]; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/hvac.nix b/hosts/rpi/services/home-assistant/hvac.nix deleted file mode 100644 index cb62f9a..0000000 --- a/hosts/rpi/services/home-assistant/hvac.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ - services.home-assistant.config = { - automation = [ - { - alias = "Turn off garage heat overnight"; - id = "garage_heat_overnight"; - triggers = [ - { - trigger = "time"; - at = "22:00:00"; - } - ]; - actions = [ - { - action = "scene.create"; - data = { - scene_id = "garage_climate_before"; - snapshot_entities = [ - "climate.mysa_89501c_thermostat" - "climate.mysa_2bbd00_thermostat" - ]; - }; - } - { - action = "climate.set_hvac_mode"; - target = { - entity_id = [ - "climate.mysa_89501c_thermostat" - "climate.mysa_2bbd00_thermostat" - ]; - }; - data = { - hvac_mode = "off"; - }; - } - ]; - } - { - alias = "Turn on garage heat in the morning"; - id = "garage_heat_morning"; - triggers = [ - { - trigger = "time"; - at = "06:00:00"; - } - ]; - conditions = [ - { - condition = "numeric_state"; - entity_id = "zone.home"; - above = 0; - } - ]; - actions = [ - { - action = "scene.turn_on"; - target = { - entity_id = "scene.garage_climate_before"; - }; - } - ]; - } - ]; - }; -} diff --git a/hosts/rpi/services/home-assistant/leak.nix b/hosts/rpi/services/home-assistant/leak.nix deleted file mode 100644 index bcfb608..0000000 --- a/hosts/rpi/services/home-assistant/leak.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - services.home-assistant.config = { - automation = [ - { - alias = "Notify on leak detected"; - id = "leak_detected"; - triggers = { - trigger = "state"; - entity_id = [ - "binary_sensor.bathroom_sink_left_water_leak" - "binary_sensor.bathroom_sink_right_water_leak" - "binary_sensor.bathroom_toilet_water_leak" - "binary_sensor.garage_bathroom_sink_water_leak" - "binary_sensor.garage_bathroom_toilet_water_leak" - "binary_sensor.kitchen_sink_water_leak" - ]; - to = "on"; - }; - actions = [ - { - action = "notify.everyone"; - data = { - title = "Leak detected!"; - message = "A leak has been detected in the {{ trigger.to_state.attributes.friendly_name | lower }}"; - }; - } - ]; - } - ]; - }; -} diff --git a/hosts/rpi/services/home-assistant/lights.nix b/hosts/rpi/services/home-assistant/lights.nix deleted file mode 100644 index adef09e..0000000 --- a/hosts/rpi/services/home-assistant/lights.nix +++ /dev/null @@ -1,127 +0,0 @@ -{ - services.home-assistant = { - extraComponents = [ - "elgato" - "nanoleaf" - ]; - - config = { - light = [ - { - platform = "group"; - name = "Garage desk lights"; - entities = [ - "light.shapes_acf4" - "light.jamie_ring_light" - ]; - } - ]; - automation = [ - { - alias = "Garage motion-activated lights"; - id = "garage_motion_lights"; - use_blueprint = { - path = "homeassistant/motion_light.yaml"; - input = { - motion_entity = "binary_sensor.homelab_zone_garage_motion_occupancy"; - light_target = { - entity_id = "light.homelab_group_garage_indoors_lights"; - }; - no_motion_wait = 1800; - }; - }; - } - { - alias = "Turn on outside lights at sunset"; - id = "turn_on_outside_lights"; - triggers = [ - { - trigger = "sun"; - event = "sunset"; - } - ]; - actions = [ - { - action = "light.turn_on"; - target = { - entity_id = [ - "light.homelab_group_garage_outdoor_lights" - "light.homelab_group_front_porch_lights" - "light.homelab_group_balcony_lights" - ]; - }; - } - ]; - } - { - alias = "Turn off outside lights at sunrise"; - id = "turn_off_outside_lights"; - triggers = [ - { - trigger = "sun"; - event = "sunrise"; - } - ]; - actions = [ - { - action = "light.turn_off"; - target = { - entity_id = [ - "light.homelab_group_garage_outdoor_lights" - "light.homelab_group_front_porch_lights" - "light.homelab_group_balcony_lights" - ]; - }; - } - ]; - } - ]; - - adaptive_lighting = [ - { - name = "Garage lights"; - lights = [ - "light.homelab_group_garage_indoors_lights" - ]; - min_brightness = 100; - detect_non_ha_changes = true; - } - { - name = "Garage desk lights"; - lights = [ - "light.shapes_acf4" - "light.jamie_ring_light" - ]; - detect_non_ha_changes = true; - } - { - name = "Indoor lights"; - lights = [ - "light.homelab_group_garage_stairs" - "light.homelab_group_kitchen" - "light.homelab_group_living_room" - "light.homelab_group_living_room_stairs_lights" - "light.homelab_group_office_lights" - "light.homelab_group_upstairs_hallway_lights" - "light.homelab_group_bedroom_lights" - "light.homelab_group_bathroom_overhead_lights" - ]; - min_brightness = 50; - min_color_temp = 3000; - detect_non_ha_changes = true; - } - { - name = "Outside lights"; - lights = [ - "light.homelab_group_balcony" - "light.homelab_group_rooftop" - "light.homelab_group_front_porch" - "light.homelab_group_garage_outdoor" - ]; - min_brightness = 100; - detect_non_ha_changes = true; - } - ]; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/miele.nix b/hosts/rpi/services/home-assistant/miele.nix deleted file mode 100644 index 6f5fbd5..0000000 --- a/hosts/rpi/services/home-assistant/miele.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ pkgs, ... }: -{ - services.home-assistant = { - customComponents = with pkgs.home-assistant-custom-components; [ miele ]; - - config = { - automation = [ - { - alias = "Notify when tumble dryer finished"; - triggers = [ - { - trigger = "state"; - entity_id = "sensor.tumble_dryer_status"; - to = "program_ended"; - } - ]; - actions = [ - { - action = "notify.everyone"; - data = { - title = "Tumble dryer"; - message = "The tumble dryer is done"; - }; - } - ]; - } - { - alias = "Notify when washing machine finished"; - triggers = [ - { - trigger = "state"; - entity_id = "sensor.washing_machine_status"; - to = "program_ended"; - } - ]; - actions = [ - { - action = "notify.everyone"; - data = { - title = "Washing machine"; - message = "The washing machine is done"; - }; - } - ]; - } - ]; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/mqtt.nix b/hosts/rpi/services/home-assistant/mqtt.nix deleted file mode 100644 index 5297784..0000000 --- a/hosts/rpi/services/home-assistant/mqtt.nix +++ /dev/null @@ -1,608 +0,0 @@ -{ lib, ... }: -{ - systemd.services.zigbee2mqtt.serviceConfig = { - Restart = lib.mkForce "always"; - RestartSec = "30"; - }; - services = { - zigbee2mqtt = { - enable = true; - settings = { - availability = true; - homeassistant = true; - frontend = { - port = 8080; - }; - serial = { - port = "/dev/ttyUSB0"; - adapter = "ember"; - }; - advanced = { - log_level = "warning"; - }; - - devices = - let - defaultSwitch = { - ledColorWhenOn = 255; - ledIntensityWhenOn = 100; - ledColorWhenOff = 255; - ledIntensityWhenOff = 0; - outputMode = "On/Off"; - smartBulbMode = "Smart Bulb Mode"; - }; - defaultLight = { - color_temp_startup = 65535; - }; - in - { - # Garage - "0x001788010db5e5e0" = defaultLight // { - friendly_name = "homelab/zone/garage/light-1"; - }; - "0x001788010d6cef1e" = defaultLight // { - friendly_name = "homelab/zone/garage/light-2"; - }; - "0x001788010db5e90e" = defaultLight // { - friendly_name = "homelab/zone/garage/light-3"; - }; - "0x001788010d6cc048" = defaultLight // { - friendly_name = "homelab/zone/garage/light-4"; - }; - "0x001788010cfc498d" = defaultLight // { - friendly_name = "homelab/zone/garage/light-5"; - }; - "0x001788010bc2476c" = defaultLight // { - friendly_name = "homelab/zone/garage/light-6"; - }; - "0x54ef441000899496" = { - friendly_name = "homelab/zone/garage/motion"; - }; - "0xb43a31fffe34b129" = defaultSwitch // { - friendly_name = "homelab/zone/garage/switch-outdoors"; - }; - "0xb43a31fffe30b639" = defaultSwitch // { - friendly_name = "homelab/zone/garage/switch-indoors"; - }; - "0x001788010de59fb4" = defaultLight // { - friendly_name = "homelab/zone/garage/light-stairs"; - }; - "0xb43a31fffe380054" = defaultSwitch // { - friendly_name = "homelab/zone/garage-bathroom/switch-light"; - smartBulbMode = "Disabled"; - }; - "0x048727fffe19208b" = defaultSwitch // { - friendly_name = "homelab/zone/garage-bathroom/switch-fan"; - }; - "0xb43a31fffe38d5b8" = defaultSwitch // { - friendly_name = "homelab/zone/garage-hallway/switch-stairs"; - }; - "0x00158d000af0cf12" = { - friendly_name = "homelab/zone/garage-bathroom/sink-leak"; - }; - "0x00158d000af41202" = { - friendly_name = "homelab/zone/garage-bathroom/toilet-leak"; - }; - - # Downstairs - "0x3425b4fffe49ed85" = { - friendly_name = "homelab/zone/living-room/big-shade"; - }; - "0x187a3efffe469cf2" = { - friendly_name = "homelab/zone/living-room/small-shade"; - }; - "0x3425b4fffe4f134a" = { - friendly_name = "homelab/zone/kitchen/shade"; - }; - "0x001788010de59f87" = defaultLight // { - friendly_name = "homelab/zone/kitchen/light-stairs"; - }; - "0x001788010de588ef" = defaultLight // { - friendly_name = "homelab/zone/kitchen/light-1"; - }; - "0x001788010de58f56" = defaultLight // { - friendly_name = "homelab/zone/kitchen/light-2"; - }; - "0x001788010de59fff" = defaultLight // { - friendly_name = "homelab/zone/kitchen/light-3"; - }; - "0x001788010de59fdc" = defaultLight // { - friendly_name = "homelab/zone/kitchen/light-4"; - }; - "0xb43a31fffe396ae0" = defaultSwitch // { - friendly_name = "homelab/zone/kitchen/switch-stairs-light"; - }; - "0xb43a31fffe270352" = defaultSwitch // { - friendly_name = "homelab/zone/kitchen/switch-kitchen-light"; - }; - "0xb43a31fffe308aa9" = defaultSwitch // { - friendly_name = "homelab/zone/kitchen/switch-living-room-light"; - }; - "0x001788010de59294" = defaultLight // { - friendly_name = "homelab/zone/living-room/light-1"; - }; - "0x001788010de58f44" = defaultLight // { - friendly_name = "homelab/zone/living-room/light-2"; - }; - "0x001788010de58f50" = defaultLight // { - friendly_name = "homelab/zone/living-room/light-3"; - }; - "0x001788010de59d73" = defaultLight // { - friendly_name = "homelab/zone/living-room/light-4"; - }; - "0x001788010de59ed5" = defaultLight // { - friendly_name = "homelab/zone/living-room/light-stairs"; - }; - "0xb43a31fffe307d4a" = defaultSwitch // { - friendly_name = "homelab/zone/living-room/switch-living-room-light"; - }; - "0xb43a31fffe30b619" = defaultSwitch // { - friendly_name = "homelab/zone/living-room/switch-kitchen-light"; - }; - "0xb43a31fffe34dcd3" = defaultSwitch // { - friendly_name = "homelab/zone/living-room/switch-stairs-light"; - }; - "0xb43a31fffe38377e" = defaultSwitch // { - friendly_name = "homelab/zone/living-room/switch-front-porch"; - }; - "0x00158d000af41336" = { - friendly_name = "homelab/zone/kitchen/sink-leak"; - }; - - # Upstairs - "0x3425b4fffe415425" = { - friendly_name = "homelab/zone/office/shade"; - }; - "0x3425b4fffe6a4415" = { - friendly_name = "homelab/zone/bedroom/big-shade"; - }; - "0xe0798dfffebb2faa" = { - friendly_name = "homelab/zone/bedroom/small-shade"; - }; - "0xe0798dfffec2c88c" = { - friendly_name = "homelab/zone/bathroom/big-shade"; - }; - "0x3425b4fffecfc7ca" = { - friendly_name = "homelab/zone/bathroom/small-shade"; - }; - "0xbc026efffe3a9626" = { - friendly_name = "homelab/zone/upstairs/hallway-shade"; - }; - "0x00158d000af0b008" = { - friendly_name = "homelab/zone/bathroom/toilet-leak"; - }; - "0x00158d000af0b938" = { - friendly_name = "homelab/zone/bathroom/sink-right-leak"; - }; - "0x00158d000af3faeb" = { - friendly_name = "homelab/zone/bathroom/sink-left-leak"; - }; - "0xe0798dfffeaa77b1" = defaultSwitch // { - friendly_name = "homelab/zone/upstairs/switch-hallway-light-2"; - smartBulbMode = "Disabled"; - }; - "0xb43a31fffe3babd1" = defaultSwitch // { - friendly_name = "homelab/zone/upstairs/switch-stairs-light"; - }; - "0xe0798dfffeaa78c9" = defaultSwitch // { - friendly_name = "homelab/zone/bedroom/switch-closet"; - }; - "0x001788010de5c71f" = defaultLight // { - friendly_name = "homelab/zone/bedroom/light-closet"; - }; - "0xe0798dfffeaa77e9" = defaultSwitch // { - friendly_name = "homelab/zone/upstairs/switch-rooftop"; - }; - "0xe0798dfffeb36d7a" = defaultSwitch // { - friendly_name = "homelab/zone/bedroom/switch"; - }; - "0xe0798dfffeb3662c" = defaultSwitch // { - friendly_name = "homelab/zone/office/switch"; - }; - "0x001788010de5c649" = defaultLight // { - friendly_name = "homelab/zone/office/light"; - }; - "0xb43a31fffe34c1cf" = defaultSwitch // { - friendly_name = "homelab/zone/upstairs/switch-hallway-light-1"; - smartBulbMode = "Disabled"; - }; - "0x001788010de5c725" = defaultLight // { - friendly_name = "homelab/zone/upstairs/light-stairs"; - }; - "0x001788010de5c6e8" = defaultLight // { - friendly_name = "homelab/zone/upstairs/light-hallway-1"; - disabled = true; - }; - "0x001788010de5c44d" = defaultLight // { - friendly_name = "homelab/zone/upstairs/light-hallway-2"; - disabled = true; - }; - "0x001788010de5c72d" = defaultLight // { - friendly_name = "homelab/zone/bedroom/light-1"; - }; - "0x001788010de5c4a6" = defaultLight // { - friendly_name = "homelab/zone/bedroom/light-2"; - }; - "0x001788010de5c49a" = defaultLight // { - friendly_name = "homelab/zone/bedroom/light-3"; - }; - "0x001788010de5cfd3" = { - friendly_name = "homelab/zone/bedroom/light-4"; - }; - "0x70ac08fffe6c8e2c" = defaultSwitch // { - friendly_name = "homelab/zone/bathroom/switch-overhead-1"; - }; - "0xe0798dfffeb368c0" = defaultSwitch // { - friendly_name = "homelab/zone/bathroom/switch-overhead-2"; - }; - "0xe0798dfffeaa7745" = defaultSwitch // { - friendly_name = "homelab/zone/bathroom/switch-vanity-1"; - smartBulbMode = "Disabled"; - }; - "0x9035eafffec6e806" = defaultSwitch // { - friendly_name = "homelab/zone/bathroom/switch-vanity-2"; - smartBulbMode = "Disabled"; - }; - "0x001788010de5c4a4" = defaultLight // { - friendly_name = "homelab/zone/bathroom/light"; - }; - - # Roof - "0x00158d000ad7f4eb" = { - friendly_name = "homelab/zone/rooftop/temperature-sensor"; - }; - "0x001788010db42ff9" = defaultLight // { - friendly_name = "homelab/zone/rooftop/light-1"; - }; - "0x001788010ce32dd5" = defaultLight // { - friendly_name = "homelab/zone/rooftop/light-2"; - }; - - # Outdoors - "0x001788010dabd66b" = defaultLight // { - friendly_name = "homelab/zone/outdoors/porch-light"; - }; - "0x001788010daba6e8" = defaultLight // { - friendly_name = "homelab/zone/outdoors/garage-light-1"; - }; - "0x001788010db42d9c" = defaultLight // { - friendly_name = "homelab/zone/outdoors/garage-light-"; - }; - "0x001788010db3bab6" = defaultLight // { - friendly_name = "homelab/zone/outdoors/garage-light-3"; - }; - "0x001788010dabc8e4" = defaultLight // { - friendly_name = "homelab/zone/outdoors/garage-light-4"; - }; - "0xe0798dfffeb367b4" = defaultSwitch // { - friendly_name = "homelab/zone/kitchen/switch-balcony"; - }; - "0x001788010daba3ee" = defaultLight // { - friendly_name = "homelab/zone/outdoors/balcony-light-1"; - }; - "0x001788010ce618a9" = defaultLight // { - friendly_name = "homelab/zone/outdoors/balcony-light-2"; - }; - }; - - groups = { - "1" = { - friendly_name = "homelab/group/kitchen-garage-stairs"; - devices = [ - "0x001788010de59fb4/11" - "0x001788010de59f87/11" - "0xb43a31fffe38d5b8/1" - "0xb43a31fffe396ae0/1" - ]; - }; - "2" = { - friendly_name = "homelab/group/living-room-lights"; - devices = [ - "0xb43a31fffe307d4a/1" - "0xb43a31fffe308aa9/1" - "0x001788010de59294/11" - "0x001788010de58f44/11" - "0x001788010de58f50/11" - "0x001788010de59d73/11" - ]; - }; - "3" = { - friendly_name = "homelab/group/kitchen-lights"; - devices = [ - "0xb43a31fffe30b619/1" - "0xb43a31fffe270352/1" - "0x001788010de588ef/11" - "0x001788010de58f56/11" - "0x001788010de59fff/11" - "0x001788010de59fdc/11" - ]; - }; - "4" = { - friendly_name = "homelab/group/living-room-stairs"; - devices = [ - "0xb43a31fffe34dcd3/1" - "0xb43a31fffe3babd1/1" - "0x001788010de59ed5/11" - "0x001788010de5c725/11" - ]; - }; - "5" = { - friendly_name = "homelab/group/front-porch-lights"; - devices = [ - "0xb43a31fffe38377e/1" - "0x001788010dabd66b/11" - ]; - }; - "6" = { - friendly_name = "homelab/group/garage-indoors"; - devices = [ - "0xb43a31fffe30b639/1" - "0x001788010db5e5e0/11" - "0x001788010d6cef1e/11" - "0x001788010db5e90e/11" - "0x001788010d6cc048/11" - "0x001788010cfc498d/11" - "0x001788010bc2476c/11" - ]; - }; - "7" = { - friendly_name = "homelab/group/garage-outdoor-lights"; - devices = [ - "0xb43a31fffe34b129/1" - "0x001788010daba6e8/11" - "0x001788010db42d9c/11" - "0x001788010db3bab6/11" - "0x001788010dabc8e4/11" - ]; - }; - "8" = { - friendly_name = "homelab/group/balcony-lights"; - devices = [ - "0xe0798dfffeb367b4/1" - "0x001788010daba3ee/11" - "0x001788010ce618a9/11" - ]; - }; - "9" = { - friendly_name = "homelab/group/rooftop-lights"; - devices = [ - "0xe0798dfffeaa77e9/1" - "0x001788010db42ff9/11" - "0x001788010ce32dd5/11" - ]; - }; - "10" = { - friendly_name = "homelab/group/office"; - devices = [ - "0xe0798dfffeb3662c/1" - "0x001788010de5c649/11" - ]; - }; - "11" = { - friendly_name = "homelab/group/upstairs-hallway"; - devices = [ - "0xe0798dfffeaa77b1/1" - "0xb43a31fffe34c1cf/1" - "0x001788010de5c6e8/11" - "0x001788010de5c44d/11" - # TODO: add 3rd light - ]; - }; - "12" = { - friendly_name = "homelab/group/bedroom"; - devices = [ - "0xe0798dfffeb36d7a/1" - "0x001788010de5c72d/11" - "0x001788010de5c4a6/11" - "0x001788010de5c49a/11" - "0x001788010de5cfd3/11" - ]; - }; - "13" = { - friendly_name = "homelab/group/bedroom-closet"; - devices = [ - "0xe0798dfffeaa78c9/1" - "0x001788010de5c71f/11" - ]; - }; - "14" = { - friendly_name = "homelab/group/bathroom-overhead"; - devices = [ - "0x70ac08fffe6c8e2c/1" - "0xe0798dfffeb368c0/1" - "0x001788010de5c4a4/11" - ]; - }; - "15" = { - friendly_name = "homelab/group/bathroom-vanity"; - devices = [ - "0xe0798dfffeaa7745/1" - "0x9035eafffec6e806/1" - ]; - }; - "16" = { - friendly_name = "homelab/group/indoor-lights"; - devices = [ - "0x001788010db5e5e0/11" - "0x001788010d6cef1e/11" - "0x001788010db5e90e/11" - "0x001788010d6cc048/11" - "0x001788010cfc498d/11" - "0x001788010bc2476c/11" - "0x001788010de59fb4/11" - "0x001788010de59f87/11" - "0x001788010de588ef/11" - "0x001788010de58f56/11" - "0x001788010de59fff/11" - "0x001788010de59fdc/11" - "0x001788010de59294/11" - "0x001788010de58f44/11" - "0x001788010de58f50/11" - "0x001788010de59d73/11" - "0x001788010de59ed5/11" - "0x001788010de5c725/11" - "0x001788010de5c649/11" - "0x001788010de5c6e8/11" - "0x001788010de5c44d/11" - # TODO: upstairs hallway light 3 - "0x001788010de5c72d/11" - "0x001788010de5c4a6/11" - "0x001788010de5c49a/11" - "0x001788010de5cfd3/11" - "0x001788010de5c71f/11" - "0x001788010de5c4a4/11" - ]; - }; - "17" = { - friendly_name = "homelab/group/upstairs-lights"; - devices = [ - "0x001788010de59fb4/11" - "0x001788010de59f87/11" - "0x001788010de588ef/11" - "0x001788010de58f56/11" - "0x001788010de59fff/11" - "0x001788010de59fdc/11" - "0x001788010de59294/11" - "0x001788010de58f44/11" - "0x001788010de58f50/11" - "0x001788010de59d73/11" - "0x001788010de59ed5/11" - "0x001788010de5c725/11" - "0x001788010de5c649/11" - "0x001788010de5c6e8/11" - "0x001788010de5c44d/11" - # TODO: upstairs hallway light 3 - "0x001788010de5c72d/11" - "0x001788010de5c4a6/11" - "0x001788010de5c49a/11" - "0x001788010de5cfd3/11" - "0x001788010de5c71f/11" - "0x001788010de5c4a4/11" - ]; - }; - "18" = { - friendly_name = "homelab/group/garage-indoors-lights"; - devices = [ - "0x001788010db5e5e0/11" - "0x001788010d6cef1e/11" - "0x001788010db5e90e/11" - "0x001788010d6cc048/11" - "0x001788010cfc498d/11" - "0x001788010bc2476c/11" - ]; - }; - "19" = { - friendly_name = "homelab/group/garage-stairs"; - devices = [ - "0x001788010de59fb4/11" - "0x001788010de59f87/11" - ]; - }; - "20" = { - friendly_name = "homelab/group/kitchen"; - devices = [ - "0x001788010de588ef/11" - "0x001788010de58f56/11" - "0x001788010de59fff/11" - "0x001788010de59fdc/11" - ]; - }; - "21" = { - friendly_name = "homelab/group/living-room"; - devices = [ - "0x001788010de59294/11" - "0x001788010de58f44/11" - "0x001788010de58f50/11" - "0x001788010de59d73/11" - ]; - }; - "22" = { - friendly_name = "homelab/group/living-room-stairs-lights"; - devices = [ - "0x001788010de59ed5/11" - "0x001788010de5c725/11" - ]; - }; - "23" = { - friendly_name = "homelab/group/front-porch"; - devices = [ - "0x001788010dabd66b/11" - ]; - }; - "24" = { - friendly_name = "homelab/group/balcony"; - devices = [ - "0x001788010daba3ee/11" - "0x001788010ce618a9/11" - ]; - }; - "25" = { - friendly_name = "homelab/group/rooftop"; - devices = [ - "0x001788010db42ff9/11" - "0x001788010ce32dd5/11" - ]; - }; - "26" = { - friendly_name = "homelab/group/office-lights"; - devices = [ - "0x001788010de5c649/11" - ]; - }; - "27" = { - friendly_name = "homelab/group/upstairs-hallway-lights"; - devices = [ - "0x001788010de5c6e8/11" - "0x001788010de5c44d/11" - # TODO: add 3rd light - ]; - }; - "28" = { - friendly_name = "homelab/group/bedroom-lights"; - devices = [ - "0x001788010de5c72d/11" - "0x001788010de5c4a6/11" - "0x001788010de5c49a/11" - "0x001788010de5cfd3/11" - ]; - }; - "29" = { - friendly_name = "homelab/group/bathroom-overhead-lights"; - devices = [ - "0x001788010de5c4a4/11" - ]; - }; - "30" = { - friendly_name = "homelab/group/garage-outdoor"; - devices = [ - "0x001788010daba6e8/11" - "0x001788010db42d9c/11" - "0x001788010db3bab6/11" - "0x001788010dabc8e4/11" - ]; - }; - }; - }; - }; - mosquitto = { - enable = true; - listeners = [ - { - settings = { - allow_anonymous = true; - }; - omitPasswordAuth = true; - acl = [ "topic readwrite #" ]; - users = { - zigbee2mqtt = { - acl = [ "readwrite #" ]; - }; - home-assistant = { - acl = [ "readwrite #" ]; - }; - }; - } - ]; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/notify.nix b/hosts/rpi/services/home-assistant/notify.nix deleted file mode 100644 index 0c361fb..0000000 --- a/hosts/rpi/services/home-assistant/notify.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - services.home-assistant.config = { - notify = [ - { - platform = "group"; - name = "Everyone"; - services = [ - { service = "mobile_app_kat_s_pixel"; } - { service = "mobile_app_jamie_pixel_8a"; } - ]; - } - ]; - }; -} diff --git a/hosts/rpi/services/home-assistant/people.nix b/hosts/rpi/services/home-assistant/people.nix deleted file mode 100644 index 3e894cf..0000000 --- a/hosts/rpi/services/home-assistant/people.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ - services.home-assistant.config = { - automation = [ - { - alias = "Notify when Jamie leaves home/work"; - id = "notify_jamie_leave_home_work"; - triggers = [ - { - trigger = "zone"; - entity_id = "person.jamie"; - zone = "zone.home"; - event = "leave"; - } - { - trigger = "zone"; - entity_id = "person.jamie"; - zone = "zone.jamie_work"; - event = "leave"; - } - ]; - actions = [ - { - variables = { - event = "{{ 'left' if trigger.event == 'leave' else 'arrived at' }}"; - person = "{{ trigger.to_state.attributes.friendly_name }}"; - zone = "{{ trigger.zone.attributes.friendly_name }}"; - }; - } - { - action = "notify.mobile_app_kat_s_pixel"; - data = { - message = "{{ person + ' ' + event + ' ' + zone }}"; - }; - } - ]; - } - { - alias = "Notify when Kat leaves home/work"; - id = "notify_kat_leave_home_work"; - triggers = [ - { - trigger = "zone"; - entity_id = "person.kat"; - zone = "zone.home"; - event = "leave"; - } - { - trigger = "zone"; - entity_id = "person.kat"; - zone = "zone.kat_work"; - event = "leave"; - } - ]; - actions = [ - { - variables = { - event = "{{ 'left' if trigger.event == 'leave' else 'arrived at' }}"; - person = "{{ trigger.to_state.attributes.friendly_name }}"; - zone = "{{ trigger.zone.attributes.friendly_name }}"; - }; - } - { - action = "notify.mobile_app_jamie_pixel_8a"; - data = { - message = "{{ person + ' ' + event + ' ' + zone }}"; - }; - } - ]; - } - ]; - }; -} diff --git a/hosts/rpi/services/home-assistant/recorder.nix b/hosts/rpi/services/home-assistant/recorder.nix deleted file mode 100644 index 907db72..0000000 --- a/hosts/rpi/services/home-assistant/recorder.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - services.home-assistant.config.recorder = { - commit_interval = 30; - purge_keep_days = 7; - }; -} \ No newline at end of file diff --git a/hosts/rpi/services/home-assistant/sonos.nix b/hosts/rpi/services/home-assistant/sonos.nix deleted file mode 100644 index a0b431f..0000000 --- a/hosts/rpi/services/home-assistant/sonos.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - services.home-assistant = { - extraComponents = [ "sonos" ]; - config = { - sonos = { - media_player = { - hosts = [ "192.168.1.246" ]; - }; - }; - }; - }; - - networking.firewall.allowedTCPPorts = [ - 1400 - 8123 - ]; -} diff --git a/hosts/rpi/services/home-assistant/unifi.nix b/hosts/rpi/services/home-assistant/unifi.nix deleted file mode 100644 index 9f9f12a..0000000 --- a/hosts/rpi/services/home-assistant/unifi.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ - services.home-assistant = { - extraComponents = [ - "unifi" - "unifiprotect" - ]; - config = { - automation = [ - { - alias = "Doorbell"; - id = "doorbell"; - triggers = [ - { - trigger = "state"; - entity_id = "binary_sensor.g4_doorbell_pro_doorbell"; - to = "on"; - } - ]; - actions = [ - { - action = "notify.everyone"; - data = { - title = "Doorbell"; - message = "There's someone at the door"; - data = { - image = "/api/camera_proxy/camera.g4_doorbell_pro_high"; - }; - }; - } - { - action = "elgato.identify"; - target = { - entity_id = [ - "light.jamie_ring_light" - "light.kat_ring_light" - ]; - }; - } - ]; - } - ]; - }; - }; -} diff --git a/hosts/rpi/services/home-assistant/waste-collection.nix b/hosts/rpi/services/home-assistant/waste-collection.nix deleted file mode 100644 index fa0b151..0000000 --- a/hosts/rpi/services/home-assistant/waste-collection.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - services.home-assistant.config = { - waste_collection_schedule = { - sources = [ - { - name = "seattle_gov"; - args = { - street_address = "!secret address"; - }; - } - ]; - }; - - sensor = [ - { - platform = "waste_collection_schedule"; - name = "Seattle garbage collection"; - } - ]; - - automation = [ - { - alias = "Notify garbage collection"; - id = "notify_garbage_schedule"; - triggers = [ - { - trigger = "calendar"; - event = "start"; - offset = "-6:00:00"; - entity_id = "calendar.seattle_public_utilities"; - } - ]; - actions = [ - { - action = "notify.everyone"; - data = { - title = "Garbage collection"; - message = "{{ states(\"sensor.seattle_garbage_collection\") }}"; - }; - } - ]; - } - ]; - }; -} diff --git a/hosts/rpi/services/home-assistant/weather.nix b/hosts/rpi/services/home-assistant/weather.nix deleted file mode 100644 index 2405aee..0000000 --- a/hosts/rpi/services/home-assistant/weather.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - services.home-assistant.config = { - automation = [ - { - alias = "UV Index Notification"; - id = "uv_index"; - description = "Notify when UV index is high"; - triggers = [ - { - trigger = "numeric_state"; - entity_id = [ - "weather.forecast_home" - ]; - attribute = "uv_index"; - above = 5; - } - ]; - actions = [ - { - action = "notify.everyone"; - data = { - title = "High UV index"; - message = "The UV index is {{ trigger.to_state.attributes.uv_index }}"; - }; - } - ]; - } - ]; - }; -}