Skip to content

Commit

Permalink
Expose a notification switch to HA and pulse the top LED's when on. (#16
Browse files Browse the repository at this point in the history
)

* Change notification to services

Added notication_on and notificaiton_clear services.
  • Loading branch information
andrew-codechimp authored Mar 26, 2024
1 parent 427110b commit 605400e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 13 deletions.
43 changes: 37 additions & 6 deletions esphome/onju-voice-microwakeword.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ api:
- service: stop_va
then:
- voice_assistant.stop
- service: notification_on
then:
- script.execute: turn_on_notification
- service: notification_clear
then:
- script.execute: clear_notification

globals:
- id: thresh_percent
Expand All @@ -100,6 +106,9 @@ globals:
- id: touch_calibration_values_right
type: uint32_t[5]
restore_value: false
- id: notification
type: bool
restore_value: false

interval:
- interval: 1s
Expand Down Expand Up @@ -359,19 +368,41 @@ script:
then:
- if:
condition:
and:
- switch.is_on: use_wake_word
- binary_sensor.is_off: mute_switch
- lambda: return id(notification);
then:
- light.turn_on:
id: top_led
blue: 100%
red: 100%
green: 0%
brightness: 60%
effect: listening_ww
brightness: 100%
effect: slow_pulse
else:
- light.turn_off: top_led
- if:
condition:
and:
- switch.is_on: use_wake_word
- binary_sensor.is_off: mute_switch
then:
- light.turn_on:
id: top_led
blue: 100%
red: 100%
green: 0%
brightness: 60%
effect: listening_ww
else:
- light.turn_off: top_led

- id: turn_on_notification
then:
- lambda: id(notification) = true;
- script.execute: reset_led

- id: clear_notification
then:
- lambda: id(notification) = false;
- script.execute: reset_led

- id: turn_on_wake_word
then:
Expand Down
45 changes: 38 additions & 7 deletions esphome/onju-voice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ api:
- service: stop_va
then:
- voice_assistant.stop
- service: notification_on
then:
- script.execute: turn_on_notification
- service: notification_clear
then:
- script.execute: clear_notification

globals:
- id: thresh_percent
Expand All @@ -90,6 +96,9 @@ globals:
- id: touch_calibration_values_right
type: uint32_t[5]
restore_value: false
- id: notification
type: bool
restore_value: false

interval:
- interval: 1s
Expand Down Expand Up @@ -391,19 +400,41 @@ script:
then:
- if:
condition:
and:
- switch.is_on: use_wake_word
- binary_sensor.is_off: mute_switch
- lambda: return id(notification);
then:
- light.turn_on:
id: top_led
blue: 100%
red: 100%
green: 0%
brightness: 60%
effect: listening_ww
brightness: 100%
effect: slow_pulse
else:
- light.turn_off: top_led
- if:
condition:
and:
- switch.is_on: use_wake_word
- binary_sensor.is_off: mute_switch
then:
- light.turn_on:
id: top_led
blue: 100%
red: 100%
green: 0%
brightness: 60%
effect: listening_ww
else:
- light.turn_off: top_led

- id: turn_on_notification
then:
- lambda: id(notification) = true;
- script.execute: reset_led

- id: clear_notification
then:
- lambda: id(notification) = false;
- script.execute: reset_led

- id: set_volume
mode: restart
Expand Down Expand Up @@ -543,4 +574,4 @@ switch:
on_turn_on:
- script.execute: turn_on_wake_word
on_turn_off:
- script.execute: turn_off_wake_word
- script.execute: turn_off_wake_word

0 comments on commit 605400e

Please sign in to comment.