From a3a54fd60df9ce81f18e2b36d4f2c4ed7b78974e Mon Sep 17 00:00:00 2001 From: tetele Date: Wed, 15 Jan 2025 21:30:25 +0000 Subject: [PATCH] Fix volume display --- esphome/onju-modules/base.yaml | 4 ++-- esphome/onju-modules/media_player.yaml | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/esphome/onju-modules/base.yaml b/esphome/onju-modules/base.yaml index dfabb81..d6e9e9a 100644 --- a/esphome/onju-modules/base.yaml +++ b/esphome/onju-modules/base.yaml @@ -225,8 +225,8 @@ script: - id: control_led_volume_touched then: - - lambda: | - id(volume_touched) = false; + - lambda: id(volume_touched) = false; + - script.execute: control_led - id: control_led_voice_assistant_waiting_for_command_phase then: [] diff --git a/esphome/onju-modules/media_player.yaml b/esphome/onju-modules/media_player.yaml index 9f1fbd5..0fc5f3a 100644 --- a/esphome/onju-modules/media_player.yaml +++ b/esphome/onju-modules/media_player.yaml @@ -13,17 +13,13 @@ media_player: float new_volume = id(onju_out).volume; if(abs(new_volume-old_volume) > 0.0001) { if(old_volume != -1) { - id(show_volume) = true; + id(volume_touched) = true; id(control_led)->execute(); } } old_volume = new_volume; globals: - - id: show_volume - type: bool - restore_value: no - initial_value: "false" light: - id: !extend top_led @@ -56,24 +52,25 @@ script: id: onju_out volume: !lambda return clamp(id(onju_out).volume+volume, 0.0f, 1.0f); - lambda: | - id(show_volume) = true; + // Required for when volume is changed externally + id(volume_touched) = true; - script.execute: control_led - - id: !extend control_led_volume_touched + - id: !remove control_led_volume_touched + - id: control_led_volume_touched + mode: restart then: - if: condition: - lambda: "return id(show_volume);" + lambda: "return id(volume_touched);" then: - light.turn_on: id: top_led effect: show_volume - delay: 1s - lambda: | - id(show_volume) = false; + id(volume_touched) = false; - script.execute: control_led - else: - - light.turn_off: top_led binary_sensor: - id: !extend volume_down