Skip to content

Commit

Permalink
Add optional power restore mode
Browse files Browse the repository at this point in the history
Add optional power restore mode
  • Loading branch information
tarontop authored Mar 11, 2024
1 parent 7fec181 commit 082c51b
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion athom-smart-plug-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,28 @@ esphome:
project:
name: "${project_name}"
version: "${project_version}"

on_boot:
- priority: -100
then:
- select.set_index:
id: power_mode
index: !lambda |-
return id(restore_mode)-1;
- lambda: |-
switch(id(restore_mode))
{
case 1:{
id(relay).turn_off();
break;
}
case 2:{
id(relay).turn_on();
break;
}
default:{
break;
}
}
esp8266:
board: esp8285
restore_from_flash: true
Expand Down Expand Up @@ -68,6 +89,24 @@ globals:
type: float
restore_value: yes
initial_value: '0.0'
- id: restore_mode
type: int
restore_value: yes
initial_value: "3"

select:
- platform: template
name: "Power On State"
id: "power_mode"
optimistic: true
options:
- Always Off
- Always On
- Restore Power Off State
on_value:
then:
- lambda: |-
id(restore_mode)=i+1;
binary_sensor:
- platform: status
Expand Down

0 comments on commit 082c51b

Please sign in to comment.