Skip to content

Commit

Permalink
Merge pull request #29 from Roving-Ronin/main
Browse files Browse the repository at this point in the history
Add on_boot selector
  • Loading branch information
tarontop authored Oct 14, 2024
2 parents 096b684 + 314a346 commit 26e0c2f
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions athom-smart-plug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ substitutions:
# Project Name
project_name: "Athom Technology.Smart Plug V3"
# Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
project_version: "v1.0.3"
project_version: "v1.0.4"
# Restore the relay (GPO switch) upon reboot to state:
relay_restore_mode: RESTORE_DEFAULT_OFF
relay_restore_mode: RESTORE_DEFAULT_ON
# Set the update interval for sensors
sensor_update_interval: 10s
# Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
Expand Down Expand Up @@ -50,6 +50,29 @@ esphome:
board_build.mcu: esp32c3
board_build.variant: esp32c3
board_build.flash_mode: dio
on_boot:
- priority: 600
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;
}
}
esp32:
board: esp32-c3-devkitm-1
Expand Down Expand Up @@ -109,6 +132,26 @@ globals:
restore_value: yes
initial_value: '0.0'

- id: restore_mode
type: int
restore_value: yes
initial_value: "2" # 0 = Always_Off. 1 = Restore_Power_Off. 2 = Always_On.

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

0 comments on commit 26e0c2f

Please sign in to comment.