From ca4bfb1cbc884bacf04622d7b53813f51aaf0a15 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 7 Oct 2025 21:00:57 +0200 Subject: couchlight: add lock --- esphome/config/couchlight.yaml | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'esphome') diff --git a/esphome/config/couchlight.yaml b/esphome/config/couchlight.yaml index 8797ac8..3dd125a 100644 --- a/esphome/config/couchlight.yaml +++ b/esphome/config/couchlight.yaml @@ -2,6 +2,11 @@ esphome: name: couchlight platform: ESP8266 board: d1_mini + on_boot: + then: + - lock.template.publish: + id: child_lock + state: UNLOCKED # Enable logging logger: @@ -48,6 +53,15 @@ output: platform: gpio pin: D2 +script: + - id: reset_child_lock + mode: restart + then: + - delay: 30min + - lock.template.publish: + id: child_lock + state: UNLOCKED + binary_sensor: - id: button_light1 name: "Couch 1 PushButton" @@ -60,7 +74,11 @@ binary_sensor: - delayed_on: 50ms on_press: then: - - light.toggle: light1 + - if: + condition: + lock.is_unlocked: child_lock + then: + - light.toggle: light1 internal: true # hide from UI - id: button_light2 @@ -74,5 +92,20 @@ binary_sensor: - delayed_on: 50ms on_press: then: - - light.toggle: light2 + - if: + condition: + lock.is_unlocked: child_lock + then: + - light.toggle: light2 internal: true # hide from UI + +lock: + - id: child_lock + platform: template + name: "Child Lock" + optimistic: true + on_lock: + - script.execute: reset_child_lock + on_unlock: + - script.stop: reset_child_lock + -- cgit v1.2.3