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