diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml
deleted file mode 100644
index c68a761..0000000
--- a/.github/actions/build/action.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-name: 'Build configs'
-description: ''
-inputs:
- device:
- description: 'Device to compile'
- required: true
-runs:
- using: "composite"
- steps:
- - name: Install Dependencies
- shell: bash
- run: |
- apt update
- apt install -y jq
- pip3 install yq
-
- - name: Get info
- id: info
- shell: bash
- run: |
- esphome=$(esphome config athom-${{ inputs.device }}.yaml | yq ".esphome")
- name=$(echo $esphome | yq -r ".project.name")
- version=$(echo $esphome | yq -r ".project.version")
- devicename=$(echo $esphome | yq -r ".name")
- esphome_version=$(esphome version)
- esphome_version=$(echo $esphome_version | cut -d " " -f 2)
-
- echo "name=$name" >> $GITHUB_OUTPUT
- echo "version=$version" >> $GITHUB_OUTPUT
- echo "devicename=$devicename" >> $GITHUB_OUTPUT
- echo "esphome_version=$esphome_version" >> $GITHUB_OUTPUT
-
-
- - name: Compile ${{ inputs.device }}
- shell: bash
- run: esphome compile athom-${{ inputs.device }}.yaml
-
- - name: Copy generated file
- shell: bash
- run: |
- cp .esphome/build/${{ steps.info.outputs.devicename }}/.pioenvs/${{ steps.info.outputs.devicename }}/firmware.bin \
- ./${{ steps.info.outputs.name }}--${{ steps.info.outputs.version }}.bin
-
- - name: Upload binary
- uses: actions/upload-artifact@v3
- with:
- name: Athom Binaries (${{ steps.info.outputs.esphome_version }})
- path: ./${{ steps.info.outputs.name }}--${{ steps.info.outputs.version }}.bin
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index 84b5cd4..0000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-name: Build binaries
-
-on:
- push:
- branches: [main]
- workflow_dispatch:
-
-jobs:
- build:
- name: Build ${{ matrix.device }} - ${{ matrix.esphome }}
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- device:
- - rgb-light
- - rgbww-light
- - rgbct-light
- - rgbw-light
- - garage-door
- - ws2812b
- - mini-switch
- - relay-board-x1
- - relay-board-x2
- - relay-board-x4
- - relay-board-x8
- - smart-plug
- - smart-plug-v2
- - wall-outlet
- - sw01
- - sw01-v2
- - sw02
- - sw02-v2
- - sw03
- - sw04
- - cb02
- - ls-4p-3wire
- - ls-4p-4wire
- - presence-sensor
- esphome:
- - latest
- - beta
- - dev
-
- container: ghcr.io/esphome/esphome:${{ matrix.esphome }}
- steps:
- - name: Checkout source
- uses: actions/checkout@v3.2.0
- - uses: ./.github/actions/build
- with:
- device: ${{ matrix.device }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 220f386..9059bd0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -4,41 +4,37 @@ on:
pull_request:
jobs:
- build:
- name: Building ${{ matrix.device }}
+ ci:
+ name: Building ${{ matrix.file }}
runs-on: ubuntu-latest
strategy:
- fail-fast: false
matrix:
- device:
- - rgb-light
- - rgbww-light
- - rgbct-light
- - rgbw-light
- - garage-door
- - ws2812b
- - mini-switch
- - relay-board-x1
- - relay-board-x2
- - relay-board-x4
- - relay-board-x8
- - smart-plug
- - smart-plug-v2
- - wall-outlet
- - sw01
- - sw01-v2
- - sw02
- - sw02-v2
- - sw03
- - sw04
- - cb02
- - ls-4p-3wire
- - ls-4p-4wire
- - presence-sensor
+ file:
+ - athom-cb02.yaml
+ - athom-garage-door.yaml
+ - athom-mini-switch.yaml
+ - athom-presence-sensor.yaml
+ - athom-relay-board-x1.yaml
+ - athom-relay-board-x2.yaml
+ - athom-relay-board-x4.yaml
+ - athom-relay-board-x8.yaml
+ - athom-rgb-light.yaml
+ - athom-rgbct-light.yaml
+ - athom-rgbw-light.yaml
+ - athom-rgbww-light.yaml
+ - athom-smart-plug-v2.yaml
+ - athom-smart-plug.yaml
+ - athom-sw01-v2.yaml
+ - athom-sw01.yaml
+ - athom-sw02-v2.yaml
+ - athom-sw02.yaml
+ - athom-sw03.yaml
+ - athom-sw04.yaml
+ - athom-wall-outlet.yaml
steps:
- - name: Checkout source
- uses: actions/checkout@v3.2.0
- - uses: esphome/build-action@v1.1.0
- id: esphome-build
+ - name: Checkout source code
+ uses: actions/checkout@v4.1.7
+ - name: Build ESPHome firmware to verify configuration
+ uses: esphome/build-action@v4.0.1
with:
- yaml_file: athom-${{ matrix.device }}.yaml
+ yaml-file: ${{ matrix.file }}
\ No newline at end of file
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..03587a6
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,36 @@
+name: Build and Publish ESPHome firmware and website
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ build:
+ uses: esphome/workflows/.github/workflows/publish.yml@main
+ with:
+ # CHANGEME: Set the filenames of your config files here:
+ files:
+ athom-cb02.yaml,
+ athom-garage-door.yaml,
+ athom-mini-switch.yaml,
+ athom-presence-sensor.yaml,
+ athom-relay-board-x1.yaml,
+ athom-relay-board-x2.yaml,
+ athom-relay-board-x4.yaml,
+ athom-relay-board-x8.yaml,
+ athom-rgb-light.yaml,
+ athom-rgbct-light.yaml,
+ athom-rgbw-light.yaml,
+ athom-rgbww-light.yaml,
+ athom-smart-plug-v2.yaml,
+ athom-smart-plug.yaml,
+ athom-sw01-v2.yaml,
+ athom-sw01.yaml,
+ athom-sw02-v2.yaml,
+ athom-sw02.yaml,
+ athom-sw03.yaml,
+ athom-sw04.yaml,
+ athom-wall-outlet.yaml
+ # CHANGEME: Set the name of your project here:
+ name: Athom ESP8285 Device
\ No newline at end of file
diff --git a/athom-cb02.yaml b/athom-cb02.yaml
index ac2fa55..67ae1bd 100644
--- a/athom-cb02.yaml
+++ b/athom-cb02.yaml
@@ -1,16 +1,67 @@
substitutions:
- device_name: "athom-cb02-switch"
- project_name: "Athom Technology.Switch Module"
- project_version: "1.1"
+ # Default name
+ name: "athom-cb02-switch"
+ # Default friendly name
+ friendly_name: "Athom Relay Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom cb02 relay switch"
+ # Project Name
+ project_name: "Athom Technology.CB02 Relay Switch"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
relay_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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;
+ }
+ }
esp8266:
board: esp8285
@@ -22,8 +73,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -31,21 +85,50 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-cb02.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
- platform: gpio
pin:
- number: 3
+ number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "Power Button"
@@ -64,19 +147,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
- platform: gpio
@@ -86,7 +189,6 @@ switch:
restore_mode: ${relay_restore_mode}
on_turn_on:
- light.turn_on: blue_led
-
on_turn_off:
- light.turn_off: blue_led
@@ -103,12 +205,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-garage-door.yaml b/athom-garage-door.yaml
index ab391e7..eef3630 100644
--- a/athom-garage-door.yaml
+++ b/athom-garage-door.yaml
@@ -1,13 +1,42 @@
substitutions:
- device_name: "athom-garage-door"
- project_name: "Athom Technology.Garage Door Opener"
- project_version: "1.2"
-
+ # Default name
+ name: "athom-garage-door"
+ # Default friendly name
+ friendly_name: "Athom Garage Door"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom garage door opener"
+ # Project Name
+ project_name: "Athom Technology.Athom Garage Door Opener"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.2.2"
+ # Status inverted
+ status_inverted: "true"
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -18,9 +47,11 @@ esp8266:
api:
ota:
+ - platform: esphome
logger:
-
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -28,8 +59,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -39,10 +78,24 @@ dashboard_import:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
binary_sensor:
- platform: status
@@ -55,7 +108,7 @@ binary_sensor:
id: contact
pin:
number: GPIO4
- inverted: true
+ inverted: "${status_inverted}"
filters:
- delayed_on: 20ms
@@ -78,13 +131,19 @@ binary_sensor:
- button.press: Reset
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
- platform: gpio
@@ -103,7 +162,9 @@ light:
name: "Status LED"
id: wifi_led
disabled_by_default: true
- pin: GPIO12
+ pin:
+ inverted: true
+ number: GPIO12
cover:
- platform: template
@@ -131,11 +192,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-ls-4p-3wire.yaml b/athom-ls-4p-3wire.yaml
index a228cd1..a512f2f 100644
--- a/athom-ls-4p-3wire.yaml
+++ b/athom-ls-4p-3wire.yaml
@@ -1,7 +1,7 @@
substitutions:
device_name: "athom-ls-4p-3wire"
project_name: "Athom Technology.LS 4P 3Wire"
- project_version: "1.1"
+ project_version: "1.1.1"
button_toggle: "true"
led_restore_mode: RESTORE_DEFAULT_OFF
number_of_leds: '150'
@@ -12,6 +12,7 @@ esphome:
name: "${device_name}"
friendly_name: ""
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -25,6 +26,7 @@ esp8266:
api:
ota:
+ - platform: esphome
logger:
baud_rate: 0
@@ -70,7 +72,7 @@ sensor:
name: "Uptime Sensor"
- platform: wifi_signal
- name: "${friendly_name} WiFi Signal"
+ name: "WiFi Signal"
update_interval: 60s
button:
diff --git a/athom-ls-4p-4wire.yaml b/athom-ls-4p-4wire.yaml
index 92ba471..93dd654 100644
--- a/athom-ls-4p-4wire.yaml
+++ b/athom-ls-4p-4wire.yaml
@@ -1,7 +1,7 @@
substitutions:
device_name: "athom-ls-4p-4wire"
project_name: "Athom Technology.LS 4P 4Wire"
- project_version: "1.1"
+ project_version: "1.1.1"
button_toggle: "true"
light_restore_mode: RESTORE_DEFAULT_OFF
number_of_leds: '150'
@@ -12,6 +12,7 @@ esphome:
name: "${device_name}"
friendly_name: ""
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -25,6 +26,7 @@ esp8266:
api:
ota:
+ - platform: esphome
logger:
baud_rate: 0
@@ -70,7 +72,7 @@ sensor:
name: "Uptime Sensor"
- platform: wifi_signal
- name: "${friendly_name} WiFi Signal"
+ name: "WiFi Signal"
update_interval: 60s
button:
diff --git a/athom-mini-switch.yaml b/athom-mini-switch.yaml
index 43a80f0..c4ef79a 100644
--- a/athom-mini-switch.yaml
+++ b/athom-mini-switch.yaml
@@ -1,16 +1,67 @@
substitutions:
- device_name: "athom-mini-switch"
- project_name: "Athom Technology.Mini Relay Switch Module"
- project_version: "1.1"
+ # Default name
+ name: "athom-mini-switch"
+ # Default friendly name
+ friendly_name: "Athom Relay Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom mini relay switch module"
+ # Project Name
+ project_name: "Athom Technology.Mini Relay Switch"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(mini_relay).turn_off();
+ break;
+ }
+ case 2:{
+ id(mini_relay).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -22,9 +73,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
-
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -32,22 +85,56 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
+ # This spawns an AP with the device name and mac address with no password.
ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-mini-switch.yaml
+globals:
+ - 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;
+
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
- platform: gpio
@@ -68,14 +155,32 @@ light:
output: relay_output
name: "Mini Switch"
restore_mode: ${light_restore_mode}
+ on_turn_on:
+ - light.turn_on: led
+ on_turn_off:
+ - light.turn_off: led
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
binary_sensor:
# Wired switch
@@ -88,7 +193,6 @@ binary_sensor:
mode: INPUT_PULLUP
on_state:
- light.toggle: mini_relay
- - light.toggle: led
on_multi_click:
- timing:
- ON for at most 0.5s
@@ -116,7 +220,6 @@ binary_sensor:
- OFF for at least 0.2s
then:
- light.toggle: mini_relay
- - light.toggle: led
- timing:
- ON for at least 4s
then:
@@ -124,16 +227,73 @@ binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-presence-sensor.yaml b/athom-presence-sensor.yaml
index 40510ef..8b3056a 100644
--- a/athom-presence-sensor.yaml
+++ b/athom-presence-sensor.yaml
@@ -1,15 +1,40 @@
substitutions:
+ # Default name
name: "athom-presence-sensor"
- friendly_name: "presence sensor"
+ # Default friendly name
+ friendly_name: "Athom Presence Sensor"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
room: ""
- device_description: "mmwave radar human presence sensor"
- project_name: "Athom Technology.Presence Sensor"
- project_version: "1.0"
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom mmwave radar human presence sensor"
+ # Project Name
+ project_name: "Athom Technology.Athom Presence Sensor"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.0.2"
+ # 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: ""
+ # 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"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -21,12 +46,14 @@ esp8266:
preferences:
flash_write_interval: 1min
-# Enable logging
logger:
+ level: ${log_level}
+ baud_rate: 115200
api:
ota:
+ - platform: esphome
mdns:
disabled: false
@@ -34,8 +61,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
+ # This spawns an AP with the device name and mac address with no password.
ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -67,10 +102,10 @@ uart:
# sequence:
# - lambda: UARTDebug::log_string(direction, bytes);
-
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
- platform: gpio
pin:
@@ -98,8 +133,11 @@ binary_sensor:
- delayed_off: 10s
device_class: motion
on_press:
- then:
- - light.turn_on: led
+ if:
+ condition:
+ switch.is_on: presence_light
+ then:
+ - light.turn_on: led
- platform: gpio
pin:
@@ -116,7 +154,6 @@ binary_sensor:
then:
- light.turn_off: led
-
- platform: template
name: "Occupancy"
id: occupancy
@@ -135,10 +172,24 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "WiFi Signal Sensor"
+ 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: bh1750
name: "Light Sensor"
@@ -158,7 +209,20 @@ switch:
turn_off_action:
- uart.write: "sensorStop\r\n"
-
+ - platform: template
+ name: Presence Light
+ id: presence_light
+ entity_category: config
+ optimistic: true
+ restore_mode: RESTORE_DEFAULT_ON
+ on_turn_on:
+ if:
+ condition:
+ binary_sensor.is_on: occupancy
+ then:
+ - light.turn_on: led
+ on_turn_off:
+ - light.turn_off: led
number:
- platform: template
@@ -184,7 +248,6 @@ number:
- delay: 500ms
- switch.turn_on: mmwave_sensor
-
- platform: template
name: Maintain Sensitivity #Value range: 0 ~ 9 Default Maintain sensitivity: 7 Default Trigger sensitivity: 5
id: Maintain_Sensitivity
@@ -230,7 +293,6 @@ number:
- delay: 500ms
- switch.turn_on: mmwave_sensor
-
- platform: template
name: Detection Delay #Confirmation delay Value range: 0 ~ 100 default 0.050 seconds.
id: Detection_Delay
@@ -277,7 +339,6 @@ number:
- delay: 500ms
- switch.turn_on: mmwave_sensor
-
- platform: template
name: Blockade Time #Configure block time Value range: 1 ~ 255, default 1 seconds.
id: Blockade_Time
@@ -324,6 +385,12 @@ button:
id: restart_esp
entity_category: config
internal: true
+
+ - platform: safe_mode
+ name: "Safe Mode"
+ internal: false
+ entity_category: config
+
- platform: template
name: "Restart_mmWave"
id: "restart_mmwave"
@@ -344,12 +411,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
time:
- platform: sntp
- id: my_time
-
+ 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");'
\ No newline at end of file
diff --git a/athom-relay-board-x1.yaml b/athom-relay-board-x1.yaml
index 5f59aaa..457cb07 100644
--- a/athom-relay-board-x1.yaml
+++ b/athom-relay-board-x1.yaml
@@ -1,13 +1,42 @@
substitutions:
- device_name: "athom-relay-board-x1"
- project_name: "Athom Technology.Relay-Board-X1"
- project_version: "1.0"
+ # Default name
+ name: "athom-1ch-relay"
+ # Default friendly name
+ friendly_name: "Athom 1CH Relay"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom esp8266 1ch relay board"
+ # Project Name
+ project_name: "Athom Technology.Athom 1CH Relay Board"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.0.2"
+ # Restore the relay (GPO switch) upon reboot to state:
relay_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -22,14 +51,25 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 115200
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -39,23 +79,44 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
# Relay
@@ -77,11 +138,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
\ No newline at end of file
diff --git a/athom-relay-board-x2.yaml b/athom-relay-board-x2.yaml
index 121adac..cea761a 100644
--- a/athom-relay-board-x2.yaml
+++ b/athom-relay-board-x2.yaml
@@ -1,14 +1,43 @@
substitutions:
- device_name: "athom-relay-board-x2"
- project_name: "Athom Technology.Relay-Board-X2"
- project_version: "1.0"
+ # Default name
+ name: "athom-2ch-relay"
+ # Default friendly name
+ friendly_name: "Athom 2CH Relay"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom esp8266 2ch relay board"
+ # Project Name
+ project_name: "Athom Technology.Athom 2CH Relay Board"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.0.2"
+ # Restore the relay (GPO switch) upon reboot to state:
relay1_restore_mode: RESTORE_DEFAULT_OFF
relay2_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -23,14 +52,25 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 115200
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -40,23 +80,44 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
# Relay
@@ -84,11 +145,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
\ No newline at end of file
diff --git a/athom-relay-board-x4.yaml b/athom-relay-board-x4.yaml
index 83b43d9..3818022 100644
--- a/athom-relay-board-x4.yaml
+++ b/athom-relay-board-x4.yaml
@@ -1,16 +1,45 @@
substitutions:
- device_name: "athom-relay-board-x4"
- project_name: "Athom Technology.Relay-Board-X4"
- project_version: "1.0"
+ # Default name
+ name: "athom-4ch-relay"
+ # Default friendly name
+ friendly_name: "Athom 4CH Relay"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom esp8266 4ch relay board"
+ # Project Name
+ project_name: "Athom Technology.Athom 4CH Relay Board"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.0.2"
+ # Restore the relay (GPO switch) upon reboot to state:
relay1_restore_mode: RESTORE_DEFAULT_OFF
relay2_restore_mode: RESTORE_DEFAULT_OFF
relay3_restore_mode: RESTORE_DEFAULT_OFF
relay4_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -25,14 +54,25 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 115200
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -42,23 +82,44 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
- platform: gpio
@@ -97,12 +158,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
\ No newline at end of file
diff --git a/athom-relay-board-x8.yaml b/athom-relay-board-x8.yaml
index 074db81..9730f88 100644
--- a/athom-relay-board-x8.yaml
+++ b/athom-relay-board-x8.yaml
@@ -1,7 +1,17 @@
substitutions:
- device_name: "athom-relay-board-x8"
- project_name: "Athom Technology.Relay-Board-X8"
- project_version: "1.0"
+ # Default name
+ name: "athom-8ch-relay"
+ # Default friendly name
+ friendly_name: "Athom 8CH Relay"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom esp8266 8ch relay board"
+ # Project Name
+ project_name: "Athom Technology.Athom 8CH Relay Board"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.0.2"
+ # Restore the relay (GPO switch) upon reboot to state:
relay1_restore_mode: RESTORE_DEFAULT_OFF
relay2_restore_mode: RESTORE_DEFAULT_OFF
relay3_restore_mode: RESTORE_DEFAULT_OFF
@@ -10,11 +20,30 @@ substitutions:
relay6_restore_mode: RESTORE_DEFAULT_OFF
relay7_restore_mode: RESTORE_DEFAULT_OFF
relay8_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -29,14 +58,25 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 115200
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -46,23 +86,44 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
- platform: gpio
@@ -125,11 +186,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
\ No newline at end of file
diff --git a/athom-rgb-light.yaml b/athom-rgb-light.yaml
index 5b2c39b..91e6ceb 100644
--- a/athom-rgb-light.yaml
+++ b/athom-rgb-light.yaml
@@ -1,13 +1,42 @@
substitutions:
- device_name: "athom-rgb-light"
- project_name: "Athom Technology.RGB Light Strip Controller"
- project_version: "1.1"
+ # Default name
+ name: "athom-rgb-light"
+ # Default friendly name
+ friendly_name: "Athom RGB Controller"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom rgb light strip controller"
+ # Project Name
+ project_name: "Athom Technology.Athom RGB Controller"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the light (GPO switch) upon reboot to state:
light_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -22,9 +51,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -32,8 +63,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -43,6 +82,7 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
- platform: gpio
pin:
@@ -64,21 +104,40 @@ binary_sensor:
sensor:
- platform: uptime
- name: "Uptime"
+ name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
-
+ entity_category: config
output:
- platform: esp8266_pwm
@@ -104,11 +163,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
\ No newline at end of file
diff --git a/athom-rgbct-light.yaml b/athom-rgbct-light.yaml
index 9b1254c..442a1d0 100644
--- a/athom-rgbct-light.yaml
+++ b/athom-rgbct-light.yaml
@@ -1,9 +1,35 @@
substitutions:
- device_name: "athom-rgbct-light"
- project_name: "Athom Technology.RGBCCT Bulb"
- project_version: "1.1"
+ # Default name
+ name: "athom-rgbcct-bulb"
+ # Default friendly name
+ friendly_name: "Athom RGBCCT Bulb"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 15w rgbcct light bulb"
+ # Project Name
+ project_name: "Athom Technology.Athom RGBCCT Bulb"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the light (GPO switch) upon reboot to state:
light_restore_mode: RESTORE_DEFAULT_ON
- color_interlock: 'true'
+ # 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: ""
+ # 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"
+ color_interlock: "true"
globals:
- id: fast_boot
@@ -11,16 +37,61 @@ globals:
restore_value: yes
initial_value: '0'
+ - id: restore_mode
+ type: int
+ restore_value: yes
+ initial_value: "1"
+
+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;
+
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
on_boot:
- then:
- - script.execute: fast_boot_script
+ then:
+ - script.execute: fast_boot_script
+ - select.set_index:
+ id: power_mode
+ index: !lambda |-
+ return id(restore_mode)-1;
+ - lambda: |-
+ switch(id(restore_mode))
+ {
+ case 1:{
+ auto call = id(rgbct_light).turn_off();
+ call.perform();
+ break;
+ }
+ case 2:{
+ auto call = id(rgbct_light).turn_on();
+ call.set_color_mode(ColorMode::WHITE);
+ call.set_brightness(1.0);
+ call.perform();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -32,8 +103,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -41,8 +115,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -52,23 +134,44 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
- platform: esp8266_pwm
@@ -93,17 +196,20 @@ output:
id: white_output
pin: GPIO5
min_power: 0.01
- max_power: 1
+ max_power: 0.9
zero_means_zero: true
- platform: esp8266_pwm
id: ct_output
inverted: true
pin: GPIO13
+ min_power: 0.01
+ max_power: 0.9
+ zero_means_zero: true
light:
- platform: rgbct
id: rgbct_light
- name: "RGBCT_Bulb"
+ name: "RGBCCT_Bulb"
restore_mode: ${light_restore_mode}
red: red_output
green: green_output
@@ -118,14 +224,70 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
script:
- id: fast_boot_script
diff --git a/athom-rgbw-light.yaml b/athom-rgbw-light.yaml
index fffd322..c8e728c 100644
--- a/athom-rgbw-light.yaml
+++ b/athom-rgbw-light.yaml
@@ -1,13 +1,43 @@
substitutions:
- device_name: "athom-rgbw-light"
+ # Default name
+ name: "athom-rgbw-light"
+ # Default friendly name
+ friendly_name: "Athom RGBW Light"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom rgbw light strip controller"
+ # Project Name
project_name: "Athom Technology.RGBW Light Strip Controller"
- project_version: "1.1"
- light_restore_mode: RESTORE_DEFAULT_OFF
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the light (GPO switch) upon reboot to state:
+ light_restore_mode: RESTORE_DEFAULT_ON
+ # 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: ""
+ # 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"
+ color_interlock: "true"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -19,6 +49,7 @@ esp8266:
api:
ota:
+ - platform: esphome
logger:
@@ -28,8 +59,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -39,6 +78,7 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
- platform: gpio
pin:
@@ -61,19 +101,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
- platform: esp8266_pwm
@@ -100,18 +160,73 @@ light:
green: output_green
blue: output_blue
white: output_white
- color_interlock: true
-
+ color_interlock: ${color_interlock}
text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
\ No newline at end of file
diff --git a/athom-rgbww-light.yaml b/athom-rgbww-light.yaml
index 95a8097..545af25 100644
--- a/athom-rgbww-light.yaml
+++ b/athom-rgbww-light.yaml
@@ -1,9 +1,35 @@
substitutions:
- device_name: "athom-rgbww-light"
- project_name: "Athom Technology.RGBCW Bulb"
- project_version: "1.1"
+ # Default name
+ name: "athom-rgbcw-bulb"
+ # Default friendly name
+ friendly_name: "Athom RGBCW Bulb"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 7w rgbcw light bulb"
+ # Project Name
+ project_name: "Athom Technology.Athom RGBCW Bulb"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the light (GPO switch) upon reboot to state:
light_restore_mode: RESTORE_DEFAULT_ON
- color_interlock: 'true'
+ # 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: ""
+ # 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"
+ color_interlock: "true"
globals:
- id: fast_boot
@@ -11,16 +37,61 @@ globals:
restore_value: yes
initial_value: '0'
+ - id: restore_mode
+ type: int
+ restore_value: yes
+ initial_value: "1"
+
+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;
+
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
on_boot:
- then:
- - script.execute: fast_boot_script
+ then:
+ - script.execute: fast_boot_script
+ - select.set_index:
+ id: power_mode
+ index: !lambda |-
+ return id(restore_mode)-1;
+ - lambda: |-
+ switch(id(restore_mode))
+ {
+ case 1:{
+ auto call = id(rgbww_light).turn_off();
+ call.perform();
+ break;
+ }
+ case 2:{
+ auto call = id(rgbww_light).turn_on();
+ call.set_color_mode(ColorMode::WHITE);
+ call.set_brightness(1.0);
+ call.perform();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -32,6 +103,7 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
@@ -41,8 +113,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -52,23 +132,44 @@ dashboard_import:
binary_sensor:
- platform: status
name: "Status"
+ entity_category: diagnostic
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
- platform: esp8266_pwm
@@ -90,13 +191,12 @@ output:
id: warm_white_output
pin: GPIO13
min_power: 0.000499
- max_power: 1
+ max_power: 0.9
- platform: esp8266_pwm
id: white_output
pin: GPIO5
min_power: 0.000499
- max_power: 1
-
+ max_power: 0.9
light:
- platform: rgbww
@@ -116,14 +216,70 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
-
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
+
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");'
script:
- id: fast_boot_script
@@ -155,4 +311,4 @@ script:
ESP_LOGD("athom-rgbww-light.yaml", "Reset counter");
id(fast_boot) = 0;
fast_boot->loop();
- global_preferences->sync();
+ global_preferences->sync();
\ No newline at end of file
diff --git a/athom-smart-plug-v2.yaml b/athom-smart-plug-v2.yaml
index 0f80764..32be13f 100644
--- a/athom-smart-plug-v2.yaml
+++ b/athom-smart-plug-v2.yaml
@@ -5,30 +5,42 @@ substitutions:
room: ""
device_description: "athom smart plug v2"
project_name: "Athom Technology.Smart Plug V2"
- project_version: "2.0.2"
+ project_version: "v2.0.5"
+ sensor_update_interval: "10s"
relay_restore_mode: RESTORE_DEFAULT_OFF
- sensor_update_interval: 10s
# Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
current_limit : "16"
# 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: ""
# 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"
-
+ wifi_fast_connect: "false"
+ # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
+ log_level: "INFO"
+ # Enable or disable the use of IPv6 networking on the device
+ ipv6_enable: "false"
+ # Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
+ hide_energy_sensor: "true"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
+ comment: "${device_description}"
area: "${room}"
name_add_mac_suffix: true
- min_version: 2024.2.1
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
on_boot:
- - priority: -100
+ - priority: 600
then:
- select.set_index:
id: power_mode
@@ -49,6 +61,7 @@ esphome:
break;
}
}
+
esp8266:
board: esp8285
restore_from_flash: true
@@ -56,12 +69,13 @@ esp8266:
preferences:
flash_write_interval: 5min
-
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
baud_rate: 0
mdns:
@@ -70,9 +84,15 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
domain: "${dns_domain}"
captive_portal:
@@ -80,6 +100,11 @@ captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-smart-plug-v2.yaml
+# Dentra Components - Adds 'Platform - Energy Statistics'
+# https://github.com/dentra/esphome-components/tree/master/components/energy_statistics
+# external_components:
+# - source: github://dentra/esphome-components
+
uart:
rx_pin: RX
baud_rate: 4800
@@ -138,21 +163,22 @@ sensor:
entity_category: diagnostic
internal: true
+ # Reports the WiFi signal strength/RSSI in dB
- platform: wifi_signal
- name: "WiFi Signal"
+ name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: diagnostic
- internal: true
# Reports the WiFi signal strength in %
- platform: copy
source_id: wifi_signal_db
- name: "WiFi Strength"
+ name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: diagnostic
+ device_class: ""
- platform: cse7766
current:
@@ -193,6 +219,17 @@ sensor:
id(total_energy) += current_energy_value - previous_energy_value;
previous_energy_value = current_energy_value;
id(total_energy_sensor).update();
+ # internal: ${hide_energy_sensor}
+
+ apparent_power:
+ name: "Apparent Power"
+ filters:
+ - throttle_average: ${sensor_update_interval}
+
+ power_factor:
+ name: "Power Factor"
+ filters:
+ - throttle_average: ${sensor_update_interval}
- platform: template
name: "Total Energy"
@@ -204,17 +241,47 @@ sensor:
accuracy_decimals: 3
lambda: |-
return id(total_energy);
- update_interval: never
+ update_interval: ${sensor_update_interval}
- platform: total_daily_energy
- name: "Total Daily Energy"
+ name: "Total Energy Since Boot"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
+ icon: mdi:hours-24
accuracy_decimals: 3
filters:
- multiply: 0.001
+ # # Dentra Components - Define the id of the sensor providing 'Total Energy' used
+ # - platform: "energy_statistics"
+ # total: total_energy_sensor
+
+ # # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
+ # energy_today:
+ # name: "Energy Today"
+ # id: total_energy_today
+ # accuracy_decimals: 3
+ # icon: mdi:hours-24
+
+ # # Dentra Components - Adds Energy Yesterday
+ # energy_yesterday:
+ # name: "Total Energy Yesterday"
+ # id: total_energy_yesterday
+ # accuracy_decimals: 3
+
+ # # Dentra Components - Adds Energy Week
+ # energy_week:
+ # name: "Total Energy Week"
+ # id: total_energy_week
+ # accuracy_decimals: 3
+
+ # # Dentra Components - Adds Energy Month
+ # energy_month:
+ # name: "Total Energy Month"
+ # id: total_energy_month
+ # accuracy_decimals: 3
+
button:
- platform: restart
name: "Restart"
@@ -296,8 +363,13 @@ time:
id: sntp_time
# Define the timezone of the device
timezone: "${timezone}"
- # Change sync interval from default 5min to 6 hours
- update_interval: 360min
+ # 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:
diff --git a/athom-smart-plug.yaml b/athom-smart-plug.yaml
index ccf0d03..838669d 100644
--- a/athom-smart-plug.yaml
+++ b/athom-smart-plug.yaml
@@ -1,45 +1,136 @@
substitutions:
+
name: "athom-smart-plug"
friendly_name: "Smart Plug"
+ # 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 smart plug"
project_name: "Athom Technology.Smart Plug"
- project_version: "1.0"
+ project_version: "v1.0.2"
relay_restore_mode: RESTORE_DEFAULT_OFF
sensor_update_interval: 10s
+ # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
+ current_limit : "10"
+ # 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: ""
+ # 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: "INFO"
+ # Enable or disable the use of IPv6 networking on the device
+ ipv6_enable: "false"
+ # Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
+ hide_energy_sensor: "true"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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;
+ }
+ }
esp8266:
board: esp8285
restore_from_flash: true
preferences:
- flash_write_interval: 1min
+ flash_write_interval: 5min
api:
ota:
+ - platform: esphome
logger:
+ level: ${log_level}
+ baud_rate: 0
+
+mdns:
+ disabled: false
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-smart-plug.yaml
+# Dentra Components - Adds 'Platform - Energy Statistics'
+# https://github.com/dentra/esphome-components/tree/master/components/energy_statistics
+# external_components:
+# - source: github://dentra/esphome-components
+
+globals:
+ - id: total_energy
+ 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
name: "Status"
@@ -70,21 +161,22 @@ sensor:
entity_category: diagnostic
internal: True
+ # Reports the WiFi signal strength/RSSI in dB
- platform: wifi_signal
- name: "WiFi Signal"
+ name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: diagnostic
- internal: true
# Reports the WiFi signal strength in %
- platform: copy
source_id: wifi_signal_db
- name: "WiFi Strength"
+ name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: diagnostic
+ device_class: ""
- platform: hlw8012
sel_pin:
@@ -93,8 +185,12 @@ sensor:
cf_pin: GPIO4
cf1_pin: GPIO5
voltage_divider: 780
+
current:
name: "Current"
+ id: current
+ unit_of_measurement: A
+ accuracy_decimals: 2
filters:
- calibrate_linear:
- 0.0000 -> 0.0110 # Relay off no load
@@ -107,13 +203,24 @@ sensor:
- 9.9171 -> 7.9830
# Normalize for plug load
- lambda: if (x < 0.0260) return 0; else return (x - 0.0260);
+ on_value_range:
+ - above: ${current_limit}
+ then:
+ - switch.turn_off: relay
+
voltage:
name: "Voltage"
+ id: voltage
+ unit_of_measurement: V
+ accuracy_decimals: 1
+ filters:
+ - skip_initial: 2
power:
name: "Power"
id: socket_my_power
unit_of_measurement: W
+ accuracy_decimals: 1
filters:
- calibrate_linear:
- 0.0000 -> 0.5900 # Relay off no load
@@ -129,8 +236,40 @@ sensor:
change_mode_every: 1
update_interval: 5s
- - platform: total_daily_energy
+ # Shows the Energy kWh since the device was last started
+ energy:
+ name: "Energy"
+ id: energy
+ unit_of_measurement: kWh
+ accuracy_decimals: 3
+ filters:
+ # Multiplication factor from W to kW is 0.001
+ - multiply: 0.001
+ on_value:
+ then:
+ - 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();
+ # internal: ${hide_energy_sensor}
+
+ # Shows the TOTAL/Lifetime Energy kWh used by the device, may reset to zero upon firmware updates
+ - platform: template
name: "Total Energy"
+ id: total_energy_sensor
+ unit_of_measurement: kWh
+ device_class: "energy"
+ state_class: "total_increasing"
+ icon: "mdi:lightning-bolt"
+ accuracy_decimals: 3
+ lambda: |-
+ return id(total_energy);
+ update_interval: ${sensor_update_interval}
+
+ - platform: total_daily_energy
+ name: "Total Energy Since Boot"
power_id: socket_my_power
unit_of_measurement: kWh
accuracy_decimals: 3
@@ -138,8 +277,40 @@ sensor:
filters:
- multiply: 0.001
+ # Dentra Components - Define the id of the sensor providing 'Total Energy' used
+ # - platform: "energy_statistics"
+ # total: total_energy_sensor
+
+ # # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
+ # energy_today:
+ # name: "Total Energy Today"
+ # id: total_energy_today
+ # accuracy_decimals: 3
+ # icon: mdi:hours-24
+
+ # # Dentra Components - Adds Energy Yesterday
+ # energy_yesterday:
+ # name: "Total Energy Yesterday"
+ # id: total_energy_yesterday
+ # accuracy_decimals: 3
+
+ # # Dentra Components - Adds Energy Week
+ # energy_week:
+ # name: "Total Energy Week"
+ # id: total_energy_week
+ # accuracy_decimals: 3
+
+ # # Dentra Components - Adds Energy Month
+ # energy_month:
+ # name: "Total Energy Month"
+ # id: total_energy_month
+ # accuracy_decimals: 3
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
name: "Reset"
id: Reset
@@ -185,7 +356,7 @@ text_sensor:
# Creates a sensor showing when the device was last restarted
- platform: template
- name: 'Device Last Restart'
+ name: 'Last Restart'
id: device_last_restart
icon: mdi:clock
entity_category: diagnostic
@@ -193,7 +364,7 @@ text_sensor:
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
- platform: template
- name: "Device Uptime"
+ name: "Uptime"
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_sensor).state);
@@ -219,8 +390,15 @@ text_sensor:
time:
- platform: sntp
id: sntp_time
- # Change sync interval from default 5min to 6 hours
- update_interval: 360min
+ # 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:
@@ -232,4 +410,3 @@ time:
- text_sensor.template.publish:
id: device_last_restart
state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'
-
diff --git a/athom-sw01-v2.yaml b/athom-sw01-v2.yaml
index 9d161ed..ab5b5d6 100644
--- a/athom-sw01-v2.yaml
+++ b/athom-sw01-v2.yaml
@@ -1,16 +1,67 @@
substitutions:
- device_name: "athom-1gang-switch-v2"
- project_name: "Athom Technology.1 Gang Switch V2"
- project_version: "1.1"
+ # Default name
+ name: "athom-1gang-switch-v2"
+ # Default friendly name
+ friendly_name: "1Gang Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 1gang switch v2"
+ # Project Name
+ project_name: "Athom Technology.1Gang Switch V2"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(light1).turn_off();
+ break;
+ }
+ case 2:{
+ id(light1).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -22,9 +73,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -32,17 +85,46 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-sw01-v2.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
# Touch Button
- platform: gpio
@@ -68,19 +150,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
# Relay
@@ -125,11 +227,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-sw01.yaml b/athom-sw01.yaml
index c609377..88a233f 100644
--- a/athom-sw01.yaml
+++ b/athom-sw01.yaml
@@ -1,16 +1,67 @@
substitutions:
- device_name: "athom-1gang-switch"
- project_name: "Athom Technology.1 Gang Switch"
- project_version: "1.1"
+ # Default name
+ name: "athom-1gang-switch"
+ # Default friendly name
+ friendly_name: "1Gang Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 1gang switch"
+ # Project Name
+ project_name: "Athom Technology.1Gang Switch"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(light1).turn_off();
+ break;
+ }
+ case 2:{
+ id(light1).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -22,9 +73,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -32,17 +85,46 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-sw01.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
# Touch Button
- platform: gpio
@@ -68,19 +150,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
# Relay
@@ -125,11 +227,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-sw02-v2.yaml b/athom-sw02-v2.yaml
index de933f7..0508f1f 100644
--- a/athom-sw02-v2.yaml
+++ b/athom-sw02-v2.yaml
@@ -1,17 +1,70 @@
substitutions:
- device_name: "athom-2gang-switch-v2"
- project_name: "Athom Technology.2 Gang Switch V2"
- project_version: "1.1"
+ # Default name
+ name: "athom-2gang-switch-v2"
+ # Default friendly name
+ friendly_name: "2Gang Switch V2"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 2gang switch v2"
+ # Project Name
+ project_name: "Athom Technology.2Gang Switch V2"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light1_restore_mode: RESTORE_DEFAULT_OFF
light2_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(light1).turn_off();
+ id(light2).turn_off();
+ break;
+ }
+ case 2:{
+ id(light1).turn_on();
+ id(light2).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -23,9 +76,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -33,17 +88,46 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-sw02-v2.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
# Touch Buttons
- platform: gpio
@@ -83,19 +167,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
# Relays
@@ -168,11 +272,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-sw02.yaml b/athom-sw02.yaml
index c51c2b8..ee9b5b4 100644
--- a/athom-sw02.yaml
+++ b/athom-sw02.yaml
@@ -1,17 +1,70 @@
substitutions:
- device_name: "athom-2gang-switch"
- project_name: "Athom Technology.2 Gang Switch"
- project_version: "1.1"
+ # Default name
+ name: "athom-2gang-switch"
+ # Default friendly name
+ friendly_name: "2Gang Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 2gang switch"
+ # Project Name
+ project_name: "Athom Technology.2Gang Switch"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light1_restore_mode: RESTORE_DEFAULT_OFF
light2_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(light1).turn_off();
+ id(light2).turn_off();
+ break;
+ }
+ case 2:{
+ id(light1).turn_on();
+ id(light2).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -23,9 +76,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -33,17 +88,46 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-sw02.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
# Touch Buttons
- platform: gpio
@@ -83,19 +167,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
# Relays
@@ -163,11 +267,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-sw03.yaml b/athom-sw03.yaml
index 22cbdb5..704b3d7 100644
--- a/athom-sw03.yaml
+++ b/athom-sw03.yaml
@@ -1,18 +1,73 @@
substitutions:
- device_name: "athom-3gang-switch"
- project_name: "Athom Technology.3 Gang Switch"
- project_version: "1.1"
+ # Default name
+ name: "athom-3gang-switch"
+ # Default friendly name
+ friendly_name: "3Gang Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 3gang switch"
+ # Project Name
+ project_name: "Athom Technology.3Gang Switch"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light1_restore_mode: RESTORE_DEFAULT_OFF
light2_restore_mode: RESTORE_DEFAULT_OFF
light3_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(light1).turn_off();
+ id(light2).turn_off();
+ id(light3).turn_off();
+ break;
+ }
+ case 2:{
+ id(light1).turn_on();
+ id(light2).turn_on();
+ id(light3).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -24,9 +79,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -34,17 +91,46 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-sw03.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
# Touch Buttons
- platform: gpio
@@ -98,19 +184,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
# Relays
@@ -201,11 +307,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-sw04.yaml b/athom-sw04.yaml
index cd58a9e..bcfb7d2 100644
--- a/athom-sw04.yaml
+++ b/athom-sw04.yaml
@@ -1,19 +1,76 @@
substitutions:
- device_name: "athom-4gang-switch"
- project_name: "Athom Technology.4 Gang Switch"
- project_version: "1.1"
+ # Default name
+ name: "athom-4gang-switch"
+ # Default friendly name
+ friendly_name: "4Gang Switch"
+ # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
+ room: ""
+ # Description as appears in ESPHome & top of webserver page
+ device_description: "athom 4gang switch"
+ # Project Name
+ project_name: "Athom Technology.4Gang Switch"
+ # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
+ project_version: "v1.1.2"
+ # Restore the relay (GPO switch) upon reboot to state:
light1_restore_mode: RESTORE_DEFAULT_OFF
light2_restore_mode: RESTORE_DEFAULT_OFF
light3_restore_mode: RESTORE_DEFAULT_OFF
light4_restore_mode: RESTORE_DEFAULT_OFF
+ # 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: ""
+ # 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"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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(light1).turn_off();
+ id(light2).turn_off();
+ id(light3).turn_off();
+ id(light4).turn_off();
+ break;
+ }
+ case 2:{
+ id(light1).turn_on();
+ id(light2).turn_on();
+ id(light3).turn_on();
+ id(light4).turn_on();
+ break;
+ }
+ default:{
+ break;
+ }
+ }
esp8266:
board: esp8285
@@ -25,9 +82,11 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
- baud_rate: 0
+ level: ${log_level}
+ baud_rate: 115200
mdns:
disabled: false
@@ -35,17 +94,46 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-sw04.yaml
+globals:
+ - 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
name: "Status"
+ entity_category: diagnostic
# Touch Buttons
- platform: gpio
@@ -101,19 +189,39 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
- platform: wifi_signal
- name: "${friendly_name} 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: ""
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
output:
# Relays
@@ -164,11 +272,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
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");'
\ No newline at end of file
diff --git a/athom-wall-outlet.yaml b/athom-wall-outlet.yaml
index 76cbc03..6628b73 100644
--- a/athom-wall-outlet.yaml
+++ b/athom-wall-outlet.yaml
@@ -1,29 +1,78 @@
substitutions:
- device_name: "athom-wall-outlet"
- # friendly_name: "Athom Wall Outlet"
- project_name: "Athom Technology.Wall Outlet"
- project_version: "1.1"
+ name: "athom-wall-outlet"
+ friendly_name: "Athom Wall Outlet"
+ # 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 wall outlet"
+ project_name: "Athom Technology.Athom Wall Outlet"
+ project_version: "v1.1.2"
+ sensor_update_interval: "10s"
relay_restore_mode: RESTORE_DEFAULT_OFF
- sensor_update_interval: 10s
+ # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
+ current_limit : "16"
+ # 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: ""
+ # 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: "INFO"
+ # Enable or disable the use of IPv6 networking on the device
+ ipv6_enable: "false"
+ # Hide the ENERGY sensor that shows kWh consumed, but with no time period associated with it. Resets when device restarted and reflashed.
+ hide_energy_sensor: "true"
esphome:
- name: "${device_name}"
- friendly_name: ""
+ name: "${name}"
+ friendly_name: "${friendly_name}"
+ comment: "${device_description}"
+ area: "${room}"
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
+ 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;
+ }
+ }
esp8266:
board: esp8285
restore_from_flash: true
preferences:
- flash_write_interval: 1min
+ flash_write_interval: 5min
api:
ota:
+ - platform: esphome
logger:
baud_rate: 0
@@ -34,8 +83,16 @@ mdns:
web_server:
port: 80
+network:
+ enable_ipv6: ${ipv6_enable}
+
wifi:
- ap: {} # This spawns an AP with the device name and mac address with no password.
+ # This spawns an AP with the device name and mac address with no password.
+ ap: {}
+ # Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
+ fast_connect: "${wifi_fast_connect}"
+ # Define dns domain / suffix to add to hostname
+ domain: "${dns_domain}"
captive_portal:
@@ -52,9 +109,29 @@ globals:
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
name: "Status"
+ entity_category: diagnostic
- platform: gpio
pin:
@@ -77,37 +154,58 @@ binary_sensor:
sensor:
- platform: uptime
name: "Uptime Sensor"
+ id: uptime_sensor
+ entity_category: diagnostic
+ internal: true
+ # Reports the WiFi signal strength/RSSI in dB
- platform: wifi_signal
- name: "${friendly_name} WiFi Signal"
+ name: "WiFi Signal dB"
+ id: wifi_signal_db
update_interval: 60s
+ entity_category: diagnostic
+
+ # Reports the WiFi signal strength in %
+ - 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: "%"
+ entity_category: diagnostic
+ device_class: ""
- platform: cse7766
current:
name: "Current"
- # filters:
- # - lambda: if (x < 0.060) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
+ filters:
+ - throttle_average: ${sensor_update_interval}
+ - lambda: if (x < 0.060) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
+ on_value_range:
+ - above: ${current_limit}
+ then:
+ - switch.turn_off: relay
voltage:
name: "Voltage"
filters:
- throttle_average: ${sensor_update_interval}
+
power:
name: "Power"
id: power_sensor
filters:
- throttle_average: ${sensor_update_interval}
- # - lambda: if (x < 3.0) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
-
+ - lambda: if (x < 3.0) return 0.0; else return x; #For the chip will report less than 3w power when no load is connected
energy:
name: "Energy"
id: energy
unit_of_measurement: kWh
filters:
+ - throttle: ${sensor_update_interval}
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
- - throttle_average: ${sensor_update_interval}
on_value:
then:
- lambda: |-
@@ -115,9 +213,22 @@ sensor:
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();
+ # internal: ${hide_energy_sensor}
+
+ apparent_power:
+ name: "Apparent Power"
+ filters:
+ - throttle_average: ${sensor_update_interval}
+
+ power_factor:
+ name: "Power Factor"
+ filters:
+ - throttle_average: ${sensor_update_interval}
- platform: template
name: "Total Energy"
+ id: total_energy_sensor
unit_of_measurement: kWh
device_class: "energy"
state_class: "total_increasing"
@@ -128,33 +239,67 @@ sensor:
update_interval: ${sensor_update_interval}
- platform: total_daily_energy
- name: "Total Daily Energy"
+ name: "Total Energy Since Boot"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
+ icon: mdi:hours-24
accuracy_decimals: 3
filters:
- multiply: 0.001
+ # # Dentra Components - Define the id of the sensor providing 'Total Energy' used
+ # - platform: "energy_statistics"
+ # total: total_energy_sensor
+
+ # # Dentra Components - Adds Energy Today. Persistents if restarted, unlike 'total_daily_energy'
+ # energy_today:
+ # name: "Energy Today"
+ # id: total_energy_today
+ # accuracy_decimals: 3
+ # icon: mdi:hours-24
+
+ # # Dentra Components - Adds Energy Yesterday
+ # energy_yesterday:
+ # name: "Total Energy Yesterday"
+ # id: total_energy_yesterday
+ # accuracy_decimals: 3
+
+ # # Dentra Components - Adds Energy Week
+ # energy_week:
+ # name: "Total Energy Week"
+ # id: total_energy_week
+ # accuracy_decimals: 3
+
+ # # Dentra Components - Adds Energy Month
+ # energy_month:
+ # name: "Total Energy Month"
+ # id: total_energy_month
+ # accuracy_decimals: 3
button:
+ - platform: restart
+ name: "Restart"
+ entity_category: config
+
- platform: factory_reset
- name: "Reset"
+ name: "Factory Reset"
id: Reset
+ entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
+ entity_category: config
switch:
- platform: gpio
- name: "Wall Outlet"
+ name: "Switch"
pin: GPIO12
id: relay
restore_mode: ${relay_restore_mode}
on_turn_on:
- light.turn_on: red_led
-
on_turn_off:
- light.turn_off: red_led
@@ -171,11 +316,67 @@ text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
+ entity_category: diagnostic
ssid:
name: "Connected SSID"
+ entity_category: diagnostic
mac_address:
name: "Mac Address"
+ entity_category: diagnostic
+
+ # Creates a sensor showing when the device was last restarted
+ - platform: template
+ name: 'Last Restart'
+ id: device_last_restart
+ icon: mdi:clock
+ entity_category: diagnostic
+# device_class: timestamp
+
+ # Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
+ - platform: template
+ name: "Uptime"
+ entity_category: diagnostic
+ 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() };
+ }
+ icon: mdi:clock-start
time:
- platform: sntp
- id: sntp_time
\ No newline at end of file
+ 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");'
\ No newline at end of file
diff --git a/athom-ws2812b.yaml b/athom-ws2812b.yaml
index 7c6bc49..1d48605 100644
--- a/athom-ws2812b.yaml
+++ b/athom-ws2812b.yaml
@@ -1,7 +1,7 @@
substitutions:
device_name: "athom-ws2812b"
project_name: "Athom Technology.WS2812B Controller"
- project_version: "1.1"
+ project_version: "1.1.1"
button_toggle: "true"
led_restore_mode: RESTORE_DEFAULT_OFF
number_of_leds: '150'
@@ -12,6 +12,7 @@ esphome:
name: "${device_name}"
friendly_name: ""
name_add_mac_suffix: true
+ min_version: 2024.6.0
project:
name: "${project_name}"
version: "${project_version}"
@@ -28,6 +29,7 @@ preferences:
api:
ota:
+ - platform: esphome
logger:
baud_rate: 0
@@ -38,7 +40,6 @@ mdns:
web_server:
port: 80
-
wifi:
ap: {} # This spawns an AP with the device name and mac address with no password.
@@ -74,7 +75,7 @@ sensor:
name: "Uptime Sensor"
- platform: wifi_signal
- name: "${friendly_name} WiFi Signal"
+ name: "WiFi Signal"
update_interval: 60s
button:
@@ -111,4 +112,3 @@ text_sensor:
time:
- platform: sntp
id: sntp_time
-
diff --git a/static/_config.yml b/static/_config.yml
new file mode 100644
index 0000000..fe3d0cc
--- /dev/null
+++ b/static/_config.yml
@@ -0,0 +1,4 @@
+# CHANGEME: Set these variable to your liking
+title: ESPHome Project Template
+description: Powered by ESPHome and ESP Web Tools
+theme: jekyll-theme-slate
\ No newline at end of file
diff --git a/static/index.md b/static/index.md
new file mode 100644
index 0000000..fd14936
--- /dev/null
+++ b/static/index.md
@@ -0,0 +1,11 @@
+# About
+
+Add some information about your project here.
+
+# Installation
+
+You can use the button below to install the pre-built firmware directly to your device via USB from the browser.
+
+
+
+
\ No newline at end of file