mirror of
https://github.com/athom-tech/esp32-configs.git
synced 2026-07-27 19:56:13 +00:00
625 lines
16 KiB
YAML
625 lines
16 KiB
YAML
substitutions:
|
|
name: "athom-em-6"
|
|
friendly_name: "Athom Energy Meter"
|
|
# Allows ESP device to be automatically lined to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
|
|
room: ""
|
|
device_description: "athom bl0906 energy meter (6 channels)"
|
|
project_name: "Athom Technology.Athom Energy Meter(6 Channels)"
|
|
project_version: "3.0.4"
|
|
update_interval: 5s
|
|
# Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
|
|
dns_domain: ".local"
|
|
# Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
|
|
timezone: ""
|
|
# Set the duration between the sntp service polling ntp.org servers for an update
|
|
sntp_update_interval: 6h
|
|
# Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
|
|
sntp_server_1: "0.pool.ntp.org"
|
|
sntp_server_2: "1.pool.ntp.org"
|
|
sntp_server_3: "2.pool.ntp.org"
|
|
# Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
|
|
wifi_fast_connect: "false"
|
|
# Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
|
log_level: "DEBUG"
|
|
# Enable or disable the use of IPv6 networking on the device
|
|
ipv6_enable: "false"
|
|
|
|
#############################ESP32C3###########################
|
|
bl0906_tx_pin: GPIO7
|
|
bl0906_rx_pin: GPIO8
|
|
button_pin: GPIO9
|
|
led_pin: GPIO10
|
|
clk_pin: GPIO2
|
|
mosi_pin: GPIO3
|
|
backlight_pin: GPIO18
|
|
reset_pin: GPIO4
|
|
dc_pin: GPIO5
|
|
cs_pin: GPIO6
|
|
#############################ESP32C3###########################
|
|
|
|
#############################ESP32-WROOM-32D###########################
|
|
# bl0906_tx_pin: GPIO12
|
|
# bl0906_rx_pin: GPIO14
|
|
# button_pin: GPIO0
|
|
# led_pin: GPIO15
|
|
# backlight_pin: GPIO33
|
|
# clk_pin: GPIO16
|
|
# mosi_pin: GPIO17
|
|
# reset_pin: GPIO5
|
|
# dc_pin: GPIO18
|
|
# cs_pin: GPIO19
|
|
#############################ESP32-WROOM-32D###########################
|
|
esphome:
|
|
name: "${name}"
|
|
friendly_name: "${friendly_name}"
|
|
comment: "${device_description}"
|
|
area: "${room}"
|
|
name_add_mac_suffix: true
|
|
min_version: 2026.6.0
|
|
project:
|
|
name: "${project_name}"
|
|
version: "${project_version}"
|
|
|
|
esp32:
|
|
board: esp32-c3-devkitm-1
|
|
flash_size: 4MB
|
|
variant: ESP32C3
|
|
framework:
|
|
type: esp-idf
|
|
version: recommended
|
|
sdkconfig_options:
|
|
# @grigi found in testing that these options resulted in better responsiveness.
|
|
# BLE 4.2 is supported by ALL ESP32 boards that have bluetooth, the original and derivatives.
|
|
CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
|
|
# Also enable this on any derivative boards (S2, C3 etc) but not the original ESP32.
|
|
CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
|
|
# Extend the watchdog timeout, so the device reboots if the device appears locked up for over 10 seconds.
|
|
CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"
|
|
|
|
# esp32:
|
|
# board: esp32dev
|
|
# flash_size: 4MB
|
|
# variant: ESP32
|
|
# framework:
|
|
# type: arduino
|
|
# version: recommended
|
|
|
|
preferences:
|
|
flash_write_interval: 5min
|
|
|
|
api:
|
|
# reboot_timeout: 0s
|
|
# Only enable BLE tracking when wifi is up and api is connected
|
|
# Gives single-core ESP32-C3 devices time to manage wifi and authenticate with api
|
|
on_client_connected:
|
|
- esp32_ble_tracker.start_scan:
|
|
continuous: true
|
|
# Disable BLE tracking when there are no api connections live
|
|
on_client_disconnected:
|
|
if:
|
|
condition:
|
|
not:
|
|
api.connected:
|
|
then:
|
|
- esp32_ble_tracker.stop_scan:
|
|
|
|
ota:
|
|
- platform: esphome
|
|
id: ota_esphome
|
|
# Enables OTA firmware flashing from a URL (used by the update component below)
|
|
- platform: http_request
|
|
id: ota_http_request
|
|
|
|
# Required by the ota http_request platform and the update component.
|
|
# verify_ssl: false skips TLS cert validation to reduce heap/RAM pressure during
|
|
# the download; the manifest's MD5 still verifies firmware integrity before flashing.
|
|
http_request:
|
|
id: http_request_component
|
|
verify_ssl: false
|
|
|
|
update:
|
|
# Managed updates via HTTP request: periodically checks the published manifest
|
|
# and exposes a "Firmware Update" entity, pointing at this device's GitHub Pages
|
|
# manifest. Pages URLs avoid the redirect/buffer issues of Release download URLs.
|
|
- platform: http_request
|
|
id: update_http_request
|
|
name: "Firmware Update"
|
|
source: https://athom-tech.github.io/esp32-configs/firmware/athom-energy-monitor-x6.manifest.json
|
|
# update_interval defaults to 6h (how often it checks, not installs)
|
|
|
|
logger:
|
|
baud_rate: 115200
|
|
level: ${log_level}
|
|
hardware_uart: UART0
|
|
|
|
mdns:
|
|
disabled: false
|
|
|
|
web_server:
|
|
port: 80
|
|
|
|
network:
|
|
enable_ipv6: ${ipv6_enable}
|
|
|
|
wifi:
|
|
ap: {}
|
|
fast_connect: "${wifi_fast_connect}"
|
|
domain: "${dns_domain}"
|
|
|
|
captive_portal:
|
|
|
|
improv_serial:
|
|
|
|
esp32_improv:
|
|
authorizer: none
|
|
|
|
esp32_ble_tracker:
|
|
scan_parameters:
|
|
# Don't auto start BLE scanning, we control it in the `api` block's automation.
|
|
continuous: false
|
|
active: true # send scan-request packets to gather more info, like device name for some devices.
|
|
interval: 320ms # default 320ms - how long to spend on each advert channel
|
|
window: 300ms # default 30ms - how long to actually "listen" in each interval. Reduce this if device is unstable.
|
|
# If the device cannot keep up or becomes unstable, reduce the "window" setting. This may be
|
|
# required if your device is controlling other sensors or doing PWM for lights etc.
|
|
|
|
bluetooth_proxy:
|
|
active: true
|
|
|
|
dashboard_import:
|
|
package_import_url: github://athom-tech/esp32-configs/athom-energy-monitor-x6.yaml
|
|
|
|
globals:
|
|
- id: id_Energy_sum_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_sum_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
- id: id_Energy_1_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_1_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
- id: id_Energy_2_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_2_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
- id: id_Energy_3_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_3_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
- id: id_Energy_4_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_4_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
- id: id_Energy_5_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_5_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
- id: id_Energy_6_persist
|
|
type: float
|
|
restore_value: yes
|
|
initial_value: '0.0'
|
|
- id: id_Energy_6_lastvalue
|
|
type: float
|
|
restore_value: no
|
|
initial_value: '0.0'
|
|
|
|
uart:
|
|
tx_pin: "$bl0906_tx_pin"
|
|
rx_pin: "$bl0906_rx_pin"
|
|
baud_rate: 19200
|
|
id: uart_bl0906
|
|
|
|
light:
|
|
- platform: status_led
|
|
name: "Status LED"
|
|
id: blue_led
|
|
disabled_by_default: true
|
|
pin: $led_pin
|
|
|
|
binary_sensor:
|
|
- platform: status
|
|
name: "Status"
|
|
entity_category: diagnostic
|
|
|
|
- platform: gpio
|
|
pin:
|
|
number: "$button_pin"
|
|
mode: INPUT_PULLUP
|
|
inverted: true
|
|
name: "Power Button"
|
|
disabled_by_default: true
|
|
on_multi_click:
|
|
- timing:
|
|
- ON for at least 4s
|
|
then:
|
|
- button.press: Reset
|
|
|
|
sensor:
|
|
- platform: uptime
|
|
name: "Uptime Sensor"
|
|
id: uptime_sensor
|
|
type:
|
|
timestamp
|
|
entity_category: "diagnostic"
|
|
|
|
- platform: wifi_signal
|
|
name: "WiFi Signal dB"
|
|
id: wifi_signal_db
|
|
update_interval: 60s
|
|
entity_category: "diagnostic"
|
|
|
|
- platform: copy
|
|
source_id: wifi_signal_db
|
|
name: "WiFi Signal Percent"
|
|
filters:
|
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
|
unit_of_measurement: "Signal %"
|
|
entity_category: "diagnostic"
|
|
device_class: ""
|
|
|
|
- platform: bl0906
|
|
id: id_bl0906
|
|
update_interval: "${update_interval}"
|
|
frequency:
|
|
name: 'Frequency'
|
|
id: 'Frequency'
|
|
temperature:
|
|
name: 'Temperature'
|
|
id: 'Temperature'
|
|
voltage:
|
|
name: 'Voltage'
|
|
id: 'Voltage'
|
|
channel_1:
|
|
current:
|
|
name: 'Current_1'
|
|
id: 'Current_1'
|
|
power:
|
|
name: 'Power_1'
|
|
id: 'Power_1'
|
|
energy:
|
|
id: 'Energy_1'
|
|
name: 'Energy_1_Internal'
|
|
internal: true
|
|
channel_2:
|
|
current:
|
|
name: 'Current_2'
|
|
id: 'Current_2'
|
|
power:
|
|
name: 'Power_2'
|
|
id: 'Power_2'
|
|
energy:
|
|
id: 'Energy_2'
|
|
name: 'Energy_2_Internal'
|
|
internal: true
|
|
channel_3:
|
|
current:
|
|
name: 'Current_3'
|
|
id: 'Current_3'
|
|
power:
|
|
name: 'Power_3'
|
|
id: 'Power_3'
|
|
energy:
|
|
id: 'Energy_3'
|
|
name: 'Energy_3_Internal'
|
|
internal: true
|
|
channel_4:
|
|
current:
|
|
name: 'Current_4'
|
|
id: 'Current_4'
|
|
power:
|
|
name: 'Power_4'
|
|
id: 'Power_4'
|
|
energy:
|
|
id: 'Energy_4'
|
|
name: 'Energy_4_Internal'
|
|
internal: true
|
|
channel_5:
|
|
current:
|
|
name: 'Current_5'
|
|
id: 'Current_5'
|
|
power:
|
|
name: 'Power_5'
|
|
id: 'Power_5'
|
|
energy:
|
|
id: 'Energy_5'
|
|
name: 'Energy_5_Internal'
|
|
internal: true
|
|
channel_6:
|
|
current:
|
|
name: 'Current_6'
|
|
id: 'Current_6'
|
|
power:
|
|
name: 'Power_6'
|
|
id: 'Power_6'
|
|
energy:
|
|
id: 'Energy_6'
|
|
name: 'Energy_6_Internal'
|
|
internal: true
|
|
total_energy:
|
|
name: 'Total_Energy'
|
|
id: 'Energy_sum'
|
|
internal: true
|
|
total_power:
|
|
name: 'Total_Power'
|
|
id: 'Total_Power'
|
|
|
|
- platform: copy
|
|
name: 'Total_Energy'
|
|
id: Energy_sum_persist
|
|
source_id: Energy_sum
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_sum_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_sum_lastvalue) = id(Energy_sum).state;
|
|
}
|
|
if(x < id(id_Energy_sum_persist))
|
|
{
|
|
float delta = x - id(id_Energy_sum_lastvalue);
|
|
id(id_Energy_sum_persist) += delta;
|
|
id(id_Energy_sum_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_sum_persist) = x;
|
|
}
|
|
return id(id_Energy_sum_persist);
|
|
|
|
- platform: copy
|
|
name: 'Energy_1'
|
|
id: Energy_1_persist
|
|
source_id: Energy_1
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_1_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_1_lastvalue) = id(Energy_1).state;
|
|
}
|
|
if(x < id(id_Energy_1_persist))
|
|
{
|
|
float delta = x - id(id_Energy_1_lastvalue);
|
|
id(id_Energy_1_persist) += delta;
|
|
id(id_Energy_1_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_1_persist) = x;
|
|
}
|
|
return id(id_Energy_1_persist);
|
|
|
|
- platform: copy
|
|
name: 'Energy_2'
|
|
id: Energy_2_persist
|
|
source_id: Energy_2
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_2_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_2_lastvalue) = id(Energy_2).state;
|
|
}
|
|
if(x < id(id_Energy_2_persist))
|
|
{
|
|
float delta = x - id(id_Energy_2_lastvalue);
|
|
id(id_Energy_2_persist) += delta;
|
|
id(id_Energy_2_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_2_persist) = x;
|
|
}
|
|
return id(id_Energy_2_persist);
|
|
|
|
- platform: copy
|
|
name: 'Energy_3'
|
|
id: Energy_3_persist
|
|
source_id: Energy_3
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_3_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_3_lastvalue) = id(Energy_3).state;
|
|
}
|
|
if(x < id(id_Energy_3_persist))
|
|
{
|
|
float delta = x - id(id_Energy_3_lastvalue);
|
|
id(id_Energy_3_persist) += delta;
|
|
id(id_Energy_3_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_3_persist) = x;
|
|
}
|
|
return id(id_Energy_3_persist);
|
|
|
|
- platform: copy
|
|
name: 'Energy_4'
|
|
id: Energy_4_persist
|
|
source_id: Energy_4
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_4_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_4_lastvalue) = id(Energy_4).state;
|
|
}
|
|
if(x < id(id_Energy_4_persist))
|
|
{
|
|
float delta = x - id(id_Energy_4_lastvalue);
|
|
id(id_Energy_4_persist) += delta;
|
|
id(id_Energy_4_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_4_persist) = x;
|
|
}
|
|
return id(id_Energy_4_persist);
|
|
|
|
- platform: copy
|
|
name: 'Energy_5'
|
|
id: Energy_5_persist
|
|
source_id: Energy_5
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_5_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_5_lastvalue) = id(Energy_5).state;
|
|
}
|
|
if(x < id(id_Energy_5_persist))
|
|
{
|
|
float delta = x - id(id_Energy_5_lastvalue);
|
|
id(id_Energy_5_persist) += delta;
|
|
id(id_Energy_5_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_5_persist) = x;
|
|
}
|
|
return id(id_Energy_5_persist);
|
|
|
|
- platform: copy
|
|
name: 'Energy_6'
|
|
id: Energy_6_persist
|
|
source_id: Energy_6
|
|
state_class: total_increasing
|
|
filters:
|
|
- lambda: |-
|
|
if(id(id_Energy_6_lastvalue) == 0.0 )
|
|
{
|
|
id(id_Energy_6_lastvalue) = id(Energy_6).state;
|
|
}
|
|
if(x < id(id_Energy_6_persist))
|
|
{
|
|
float delta = x - id(id_Energy_6_lastvalue);
|
|
id(id_Energy_6_persist) += delta;
|
|
id(id_Energy_6_lastvalue) = x;
|
|
}
|
|
else
|
|
{
|
|
id(id_Energy_6_persist) = x;
|
|
}
|
|
return id(id_Energy_6_persist);
|
|
|
|
button:
|
|
- platform: restart
|
|
name: "Restart"
|
|
entity_category: config
|
|
|
|
- platform: factory_reset
|
|
name: "Factory Reset"
|
|
id: Reset
|
|
entity_category: config
|
|
|
|
- platform: safe_mode
|
|
name: "Safe Mode"
|
|
internal: false
|
|
entity_category: config
|
|
|
|
- platform: template
|
|
name: Reset Energy
|
|
entity_category: config
|
|
on_press:
|
|
then:
|
|
- globals.set:
|
|
id: id_Energy_1_persist
|
|
value: '0.0'
|
|
- globals.set:
|
|
id: id_Energy_2_persist
|
|
value: '0.0'
|
|
- globals.set:
|
|
id: id_Energy_3_persist
|
|
value: '0.0'
|
|
- globals.set:
|
|
id: id_Energy_4_persist
|
|
value: '0.0'
|
|
- globals.set:
|
|
id: id_Energy_5_persist
|
|
value: '0.0'
|
|
- globals.set:
|
|
id: id_Energy_6_persist
|
|
value: '0.0'
|
|
- globals.set:
|
|
id: id_Energy_sum_persist
|
|
value: '0.0'
|
|
- bl0906.reset_energy: id_bl0906
|
|
|
|
text_sensor:
|
|
- platform: wifi_info
|
|
ip_address:
|
|
name: "IP Address"
|
|
id: ip_address
|
|
entity_category: diagnostic
|
|
ssid:
|
|
name: "Connected SSID"
|
|
id: ssid
|
|
entity_category: diagnostic
|
|
mac_address:
|
|
name: "Mac Address"
|
|
id: mac_address
|
|
entity_category: diagnostic
|
|
|
|
- platform: template
|
|
name: "Last Restart"
|
|
id: device_last_restart
|
|
icon: mdi:clock
|
|
entity_category: diagnostic
|
|
device_class: timestamp
|
|
|
|
time:
|
|
- platform: sntp
|
|
id: sntp_time
|
|
# Define the timezone of the device
|
|
timezone: "${timezone}"
|
|
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
|
|
update_interval: ${sntp_update_interval}
|
|
# Set specific sntp servers to use
|
|
servers:
|
|
- "${sntp_server_1}"
|
|
- "${sntp_server_2}"
|
|
- "${sntp_server_3}"
|
|
# Publish the time the device was last restarted
|
|
on_time_sync:
|
|
then:
|
|
# Update last restart time, but only once.
|
|
- if:
|
|
condition:
|
|
lambda: 'return id(device_last_restart).state == "";'
|
|
then:
|
|
- text_sensor.template.publish:
|
|
id: device_last_restart
|
|
state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
|