Skip to content

Commit

Permalink
Display volume if changed externally (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
tetele authored Apr 15, 2024
1 parent e102887 commit 2611612
Showing 1 changed file with 14 additions and 0 deletions.
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

4 comments on commit 2611612

@jherby2k
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be missing a "then" on line 464 - won't compile

@tetele
Copy link
Owner Author

@tetele tetele commented on 2611612 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Sorry about that! I must have missed a line when I copied stuff over here.

I'll fix it in a minute, thanks!

@jherby2k
Copy link

@jherby2k jherby2k commented on 2611612 Apr 15, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tetele
Copy link
Owner Author

@tetele tetele commented on 2611612 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 48d279f

Please sign in to comment.