From 6a8af64c7ece5f31cc15a5b2a6b710c6edcc77f1 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 11 Jun 2020 12:28:29 +0200 Subject: [PATCH] update: light-control and buttons --- configs/pepe/home-assistant.nix | 39 ++++++++++++++++--- configs/pepe/home-assistant/light-control.nix | 4 ++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index 84124d7..626604d 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -50,7 +50,7 @@ in { # all scenes input_select.scene = { icon = "mdi:brightness-auto"; - options = [ "default" "night" "outside" ]; + options = [ "default" "night" "outside" "cooking" ]; }; # scenes controlled by buttons input_select.scene_button = { @@ -62,9 +62,7 @@ in { automation = [ { - # This automation script runs when the thermostat mode selector is changed. - # It publishes its value to the same MQTT topic it is also subscribed to. - alias = "Mqtt publish Scene"; + alias = "set light-control scene"; trigger = { platform = "state"; entity_id = "input_select.scene"; @@ -73,7 +71,6 @@ in { service = "mqtt.publish"; data_template = { topic = "control/lights/set"; - #retain = true; payload_template = ''{"scene":"{{ states('input_select.scene')}}"}''; }; @@ -82,16 +79,45 @@ in { # control situation with buttons { - alias = "Toggle Button (controlled) Scene"; + alias = "Button -> Change Scene"; trigger = { platform = "state"; entity_id = "input_boolean.situation_toggle"; }; + condition = { + condition = "not"; + conditions = [{ + condition = { + condition = "state"; + entity_id = "input_select.scene"; + state = "outside"; + }; + }]; + }; action = { service = "input_select.select_next"; data.entity_id = "input_select.scene_button"; }; } + { + alias = "Button -> Default Scene"; + trigger = { + platform = "state"; + entity_id = "input_boolean.situation_toggle"; + }; + condition = { + condition = "state"; + entity_id = "input_select.scene"; + state = "outside"; + }; + action = { + service = "input_select.select_option"; + data = { + entity_id = "input_select.scene_button"; + option = "default"; + }; + }; + } { alias = "Button Scene -> Scene"; trigger = { @@ -106,6 +132,7 @@ in { }; }; } + { alias = "Set Scene To Outside when opening door"; trigger = [ diff --git a/configs/pepe/home-assistant/light-control.nix b/configs/pepe/home-assistant/light-control.nix index 4d9c3e7..240257a 100644 --- a/configs/pepe/home-assistant/light-control.nix +++ b/configs/pepe/home-assistant/light-control.nix @@ -14,6 +14,10 @@ name = "outside"; room_tracking_enabled = false; } + { + name = "cooking"; + enabled_switches = [ "stat/PAL07/RESULT" "stat/PAL08/RESULT" ]; + } { name = "night"; room_tracking_enabled = false;