From bccb2fd4e51448a2e9794acd47e7df16339f64aa Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 17 Apr 2019 20:46:58 +0200 Subject: ma bureautomation: refactor --- .../bureautomation/automation/nachtlicht.nix | 72 ++++++++++------------ 1 file changed, 32 insertions(+), 40 deletions(-) (limited to 'makefu/2configs/bureautomation/automation/nachtlicht.nix') diff --git a/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix index 2becd4a3..ec6fa20c 100644 --- a/makefu/2configs/bureautomation/automation/nachtlicht.nix +++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix @@ -1,43 +1,35 @@ [ - { - alias = "Turn off Nachtlicht on sunrise"; - trigger = - { - platform = "sun"; - event = "sunrise"; - }; - action = - { - service = "homeassistant.turn_off"; - entity_id = [ "group.nachtlicht" ]; - }; - } + # TODO: trigger if it is before dusk and somebody arives but nachtlichter are + # off from last day + # TODO: do not have nachtlicht turned on at night + { + alias = "Turn on Nachtlicht at dusk"; # when it gets dim + trigger = + { platform = "numeric_state"; + entity_id = "sun.sun"; + value_template = "{{ state.attributes.elevation }}"; + below = 10; - { - alias = "Turn on Nachtlicht on motion and dusk"; - trigger = - { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "on"; - }; - condition = # 'when dark' - { - condition = "or"; - conditions = [ - { condition = "sun"; - after = "sunset"; - after_offset = "-00:45:00"; # on dusk - } - { condition = "sun"; - before = "sunrise"; - } - ]; - }; - action = - { - service = "homeassistant.turn_on"; - entity_id = [ "group.nachtlicht" ]; - }; - } + }; + action = + { service = "homeassistant.turn_on"; + entity_id = [ "group.nachtlicht" ]; + }; + } + { + alias = "Turn off Nachtlicht at dawn"; + trigger = + { platform = "sun"; + event = "sunrise"; + offset = "01:30:00"; # on dawn + }; + # TODO: when somebody is still in the buero + # condition = + #{ + #}; + action = + { service = "homeassistant.turn_off"; + entity_id = [ "group.nachtlicht" ]; + }; + } ] -- cgit v1.2.3