From 77809d96232fc5fe3cd57c41360860a35c47e59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grondek?= Date: Sun, 31 Mar 2024 21:59:04 +0200 Subject: [PATCH] Update control of music to play when lock is locked --- README.md | 3 ++- hs-elevator.yaml | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 27abdce..a018b4d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ or Wi-Fi * turns on/off light * turns on/off music * Lock switch turns fan for 5 minutes -* Music plays on a loop while light is on +* Music plays on a loop while lock sensor senses that lock is locked +* Music turns off when lock sensor senses that lock is unlocked ## Pinout diff --git a/hs-elevator.yaml b/hs-elevator.yaml index e9e4ee5..6b48cf7 100644 --- a/hs-elevator.yaml +++ b/hs-elevator.yaml @@ -21,19 +21,25 @@ binary_sensor: - platform: gpio pin: 25 id: button - on_click: + on_click: then: - switch.toggle: light_relay - platform: gpio id: lock_status pin: 14 - on_release: + on_state: then: + - dfplayer.play_folder: + folder: 1 + loop: true + on_release: + then: + - dfplayer.stop - switch.turn_on: fan_relay - delay: 5min - if: condition: - - binary_sensor.is_off: lock_status + - binary_sensor.is_off: lock_status then: - switch.turn_off: fan_relay @@ -41,16 +47,12 @@ switch: - platform: gpio id: light_relay pin: 26 - on_turn_on: + on_turn_on: then: - - dfplayer.play_folder: - folder: 1 - loop: true - - switch.turn_off: down_led + - switch.turn_off: down_led - switch.turn_on: up_led - on_turn_off: + on_turn_off: then: - - dfplayer.stop - switch.turn_off: up_led - switch.turn_on: down_led - platform: gpio @@ -62,4 +64,3 @@ switch: - platform: gpio id: down_led pin: 33 -