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 ] }"