From 4025c817396d7ed05efcb6a57e957395a284475e Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Mon, 16 Nov 2020 22:04:21 +0100 Subject: [PATCH] hass: improve heater state when outside --- configs/pepe/home-assistant.nix | 152 ++++++++++++++++++++++---------- 1 file changed, 104 insertions(+), 48 deletions(-) diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index c6d2e8c..867b70f 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -66,10 +66,8 @@ in { input_boolean.windows_up.icon = "mdi:toggle-switch"; # heater scenes - input_select.heater_state = { - #icon = "mdi:brightness-auto"; - options = [ "off" "on1" "on2" ]; - }; + input_select.heater_state.options = [ "off" "on1" "on2" ]; + input_select.heater_state_memory.options = [ "off" "on1" "on2" ]; automation = [ @@ -130,7 +128,7 @@ in { # outside and home { - alias = "Set Scene To Outside when opening door"; + alias = "when opening door I'm outside"; trigger = [ { platform = "state"; @@ -147,17 +145,39 @@ in { to = "off"; } ]; - action = { - service = "input_select.select_option"; - data = { - entity_id = "input_select.scene"; - option = "outside"; - }; - }; + action = [ + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.scene"; + option = "outside"; + }; + } + { + service = "input_select.select_option"; + data_template = { + entity_id = "input_select.heater_state_memory"; + option = '' + {% if not is_state("input_select.heater_state", "off") %} + {{ states('input_select.heater_state') }} + {%- else -%} + {{ states('input_select.heater_state_memory') }} + {%- endif %} + ''; + }; + } + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state"; + option = "off"; + }; + } + ]; } { - alias = "Set default for motion inside"; + alias = "reset everything when back home"; trigger = map (entity_id: { platform = "state"; entity_id = entity_id; @@ -178,13 +198,22 @@ in { value_template = ''{{ states.input_select.scene.state == "outside" }}''; }; - action = { - service = "input_select.select_option"; - data = { - entity_id = "input_select.scene"; - option = "default"; - }; - }; + action = [ + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.scene"; + option = "default"; + }; + } + { + service = "input_select.select_option"; + data_template = { + entity_id = "input_select.heater_state"; + option = "{{ states('input_select.heater_state_memory') }}"; + }; + } + ]; } # window roles @@ -212,12 +241,12 @@ in { }]; } { - alias = "enforce window_up state"; + alias = "handle windows up state"; trigger = [ - { - platform = "time_pattern"; - minutes = "/5"; # every 5 minutes - } + #{ + # platform = "time_pattern"; + # minutes = "/5"; # every 5 minutes + #} { platform = "state"; entity_id = "input_boolean.windows_up"; @@ -242,13 +271,22 @@ in { platform = "time"; at = "09:00:00"; }]; - action = [{ - service = "input_select.select_option"; - data = { - entity_id = "input_select.heater_state"; - option = "on1"; - }; - }]; + action = [ + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state"; + option = "on1"; + }; + } + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state_memory"; + option = "on1"; + }; + } + ]; } { alias = "heater state = on2 in the early evening"; @@ -256,13 +294,22 @@ in { platform = "time"; at = "22:30:00"; }]; - action = [{ - service = "input_select.select_option"; - data = { - entity_id = "input_select.heater_state"; - option = "on2"; - }; - }]; + action = [ + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state"; + option = "on2"; + }; + } + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state_memory"; + option = "on2"; + }; + } + ]; } { alias = "heater state = off in the evening"; @@ -270,20 +317,29 @@ in { platform = "time"; at = "23:30:00"; }]; - action = [{ - service = "input_select.select_option"; - data = { - entity_id = "input_select.heater_state"; - option = "off"; - }; - }]; + action = [ + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state"; + option = "off"; + }; + } + { + service = "input_select.select_option"; + data = { + entity_id = "input_select.heater_state_memory"; + option = "off"; + }; + } + ]; } { - alias = "enforce heater state"; + alias = "handle heater state"; trigger = [ { platform = "time_pattern"; - minutes = "/5"; # every 5 minutes + minutes = "/10"; # every 5 minutes } { platform = "state";