From 4c950c3d87d21eeb57891d11f70a63c042b82ccb Mon Sep 17 00:00:00 2001 From: tetele Date: Mon, 15 Apr 2024 13:01:19 +0300 Subject: [PATCH] Display volume if changed externally --- esphome/onju-voice.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/esphome/onju-voice.yaml b/esphome/onju-voice.yaml index d10ea36..4d3fcf3 100644 --- a/esphome/onju-voice.yaml +++ b/esphome/onju-voice.yaml @@ -130,6 +130,17 @@ media_player: mute_pin: number: GPIO21 inverted: True + on_state: + then: + - lambda: |- + static float old_volume = -1; + float new_volume = id(onju_out).volume; + if(abs(new_volume-old_volume) > 0.0001) { + if(old_volume != -1) { + id(show_volume)->execute(); + } + } + old_volume = new_volume; microphone: - platform: i2s_audio @@ -447,6 +458,9 @@ script: - media_player.volume_set: id: onju_out volume: !lambda return clamp(id(onju_out).volume+volume, 0.0f, 1.0f); + + - id: show_volume + mode: restart - light.turn_on: id: top_led effect: show_volume