From 59a49c9370fcab730b23c5436dfaa7e82b70a670 Mon Sep 17 00:00:00 2001 From: Aiden Date: Mon, 31 Aug 2026 20:12:08 +0800 Subject: [PATCH] add Child Lock --- README.md | 4 ++-- athom-dual-smart-plug-v3.yaml | 41 ++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2100a0f..46e2bd1 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Each file contains a `dashboard_import` URL in the form `github://athom-tech/esp | `athom-2ch-relay-board.yaml` | Athom 2CH Relay Board | `esp32dev` | Two-channel relay board with local buttons, RF receiver support, and status telemetry. | | `athom-4ch-relay-board.yaml` | Athom 4CH Relay Board | `esp32dev` | Four-channel relay board with local buttons, RF receiver support, and status telemetry. | | `athom-8ch-relay-board.yaml` | Athom 8CH Relay Board | `esp32dev` | Eight-channel relay board with local buttons, RF receiver support, and status telemetry. | -| `athom-dual-smart-plug-v3.yaml` | Athom Dual Plug V3 | `esp32-c3-devkitm-1` | Dual smart plug with independent relay control, per-channel and aggregate power monitoring, persistent energy totals, and energy reset controls. | +| `athom-dual-smart-plug-v3.yaml` | Athom Dual Plug V3 | `esp32-c3-devkitm-1` | Dual-channel smart plug with independent relay control and buttons, dual-channel energy metering. | | `athom-energy-monitor-x2.yaml` | Athom Energy Meter | `esp32-c3-devkitm-1` | Two-channel energy monitor using the local `bl0906` component. | | `athom-energy-monitor-x6.yaml` | Athom Energy Meter | `esp32-c3-devkitm-1` | Six-channel energy monitor using the local `bl0906` component. | | `athom-garage-door.yaml` | Athom Garage Door | `esp32-c3-devkitm-1` | Garage door opener with relay control, door state inputs, template cover, and status LED. | @@ -133,7 +133,7 @@ If OTA fails, confirm that: - OTA and web server support are enabled in the device configurations. - Common diagnostic entities include status, uptime, Wi-Fi signal, and restart/factory-reset style buttons. - Power-monitoring devices expose voltage, current, power, energy, total energy, and related calculated sensors where supported by the hardware. -- The dual smart plug exposes per-channel measurements plus total current and total active power, persists per-channel and aggregate energy totals, and provides controls to reset those totals. +- The dual smart plug performs dual-channel energy metering with the `bl0939` chip over UART, exposing per-channel voltage, current, active power, energy, and daily energy, plus total current, total active power, and total energy. It persists per-channel and aggregate energy totals across reboots and provides buttons to reset each total. A configurable current limit (16 A by default) trips the affected channel off for overcurrent protection, a `Power On State` selector sets the boot behaviour (always off, always on, or restore previous state), and each channel can be toggled with its physical button (a 4-second hold triggers factory reset). - Presence and LD2450-based devices expose target, zone, presence, illuminance, and radar control entities. - Devices are expected to be discovered by Home Assistant through the ESPHome integration after they are on the network. diff --git a/athom-dual-smart-plug-v3.yaml b/athom-dual-smart-plug-v3.yaml index deb7bec..081abb8 100644 --- a/athom-dual-smart-plug-v3.yaml +++ b/athom-dual-smart-plug-v3.yaml @@ -10,7 +10,7 @@ substitutions: # Project Name project_name: China Athom Technology.Athom Dual Plug V3 # Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version - project_version: v3.0.4 + project_version: v3.0.5 # Restore the relay (GPO switch) upon reboot to state: relay1_restore_mode: RESTORE_DEFAULT_ON relay2_restore_mode: RESTORE_DEFAULT_ON @@ -244,11 +244,21 @@ binary_sensor: - ON for at most 1s - OFF for at least 0.2s then: - - switch.toggle: relay1 + # Ignore short press when child lock is on, to stop kids toggling the socket + - if: + condition: + switch.is_off: child_lock + then: + - switch.toggle: relay1 - timing: - ON for at least 4s then: - - button.press: Reset + # Ignore long press when child lock is on, to prevent accidental factory reset + - if: + condition: + switch.is_off: child_lock + then: + - button.press: Reset - platform: gpio pin: @@ -263,11 +273,21 @@ binary_sensor: - ON for at most 1s - OFF for at least 0.2s then: - - switch.toggle: relay2 + # Ignore short press when child lock is on, to stop kids toggling the socket + - if: + condition: + switch.is_off: child_lock + then: + - switch.toggle: relay2 - timing: - ON for at least 4s then: - - button.press: Reset + # Ignore long press when child lock is on, to prevent accidental factory reset + - if: + condition: + switch.is_off: child_lock + then: + - button.press: Reset sensor: - platform: uptime @@ -493,7 +513,16 @@ switch: id: relay2 restore_mode: ${relay2_restore_mode} icon: mdi:${power_plug_type} - + + # Child lock: when on, ignore both physical buttons' short/long press, but keep remote (HA/web) control working + - platform: template + name: "Child Lock" + id: child_lock + icon: mdi:lock + optimistic: true + restore_mode: RESTORE_DEFAULT_OFF # Keep last state after power loss/reboot, default off on first boot + entity_category: config + light: - platform: status_led name: "Status LED"