-
Notifications
You must be signed in to change notification settings - Fork 55
Description
I’ve got 4 of the ESP32-C3 UK Plug and have flashed with the sample YAML. I then customised the YAML to turn off the features I don’t need and to enable features that I want.
Specifically, I disabled the API and WiFi timeouts to prevent unwanted reboots and added a toggle switch to flip the power off and on for 15 seconds.
The device is working fine except that it still reboots randomly throughout the day - maybe once or twice. Since the power toggles off and on when the esphome restart, this means that I can’t use the device for the desired purpose.
I’m assuming that there is some watchdog other than WiFi and API which is causing reboots. I can’t see what it might be. The only thing in the debug logs is a repeated debug message about the reactive power being negative. I’ve eliminated this by clamping the minimum valid to zero and ignoring these invalid values.
Is anybody else seeing these stability issues? Here is the generated YAML…
substitutions:
timezone: Europe/London
ntp_update_interval: 5min
ntp_server_1: 0.uk.pool.ntp.org
ntp_server_2: 1.uk.pool.ntp.org
ntp_server_3: 2.uk.pool.ntp.org
topic_prefix: esphome
room: office
room_proper: Office
function: orbi
function_proper: Orbi
type: switch
type_proper: Switch
name: office-orbi-switch
id: office_orbi_switch
mqtt_client: mqtt_office_orbi_switch
friendly_name: Office Orbi Switch
device_description: Athom ESP32-C3 Plug for Office Orbi Switch
project_name: Athom Technology.Smart Plug V3
project_version: v1.0.7
relay_restore_mode: RESTORE_DEFAULT_ON
sensor_update_interval: 10s
current_limit: '16'
wifi_fast_connect: 'false'
log_level: INFO
hide_energy_sensor: 'true'
power_plug_type: power-socket-uk
ip: 192.168.86.102
esphome:
name: office-orbi-switch
comment: Athom ESP32-C3 Plug for Office Orbi Switch
area: office
friendly_name: Office Orbi Switch
name_add_mac_suffix: false
min_version: 2024.6.0
project:
name: Athom Technology.Smart Plug V3
version: v1.0.7
platformio_options:
board_build.mcu: esp32c3
board_build.variant: esp32c3
board_build.flash_mode: dio
on_boot:
- priority: 600.0
then:
- select.set_index:
id: power_mode
index: !lambda |-
return id(restore_mode)-1;
- lambda: !lambda |-
switch(id(restore_mode))
{
case 1:{
id(relay).turn_off();
break;
}
case 2:{
id(relay).turn_on();
break;
}
default:{
break;
}
}
build_path: build/office-orbi-switch
includes: []
libraries: []
esp32:
board: esp32-c3-devkitm-1
flash_size: 4MB
variant: ESP32C3
framework:
version: 2.0.5
advanced:
ignore_efuse_custom_mac: false
source: ~3.20005.0
platform_version: platformio/espressif32@5.4.0
type: arduino
preferences:
flash_write_interval: 5min
text_sensor:
- platform: version
state_topic: esphome/office-orbi-switch/version/state
name: ESPHome Version
retain: true
disabled_by_default: false
icon: mdi:new-box
entity_category: diagnostic
hide_timestamp: false
- platform: version
state_topic: esphome/office-orbi-switch/version/state
name: ESPHome Version
retain: true
disabled_by_default: false
icon: mdi:new-box
entity_category: diagnostic
hide_timestamp: false
- platform: wifi_info
ip_address:
name: IP
state_topic: esphome/office-orbi-switch/ip/state
icon: mdi:ip-network-outline
retain: false
disabled_by_default: false
entity_category: diagnostic
update_interval: 1s
- platform: template
name: Uptime
id: uptime_human
entity_category: diagnostic
update_interval: 60s
icon: mdi:clock-start
state_topic: esphome/office-orbi-switch/uptime_human_readable/state
retain: false
lambda: !lambda |-
int seconds = (id(uptime_sensor).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else {
return { (String(seconds) +"s").c_str() };
}
disabled_by_default: false
ota:
- platform: http_request
- platform: esphome
version: 2
port: 3232
http_request:
verify_ssl: false
useragent: ESPHome/2024.12.4 (https://esphome.io)
follow_redirects: true
redirect_limit: 3
timeout: 4500ms
button:
- platform: template
name: Upgrade Firmware
id: upgrade_button
state_topic: esphome/office-orbi-switch/upgrade/state
retain: false
entity_category: config
icon: mdi:memory-arrow-down
on_press:
- then:
- logger.log:
format: Requesting upgrade.
level: INFO
tag: main
args: []
- ota.http_request.flash:
md5_url: https://esphome-ota.local:6054/office-orbi-switch.md5
url: https://esphome-ota.local:6054/office-orbi-switch.bin
disabled_by_default: false
- platform: restart
name: Restart Device
id: restart_button
state_topic: esphome/office-orbi-switch/restart/state
retain: false
disabled_by_default: false
icon: mdi:restart
entity_category: config
device_class: restart
- platform: safe_mode
name: Enter Safe Mode
id: safe_mode_button
state_topic: esphome/office-orbi-switch/safe_mode/state
retain: false
disabled_by_default: false
icon: mdi:restart-alert
entity_category: config
device_class: restart
- platform: shutdown
name: Shutdown Device
id: shutdown_button
state_topic: esphome/office-orbi-switch/shutdown/state
retain: false
disabled_by_default: false
icon: mdi:power
entity_category: config
- platform: template
name: Toggle Power
id: toggle_button
state_topic: esphome/office-orbi-switch/toggle/state
retain: false
icon: mdi:swap-vertical
on_press:
- then:
- logger.log:
format: Toggling power OFF for %.1f seconds.
args:
- !lambda |-
id(toggle_duration).state
level: INFO
tag: main
- switch.turn_off:
id: relay
- delay: !lambda |-
return id(toggle_duration).state * 1000;
- logger.log:
format: Toggling power ON.
level: INFO
tag: main
args: []
- switch.turn_on:
id: relay
disabled_by_default: false
wifi:
fast_connect: true
use_address: 192.168.86.102
ap:
ssid: office-orbi-switch-fb
password: Xxxxxxxxxxx
ap_timeout: 5min
domain: .local
reboot_timeout: 15min
power_save_mode: LIGHT
passive_scan: false
enable_on_boot: true
networks:
- ssid: xxxxxxxxxxx
password: Xxxxxxxxxxx
priority: 0.0
captive_portal: {}
time:
- platform: sntp
id: sntp_time
timezone: GMT0BST,M3.5.0/1,M10.5.0
update_interval: 5min
servers:
- 0.uk.pool.ntp.org
- 1.uk.pool.ntp.org
- 2.uk.pool.ntp.org
sensor:
- platform: uptime
name: Uptime
id: uptime_sensor
retain: false
internal: true
update_interval: 60s
state_topic: ''
disabled_by_default: false
force_update: false
unit_of_measurement: s
icon: mdi:timer-outline
accuracy_decimals: 0
device_class: duration
state_class: total_increasing
entity_category: diagnostic
type: seconds
- platform: cse7766
id: athom_cse7766
current:
name: Current
icon: mdi:current-ac
retain: false
filters:
- throttle_average: 10s
- lambda: !lambda |-
if (x < 0.060) return 0.0; else return x;
on_value_range:
- above: 16.0
then:
- switch.turn_off:
id: relay
disabled_by_default: false
force_update: false
unit_of_measurement: A
accuracy_decimals: 2
device_class: current
state_class: measurement
voltage:
name: Voltage
icon: mdi:sine-wave
retain: false
filters:
- throttle_average: 10s
disabled_by_default: false
force_update: false
unit_of_measurement: V
accuracy_decimals: 1
device_class: voltage
state_class: measurement
power:
name: Power
id: power_sensor
icon: mdi:power
retain: false
filters:
- throttle_average: 10s
- lambda: !lambda |-
if (x < 3.0) return 0.0; else return x;
disabled_by_default: false
force_update: false
unit_of_measurement: W
accuracy_decimals: 1
device_class: power
state_class: measurement
energy:
name: Energy
id: energy
icon: mdi:lightning-bolt
retain: false
unit_of_measurement: kWh
filters:
- throttle: 10s
- multiply: 0.001
on_value:
- then:
- lambda: !lambda |-
static float previous_energy_value = 0.0;
float current_energy_value = id(energy).state;
id(total_energy) += current_energy_value - previous_energy_value;
previous_energy_value = current_energy_value;
id(total_energy_sensor).update();
disabled_by_default: false
force_update: false
accuracy_decimals: 3
device_class: energy
state_class: total_increasing
apparent_power:
name: Apparent Power
icon: mdi:power
retain: false
filters:
- throttle_average: 10s
disabled_by_default: false
force_update: false
unit_of_measurement: VA
accuracy_decimals: 1
device_class: apparent_power
state_class: measurement
reactive_power:
name: Reactive Power
icon: mdi:flash
retain: false
filters:
- clamp:
min_value: 0.0
ignore_out_of_range: true
max_value: .nan
- throttle_average: 10s
disabled_by_default: false
force_update: false
unit_of_measurement: var
accuracy_decimals: 1
device_class: reactive_power
state_class: measurement
power_factor:
name: Power Factor
icon: mdi:percent-outline
retain: false
filters:
- throttle_average: 10s
disabled_by_default: false
force_update: false
accuracy_decimals: 2
device_class: power_factor
state_class: measurement
- platform: template
name: Total Energy
id: total_energy_sensor
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
icon: mdi:lightning-bolt
retain: false
accuracy_decimals: 3
lambda: !lambda |-
return id(total_energy);
update_interval: 10s
disabled_by_default: false
force_update: false
- platform: total_daily_energy
name: Total Daily Energy
restore: true
power_id: power_sensor
unit_of_measurement: kWh
icon: mdi:hours-24
retain: false
accuracy_decimals: 3
filters:
- multiply: 0.001
disabled_by_default: false
force_update: false
device_class: energy
state_class: total_increasing
method: right
logger:
level: DEBUG
logs:
sensor: INFO
text_sensor: INFO
esp32.preferences: INFO
cse7766: INFO
baud_rate: 115200
tx_buffer_size: 512
deassert_rts_dtr: false
hardware_uart: USB_CDC
debug:
update_interval: 60s
external_components:
- source:
url: https://github.com/barcar/esphome_syslog
ref: main
type: git
refresh: 0s
components: all
syslog:
ip_address: 192.168.86.12
port: 514
enable_logger: true
strip_colors: true
min_level: DEBUG
web_server:
port: 80
version: 3
enable_private_network_access: true
include_internal: false
ota: true
log: true
css_url: ''
js_url: https://oi.esphome.io/v3/www.js
mqtt:
broker: 192.168.86.12
username: xxxxxxxx
password: xxxxxxxxxx
id: mqtt_office_orbi_switch
topic_prefix: esphome/office-orbi-switch
discovery_prefix: esphome_discovery
discovery: false
log_topic:
topic: esphome/office-orbi-switch/log
qos: 0
retain: true
on_message:
- topic: esphome/office-orbi-switch/safe_mode/command
payload: 'ON'
then:
- button.press:
id: safe_mode_button
qos: 0
- topic: esphome/office-orbi-switch/restart/command
payload: 'ON'
then:
- button.press:
id: restart_button
qos: 0
- topic: esphome/office-orbi-switch/shutdown/command
payload: 'ON'
then:
- button.press:
id: shutdown_button
qos: 0
- topic: esphome/office-orbi-switch/upgrade/command
payload: 'ON'
then:
- button.press:
id: upgrade_button
qos: 0
enable_on_boot: true
port: 1883
clean_session: false
discovery_retain: true
discover_ip: true
discovery_unique_id_generator: legacy
discovery_object_id_generator: none
use_abbreviations: true
keepalive: 15s
reboot_timeout: 15min
publish_nan_as_none: false
birth_message:
topic: esphome/office-orbi-switch/status
payload: online
qos: 0
retain: true
will_message:
topic: esphome/office-orbi-switch/status
payload: offline
qos: 0
retain: true
shutdown_message:
topic: esphome/office-orbi-switch/status
payload: offline
qos: 0
retain: true
prometheus:
include_internal: false
relabel: {}
esp32_improv:
authorizer: null
identify_duration: 10s
authorized_duration: 1min
wifi_timeout: 1min
uart:
- rx_pin:
number: 20
mode:
input: true
output: false
open_drain: false
pullup: false
pulldown: false
inverted: false
ignore_pin_validation_error: false
ignore_strapping_warning: false
drive_strength: 20.0
baud_rate: 4800
data_bits: 8
stop_bits: 1
parity: EVEN
rx_buffer_size: 256
globals:
- id: total_energy
type: float
restore_value: true
initial_value: '0.0'
- id: restore_mode
type: int
restore_value: true
initial_value: '2'
select:
- platform: template
name: Power On State
id: power_mode
optimistic: true
retain: false
icon: mdi:electric-switch
entity_category: config
options:
- Always Off
- Always On
- Restore Power Off State
on_value:
- then:
- lambda: !lambda |-
id(restore_mode)=i+1;
disabled_by_default: false
update_interval: 60s
initial_option: Always Off
binary_sensor:
- platform: status
name: Status
icon: mdi:check-network-outline
entity_category: diagnostic
disabled_by_default: false
device_class: connectivity
- platform: gpio
pin:
number: 3
mode:
input: true
pullup: true
output: false
open_drain: false
pulldown: false
inverted: true
ignore_pin_validation_error: false
ignore_strapping_warning: false
drive_strength: 20.0
name: Power Button
id: power_button
retain: false
disabled_by_default: true
internal: true
on_multi_click:
- timing:
- state: true
min_length: 0ms
max_length: 1s
- state: false
min_length: 200ms
then:
- switch.toggle:
id: relay
invalid_cooldown: 1s
number:
- platform: template
name: Toggle Duration
id: toggle_duration
entity_category: config
icon: mdi:timer-cog-outline
unit_of_measurement: seconds
mode: BOX
initial_value: 15.0
min_value: 5.0
max_value: 120.0
step: 5.0
optimistic: true
state_topic: ''
disabled_by_default: false
update_interval: 60s
switch:
- platform: gpio
name: Power Switch
pin:
number: 5
mode:
output: true
input: false
open_drain: false
pullup: false
pulldown: false
inverted: false
ignore_pin_validation_error: false
ignore_strapping_warning: false
drive_strength: 20.0
id: relay
restore_mode: RESTORE_DEFAULT_ON
icon: mdi:power-socket-uk
retain: false
disabled_by_default: false
interlock_wait_time: 0ms
light:
- platform: status_led
name: Status LED
id: blue_led
icon: mdi:lightbulb-outline
retain: false
disabled_by_default: true
pin:
inverted: true
number: 6
mode:
output: true
input: false
open_drain: false
pullup: false
pulldown: false
ignore_pin_validation_error: false
ignore_strapping_warning: false
drive_strength: 20.0
restore_mode: ALWAYS_OFF
output: []