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

New factory Reset Process #224

Merged
merged 4 commits into from
Dec 18, 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
47 changes: 39 additions & 8 deletions home-assistant-voice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ globals:
- id: is_timer_active
type: bool
restore_value: false
# Global variable storing if a factory reset was requested. If it is set to true, the device will factory reset once the center button is released
- id: factory_reset_requested
type: bool
restore_value: no
initial_value: 'false'

switch:
# This is the master mute switch. It is exposed to Home Assistant. The user can only turn it on and off if the hardware switch is off. (The hardware switch overrides the software one)
Expand Down Expand Up @@ -271,6 +276,12 @@ binary_sensor:
- script.execute: control_leds
on_release:
- script.execute: control_leds
# If a factory reset is requested, factory reset on release
- if:
condition:
lambda: return id(factory_reset_requested);
then:
- button.press: factory_reset_button
on_multi_click:
# Simple Click:
# - Abort "things" in order
Expand Down Expand Up @@ -446,20 +457,38 @@ binary_sensor:
sound_file: !lambda return id(factory_reset_initiated_sound);
- wait_until:
binary_sensor.is_off: center_button
- light.turn_off: voice_assistant_leds
- script.execute:
id: play_sound
priority: true
sound_file: !lambda return id(factory_reset_cancelled_sound);
# Factory Reset
- if:
condition:
lambda: return !id(factory_reset_requested);
then:
- light.turn_off: voice_assistant_leds
- script.execute:
id: play_sound
priority: true
sound_file: !lambda return id(factory_reset_cancelled_sound);
# Factory Reset Confirmed.
# . Audible warning to prompt user to release the button
# . Set factory_reset_requested to true
- timing:
- ON for at least 22s
then:
- if:
condition:
lambda: return !id(dial_touched);
then:
- button.press: factory_reset_button
- script.execute:
id: play_sound
priority: true
sound_file: !lambda return id(factory_reset_confirmed_sound);
- light.turn_on:
brightness: 100%
red: 100%
green: 0%
blue: 0%
id: voice_assistant_leds
effect: "none"
- lambda: id(factory_reset_requested) = true;

# Hardware mute switch (Side of the device)
- platform: gpio
id: hardware_mute_switch
Expand All @@ -481,7 +510,7 @@ binary_sensor:
- switch.template.publish:
id: master_mute_switch
state: OFF
# Audio Jack PLugged sensor
# Audio Jack Plugged sensor
- platform: gpio
id: jack_plugged
# Debouncing it a bit because it can be activated back and forth as you plug the audio jack
Expand Down Expand Up @@ -1440,6 +1469,8 @@ media_player:
file: https://github.com/esphome/home-assistant-voice-pe/raw/dev/sounds/factory_reset_initiated.mp3
- id: factory_reset_cancelled_sound
file: https://github.com/esphome/home-assistant-voice-pe/raw/dev/sounds/factory_reset_cancelled.mp3
- id: factory_reset_confirmed_sound
file: https://github.com/esphome/home-assistant-voice-pe/raw/dev/sounds/factory_reset_confirmed.mp3
- id: jack_connected_sound
file: https://github.com/esphome/home-assistant-voice-pe/raw/dev/sounds/jack_connected.flac
- id: jack_disconnected_sound
Expand Down
Loading