From 924d06865a1704ef0dbcf5490d2061bcb5635cce Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 27 Oct 2026 13:37:53 +0000 Subject: [PATCH] manatee: Reload Plejd when its BLE link goes stale pyplejd keeps using a dead BLE client ("Service Discovery has not been performed yet") instead of reconnecting, which left the Plejd lights unreachable for two days. Fire system log events and let an automation reload the integration when that warning shows up. Also add systemd to bt-reset's PATH so its `systemctl` calls work. --- .../modules/home-assistant/default.nix | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hosts/manatee/modules/home-assistant/default.nix b/hosts/manatee/modules/home-assistant/default.nix index d1f2f7f..abffca6 100644 --- a/hosts/manatee/modules/home-assistant/default.nix +++ b/hosts/manatee/modules/home-assistant/default.nix @@ -22,12 +22,35 @@ frontend: themes: !include_dir_merge_named themes automation: !include automations.yaml +automation nix: + # pyplejd keeps using a dead BLE client forever ("Service Discovery has not + # been performed yet") instead of reconnecting; reloading the integration fixes it + - alias: Reload Plejd when its BLE link goes stale + mode: single + triggers: + - trigger: event + event_type: system_log_event + event_data: + level: WARNING + conditions: + - "{{ 'pyplejd' in trigger.event.data.name and 'Service Discovery has not been performed yet' in (trigger.event.data.message | join(' ')) }}" + actions: + - action: homeassistant.reload_config_entry + target: + entity_id: light.takbelysning + # With mode: single, this caps it at one reload per 5 minutes + - delay: "00:05:00" + script: !include scripts.yaml scene: !include scenes.yaml recorder: purge_keep_days: 365 +# Turns logged warnings/errors into `system_log_event`s that automations can react to +system_log: + fire_event: true + alert: fridge_door: name: Fridge is open @@ -64,6 +87,7 @@ ${cfg.extraConfig}''; pkgs.kmod pkgs.gnugrep pkgs.coreutils + pkgs.systemd ] }"