From 485807c22d20db9684612333cfda0b1fa63cf45a Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 15 May 2021 13:13:13 +0200 Subject: ma home/ham: add signal-rest, update automations --- .../2configs/home/ham/automation/fenster_auf.nix | 63 ++++++++++++++++++---- 1 file changed, 52 insertions(+), 11 deletions(-) (limited to 'makefu/2configs/home/ham/automation/fenster_auf.nix') diff --git a/makefu/2configs/home/ham/automation/fenster_auf.nix b/makefu/2configs/home/ham/automation/fenster_auf.nix index ccebd5b00..871f248b9 100644 --- a/makefu/2configs/home/ham/automation/fenster_auf.nix +++ b/makefu/2configs/home/ham/automation/fenster_auf.nix @@ -1,3 +1,8 @@ +{ lib, ... }: +#uses: +# notify.signal +# binary_sensor.badezimmer_fenster_contact +# binary_sensor.dusche_fenster_contact let min = 20; fenster_offen = name: entity: @@ -13,21 +18,57 @@ let action = [ { - service = "notify.firetv_wohnzimmer"; + service = "notify.signal_home"; data = { - title = "${name} seit ${toString min} Minuten offen"; - message = "Bitte einmal checken ob das ok ist :)"; - data = { - interrupt = 1; - duration = 300; - }; + message= "${name} seit ${toString min} Minuten offen\nBitte einmal checken ob das ok ist :)"; }; } + { + service = "input_boolean.turn_on"; + target.entity_id = "input_boolean.${lib.toLower name}_lang_offen"; + } + ]; + }; + fenster_geschlossen_lang = name: entity: + { alias = "${name} wieder geschlossen"; + trigger = [ + { + platform = "state"; + entity_id = entity; + to = "off"; + } + ]; + condition = [ + { condition = "state"; + entity_id = "input_boolean.${lib.toLower name}_lang_offen"; + state = "on"; + } + ]; + action = + [ + { + service = "notify.signal_home"; + data = { + message= "${name} ist wieder geschlossen, Danke!"; + }; + } + { + service = "input_boolean.turn_off"; + target.entity_id = "input_boolean.${lib.toLower name}_lang_offen"; + } ]; }; in { - services.home-assistant.config.automation = [ - (fenster_offen "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact") - (fenster_offen "Duschfenster" "binary_sensor.dusche_fenster_contact") - ]; + services.home-assistant.config = { + input_boolean = { + badezimmerfinester_lang_offen.name = "Badezimmer lange offen"; + duschfenster_lang_offen.name = "Duschfenster lange offen"; + }; + automation = [ + (fenster_geschlossen_lang "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact") + (fenster_geschlossen_lang "Duschfenster" "binary_sensor.badezimmer_fenster_contact") + (fenster_offen "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact") + (fenster_offen "Duschfenster" "binary_sensor.dusche_fenster_contact") + ]; + }; } -- cgit v1.2.3