Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display volume if changed externally #32

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions esphome/onju-voice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down