diff options
Diffstat (limited to 'esphome/config/couchlight.yaml')
| -rw-r--r-- | esphome/config/couchlight.yaml | 37 |
1 files changed, 35 insertions, 2 deletions
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: | |||
| 2 | name: couchlight | 2 | name: couchlight |
| 3 | platform: ESP8266 | 3 | platform: ESP8266 |
| 4 | board: d1_mini | 4 | board: d1_mini |
| 5 | on_boot: | ||
| 6 | then: | ||
| 7 | - lock.template.publish: | ||
| 8 | id: child_lock | ||
| 9 | state: UNLOCKED | ||
| 5 | 10 | ||
| 6 | # Enable logging | 11 | # Enable logging |
| 7 | logger: | 12 | logger: |
| @@ -48,6 +53,15 @@ output: | |||
| 48 | platform: gpio | 53 | platform: gpio |
| 49 | pin: D2 | 54 | pin: D2 |
| 50 | 55 | ||
| 56 | script: | ||
| 57 | - id: reset_child_lock | ||
| 58 | mode: restart | ||
| 59 | then: | ||
| 60 | - delay: 30min | ||
| 61 | - lock.template.publish: | ||
| 62 | id: child_lock | ||
| 63 | state: UNLOCKED | ||
| 64 | |||
| 51 | binary_sensor: | 65 | binary_sensor: |
| 52 | - id: button_light1 | 66 | - id: button_light1 |
| 53 | name: "Couch 1 PushButton" | 67 | name: "Couch 1 PushButton" |
| @@ -60,7 +74,11 @@ binary_sensor: | |||
| 60 | - delayed_on: 50ms | 74 | - delayed_on: 50ms |
| 61 | on_press: | 75 | on_press: |
| 62 | then: | 76 | then: |
| 63 | - light.toggle: light1 | 77 | - if: |
| 78 | condition: | ||
| 79 | lock.is_unlocked: child_lock | ||
| 80 | then: | ||
| 81 | - light.toggle: light1 | ||
| 64 | internal: true # hide from UI | 82 | internal: true # hide from UI |
| 65 | 83 | ||
| 66 | - id: button_light2 | 84 | - id: button_light2 |
| @@ -74,5 +92,20 @@ binary_sensor: | |||
| 74 | - delayed_on: 50ms | 92 | - delayed_on: 50ms |
| 75 | on_press: | 93 | on_press: |
| 76 | then: | 94 | then: |
| 77 | - light.toggle: light2 | 95 | - if: |
| 96 | condition: | ||
| 97 | lock.is_unlocked: child_lock | ||
| 98 | then: | ||
| 99 | - light.toggle: light2 | ||
| 78 | internal: true # hide from UI | 100 | internal: true # hide from UI |
| 101 | |||
| 102 | lock: | ||
| 103 | - id: child_lock | ||
| 104 | platform: template | ||
| 105 | name: "Child Lock" | ||
| 106 | optimistic: true | ||
| 107 | on_lock: | ||
| 108 | - script.execute: reset_child_lock | ||
| 109 | on_unlock: | ||
| 110 | - script.stop: reset_child_lock | ||
| 111 | |||
