From 8e807058892240a54d56ed1746eb788b445093f6 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Mon, 13 Apr 2020 11:16:52 +0200 Subject: [PATCH] pepe: add double click button rule --- configs/pepe/home-assistant/zigbee2mqtt.nix | 33 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/configs/pepe/home-assistant/zigbee2mqtt.nix b/configs/pepe/home-assistant/zigbee2mqtt.nix index f3f4e00..7b9875e 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt.nix @@ -306,7 +306,35 @@ in { } ]; - # todo : double click, turn on the light in this room and every where else turn it off + # double click, turn off the light in the room + room_lights_off = map ({ button, room }: { + alias = "turn on lights in ${room}, on ${button} click"; + trigger = { + platform = "mqtt"; + topic = "zigbee2mqtt/${button}"; + }; + condition = { + condition = "template"; + value_template = ''{{ "double" == trigger.payload_json.click }}''; + }; + action = { + service = "switch.turn_off"; + entity_id = "group.${room}"; + }; + }) [ + { + button = "button_1"; + room = "living_room"; + } + { + button = "button_2"; + room = "bed_room"; + } + { + button = "button_3"; + room = "bed_room"; + } + ]; # kitchen light automation # ------------------------ @@ -340,7 +368,8 @@ in { } ]) [ "motion_sensor_1" ]; - in lib.flatten (kitchen_lights ++ all_lights_off ++ room_lights_on); + in lib.flatten + (kitchen_lights ++ all_lights_off ++ room_lights_on ++ room_lights_off); # click = double => music an aus