laundry esphome migration
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
- id: '1693027703299'
|
- id: '1693027703299'
|
||||||
alias: Downstairs Kitchen turn ON LEDs on with main lights
|
alias: Downstairs Kitchen turn ON LEDs on with main lights
|
||||||
description: ''
|
description: ''
|
||||||
trigger:
|
triggers:
|
||||||
- platform: device
|
- type: turned_on
|
||||||
type: turned_on
|
|
||||||
device_id: 1a7e2bfdfaa08e2b78bcbd5d5d12d2a7
|
device_id: 1a7e2bfdfaa08e2b78bcbd5d5d12d2a7
|
||||||
entity_id: 2921a7f1e6616c97c2ed502cbe950503
|
entity_id: afb10b1efeb20fdf7215636d438882a2
|
||||||
domain: switch
|
domain: switch
|
||||||
condition: []
|
trigger: device
|
||||||
action:
|
conditions: []
|
||||||
- service: light.turn_on
|
actions:
|
||||||
data:
|
- data:
|
||||||
transition: 10
|
transition: 20
|
||||||
brightness_pct: 95
|
brightness_pct: 95
|
||||||
target:
|
target:
|
||||||
entity_id: light.controller_dimmable_3c317c
|
entity_id: light.controller_dimmable_3c317c
|
||||||
|
action: light.turn_on
|
||||||
mode: single
|
mode: single
|
||||||
- id: '1693027792035'
|
- id: '1693027792035'
|
||||||
alias: Downstairs Kitchen turn OFF LEDs with main lights
|
alias: Downstairs Kitchen turn OFF LEDs with main lights
|
||||||
description: ''
|
description: ''
|
||||||
trigger:
|
triggers:
|
||||||
- platform: device
|
- type: turned_off
|
||||||
type: turned_off
|
|
||||||
device_id: 1a7e2bfdfaa08e2b78bcbd5d5d12d2a7
|
device_id: 1a7e2bfdfaa08e2b78bcbd5d5d12d2a7
|
||||||
entity_id: 2921a7f1e6616c97c2ed502cbe950503
|
entity_id: afb10b1efeb20fdf7215636d438882a2
|
||||||
domain: switch
|
domain: switch
|
||||||
condition: []
|
trigger: device
|
||||||
action:
|
conditions: []
|
||||||
- service: light.turn_off
|
actions:
|
||||||
data:
|
- data:
|
||||||
transition: 10
|
transition: 20
|
||||||
target:
|
target:
|
||||||
entity_id: light.controller_dimmable_3c317c
|
entity_id: light.controller_dimmable_3c317c
|
||||||
|
action: light.turn_off
|
||||||
mode: single
|
mode: single
|
||||||
|
30
esphome/archive/downstairs-bathroom-towelrail.yaml
Normal file
30
esphome/archive/downstairs-bathroom-towelrail.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
esphome:
|
||||||
|
name: downstairs-bathroom-towelrail
|
||||||
|
friendly_name: Downstairs Bathroom Towelrail
|
||||||
|
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
|
||||||
|
# Enable logging
|
||||||
|
logger:
|
||||||
|
|
||||||
|
# Enable Home Assistant API
|
||||||
|
api:
|
||||||
|
encryption:
|
||||||
|
key: "LQNFgCf7ZydoK09V22GidNeAJSlFbbHk6rny0UHv/fQ="
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- platform: esphome
|
||||||
|
password: "0a368f636bbb37d7195e93edac50f44b"
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: !secret wifi_ssid
|
||||||
|
password: !secret wifi_password
|
||||||
|
|
||||||
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||||
|
ap:
|
||||||
|
ssid: "Downstairs-Bathroom-Towelrail"
|
||||||
|
password: "kOc1t2CEXxgo"
|
||||||
|
|
||||||
|
captive_portal:
|
||||||
|
|
30
esphome/archive/downstairs-kitchen-lights.yaml
Normal file
30
esphome/archive/downstairs-kitchen-lights.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
esphome:
|
||||||
|
name: downstairs-kitchen-lights
|
||||||
|
friendly_name: Downstairs Kitchen Lights
|
||||||
|
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
|
||||||
|
# Enable logging
|
||||||
|
logger:
|
||||||
|
|
||||||
|
# Enable Home Assistant API
|
||||||
|
api:
|
||||||
|
encryption:
|
||||||
|
key: "/ZwmBVlWvNzvYBgg7l7kt/gegaUxbej0Qg0CRyl5M/I="
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- platform: esphome
|
||||||
|
password: "b692f015ebcd06236fd2a805050e32df"
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: !secret wifi_ssid
|
||||||
|
password: !secret wifi_password
|
||||||
|
|
||||||
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||||
|
ap:
|
||||||
|
ssid: "Downstairs-Kitchen-Lights"
|
||||||
|
password: "cAFaKcl5z7I2"
|
||||||
|
|
||||||
|
captive_portal:
|
||||||
|
|
@@ -1,4 +1,4 @@
|
|||||||
#############################################
|
esphome/esp-datapower-b.yaml#############################################
|
||||||
#############################################
|
#############################################
|
||||||
# Data Cupboard Power Monitor B
|
# Data Cupboard Power Monitor B
|
||||||
# Athom Smart Plug Power Monitor ESP32-C3
|
# Athom Smart Plug Power Monitor ESP32-C3
|
437
esphome/archive/esp-occupancyoffice copy.yaml.bak
Normal file
437
esphome/archive/esp-occupancyoffice copy.yaml.bak
Normal file
@@ -0,0 +1,437 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# HiLink LD1125H mmWave sensor, with BME280 Temp/Hum/Pres Sensor on an ESP32
|
||||||
|
# https://zorruno.com/2024/mmwave-occupancy-with-esp32-ld1125h/
|
||||||
|
#
|
||||||
|
# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/tree/main
|
||||||
|
# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/blob/main/LD1125H/ESP32-LD1125H-Complete.yaml
|
||||||
|
#
|
||||||
|
# mth1: 0 to 2.8m sensitive
|
||||||
|
# mth2: 2.8 to 8m sensitive
|
||||||
|
# mth3: above 8m sensitive
|
||||||
|
# rmax: max distance
|
||||||
|
# Clearance Time: Mov/Occ to Clearance waiting time
|
||||||
|
# Movement Time: Mov to Occ waiting time
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
devicename: "esp-occupancyoffice"
|
||||||
|
friendly_name: "Office Occupancy & Environment"
|
||||||
|
description_comment: "D1 Mini ESP32 with LD1125H mmWave and environment sensors for downstairs office"
|
||||||
|
api_key: !secret esp-occupancyoffice_api_key #unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-occupancyoffice_ota_pass #unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-occupancyoffice_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
|
#############################################
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
# common_api: !include
|
||||||
|
# file: common/api_common.yaml
|
||||||
|
# vars:
|
||||||
|
# local_api_key: ${api_key}
|
||||||
|
common_webportal: !include
|
||||||
|
file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: ${devicename}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
comment: ${description_comment} #appears on the esphome page in HA
|
||||||
|
min_version: 2024.6.0
|
||||||
|
area: "${room}"
|
||||||
|
on_boot: #LD1125H Initial Setting, will remember previous values (if set)
|
||||||
|
priority: -200
|
||||||
|
then:
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(th1st.begin(), th1st.end());
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(th2st.begin(), th2st.end());
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(th3st.begin(), th3st.end());
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(rmaxst.begin(), rmaxst.end());
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp32:
|
||||||
|
board: esp32dev
|
||||||
|
framework:
|
||||||
|
#type: arduino
|
||||||
|
type: esp-idf #Suggest using the ESP-IDF Framework. Changing from arduino to esp-idf needs a cabled download to change partitions
|
||||||
|
version: recommended #recommended, latest or dev
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome external or custom components to use
|
||||||
|
# https://esphome.io/components/external_components.html
|
||||||
|
# https://github.com/ssieb/esphome_components/tree/master/components/serial
|
||||||
|
#############################################
|
||||||
|
external_components:
|
||||||
|
- source:
|
||||||
|
type: git
|
||||||
|
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||||
|
components: [ serial ] #text_sensor that reads lines for a uart. Also, a sensor that reads single binary values from the uart.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Enable the Home Assistant API
|
||||||
|
# https://esphome.io/components/api.html
|
||||||
|
#############################################
|
||||||
|
api:
|
||||||
|
encryption:
|
||||||
|
key: ${api_key}
|
||||||
|
on_client_connected:
|
||||||
|
- esp32_ble_tracker.start_scan:
|
||||||
|
continuous: true
|
||||||
|
on_client_disconnected:
|
||||||
|
- esp32_ble_tracker.stop_scan:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# i2c bus
|
||||||
|
# https://esphome.io/components/i2c.html
|
||||||
|
# 10, 50, 100, 200, 800 are possible settings
|
||||||
|
# for frequency, 50kHz is default
|
||||||
|
#############################################
|
||||||
|
i2c:
|
||||||
|
sda: GPIO19
|
||||||
|
scl: GPIO21
|
||||||
|
scan: True #look for devices on boot up and report
|
||||||
|
frequency: 50kHz
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# UART Serial
|
||||||
|
# hardware on EPS32, but software, and can be glitchy on ESP8266
|
||||||
|
# https://esphome.io/components/uart.html
|
||||||
|
#############################################
|
||||||
|
uart:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang
|
||||||
|
tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang
|
||||||
|
baud_rate: 115200
|
||||||
|
data_bits: 8
|
||||||
|
stop_bits: 1
|
||||||
|
parity: NONE
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Bluetooth
|
||||||
|
# https://esphome.io/components/bluetooth_proxy.html
|
||||||
|
# https://esphome.io/components/esp32_ble_tracker.html
|
||||||
|
# Remember that this takes a LOT of processing. On the
|
||||||
|
# ESP32, enable the IDF framework, and disable the
|
||||||
|
# Web server component. Changing to the IDF framework
|
||||||
|
# needs to be via cable not OTA to change the
|
||||||
|
# partition setup.
|
||||||
|
#############################################
|
||||||
|
bluetooth_proxy:
|
||||||
|
active: true
|
||||||
|
cache_services: true
|
||||||
|
|
||||||
|
esp32_ble_tracker:
|
||||||
|
scan_parameters:
|
||||||
|
continuous: false
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Global Variables for use in automations etc
|
||||||
|
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
|
||||||
|
#############################################
|
||||||
|
globals:
|
||||||
|
- id: LD1125H_Last_Time
|
||||||
|
type: time_t
|
||||||
|
restore_value: no
|
||||||
|
#initial_value: time(NULL)
|
||||||
|
#initial_value: !lambda 'return ::time(nullptr);'
|
||||||
|
initial_value: "0"
|
||||||
|
- id: LD1125H_Last_Mov_Time
|
||||||
|
type: time_t
|
||||||
|
restore_value: no
|
||||||
|
#initial_value: time(NULL)
|
||||||
|
#initial_value: !lambda 'return ::time(nullptr);'
|
||||||
|
initial_value: "0"
|
||||||
|
- id: LD1125H_Clearence_Status
|
||||||
|
type: bool
|
||||||
|
restore_value: no
|
||||||
|
initial_value: "false"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# General esp status LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
status_led:
|
||||||
|
pin:
|
||||||
|
number: GPIO2 #ESP32 Onboard LED
|
||||||
|
ignore_strapping_warning: True #https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
|
||||||
|
inverted: false
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Interval Automations
|
||||||
|
# https://esphome.io/guides/automations.html
|
||||||
|
#############################################
|
||||||
|
interval:
|
||||||
|
- interval: 1s #Clearance Scan Time
|
||||||
|
setup_priority: -200
|
||||||
|
then:
|
||||||
|
lambda: |-
|
||||||
|
if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) {
|
||||||
|
if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) {
|
||||||
|
id(LD1125H_Occupancy).publish_state("Clearance");
|
||||||
|
id(LD1125H_Clearence_Status) = true;
|
||||||
|
}
|
||||||
|
if (id(LD1125H_MovOcc_Binary).state == true) {
|
||||||
|
id(LD1125H_MovOcc_Binary).publish_state(false);
|
||||||
|
}
|
||||||
|
if (id(LD1125H_Mov_Binary).state == true) {
|
||||||
|
id(LD1125H_Mov_Binary).publish_state(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Number Sensors (custom component)
|
||||||
|
# refer https://github.com/ssieb/esphome_components/tree/master/components/serial
|
||||||
|
#############################################
|
||||||
|
number:
|
||||||
|
- platform: template
|
||||||
|
name: ${friendly_name} LD1125H mth1 #mth1 is 0~2.8m Sensitivity.
|
||||||
|
id: LD1125H_mth1
|
||||||
|
icon: "mdi:cogs"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true #If you don't want to store the setting at ESP, set it to false.
|
||||||
|
initial_value: "60.0" #Default mth1 Setting
|
||||||
|
min_value: 10.0
|
||||||
|
max_value: 600.0
|
||||||
|
step: 5.0
|
||||||
|
set_action:
|
||||||
|
then:
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(th1st.begin(), th1st.end());
|
||||||
|
- platform: template
|
||||||
|
name: ${friendly_name} LD1125H mth2 #mth2 is 2.8~8m Sensitivity.
|
||||||
|
id: LD1125H_mth2
|
||||||
|
icon: "mdi:cogs"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true #If you don't want to store the setting at ESP, set it to false.
|
||||||
|
initial_value: "30" #Default mth2 Setting
|
||||||
|
min_value: 5
|
||||||
|
max_value: 300
|
||||||
|
step: 5
|
||||||
|
set_action:
|
||||||
|
then:
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(th2st.begin(), th2st.end());
|
||||||
|
- platform: template
|
||||||
|
name: ${friendly_name} LD1125H mth3 #mth3 is above 8m Sensitivity.
|
||||||
|
id: LD1125H_mth3
|
||||||
|
icon: "mdi:cogs"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true #If you don't want to store the setting at ESP, set it to false.
|
||||||
|
initial_value: "20" #Default mth3 Setting
|
||||||
|
min_value: 5
|
||||||
|
max_value: 200
|
||||||
|
step: 5
|
||||||
|
set_action:
|
||||||
|
then:
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(th3st.begin(), th3st.end());
|
||||||
|
- platform: template
|
||||||
|
name: ${friendly_name} LD1125H rmax #rmax is max detection distance.
|
||||||
|
id: LD1125H_rmax
|
||||||
|
icon: "mdi:cogs"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true #If you don't want to store the setting at ESP, set it to false.
|
||||||
|
initial_value: "8" #Default rmax Setting
|
||||||
|
min_value: 0.4
|
||||||
|
max_value: 12
|
||||||
|
step: 0.1
|
||||||
|
set_action:
|
||||||
|
then:
|
||||||
|
- uart.write:
|
||||||
|
id: LD1125H_UART_BUS
|
||||||
|
data: !lambda |-
|
||||||
|
std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n";
|
||||||
|
return std::vector<uint8_t>(rmaxst.begin(), rmaxst.end());
|
||||||
|
- platform: template
|
||||||
|
name: ${friendly_name} LD1125H Clearence Time
|
||||||
|
id: LD1125H_Clear_Time
|
||||||
|
icon: "mdi:cogs"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true #If you don't want to store the setting at ESP, set it to false.
|
||||||
|
initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here
|
||||||
|
min_value: 0.5
|
||||||
|
max_value: 20
|
||||||
|
step: 0.5
|
||||||
|
- platform: template
|
||||||
|
name: ${friendly_name} LD1125H Movement Time
|
||||||
|
id: LD1125H_Mov_Time
|
||||||
|
icon: "mdi:cogs"
|
||||||
|
optimistic: true
|
||||||
|
restore_value: true #If you don't want to store the setting at ESP, set it to false.
|
||||||
|
initial_value: "1" #LD1125H Mov > Occ Time Here
|
||||||
|
min_value: 0.5
|
||||||
|
max_value: 10
|
||||||
|
step: 0.5
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# General Sensors
|
||||||
|
# https://esphome.io/components/sensor/index.html
|
||||||
|
#############################################
|
||||||
|
sensor:
|
||||||
|
- platform: bme280_i2c
|
||||||
|
temperature:
|
||||||
|
name: "Temperature"
|
||||||
|
accuracy_decimals: 1
|
||||||
|
oversampling: 2x
|
||||||
|
pressure:
|
||||||
|
name: "Pressure"
|
||||||
|
oversampling: 2x
|
||||||
|
humidity:
|
||||||
|
name: "Humidity"
|
||||||
|
accuracy_decimals: 1
|
||||||
|
oversampling: 2x
|
||||||
|
address: 0x76
|
||||||
|
update_interval: ${update_interval}
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "mmWave Distance"
|
||||||
|
id: LD1125H_Distance
|
||||||
|
icon: "mdi:signal-distance-variant"
|
||||||
|
unit_of_measurement: "m"
|
||||||
|
accuracy_decimals: 2
|
||||||
|
filters: # Use Fliter To Debounce
|
||||||
|
- sliding_window_moving_average:
|
||||||
|
window_size: 8
|
||||||
|
send_every: 2
|
||||||
|
- heartbeat: 0.2s
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Text Sensors
|
||||||
|
# refer https://esphome.io/components/text_sensor/index.html
|
||||||
|
#############################################
|
||||||
|
text_sensor:
|
||||||
|
- platform: serial
|
||||||
|
uart_id: LD1125H_UART_BUS
|
||||||
|
name: ${friendly_name} LD1125H UART Text
|
||||||
|
id: LD1125H_UART_Text
|
||||||
|
icon: "mdi:format-text"
|
||||||
|
internal: True #If Don't Want to See UART Receive Data, Set To True
|
||||||
|
on_value:
|
||||||
|
lambda: |-
|
||||||
|
if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") {
|
||||||
|
id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str()));
|
||||||
|
if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) {
|
||||||
|
id(LD1125H_Occupancy).publish_state("Occupancy");
|
||||||
|
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||||
|
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||||
|
}
|
||||||
|
if (id(LD1125H_Mov_Binary).state == true) {
|
||||||
|
id(LD1125H_Mov_Binary).publish_state(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||||
|
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||||
|
}
|
||||||
|
id(LD1125H_Last_Time) = time(NULL);
|
||||||
|
if (id(LD1125H_Clearence_Status) == true) {
|
||||||
|
id(LD1125H_Clearence_Status) = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") {
|
||||||
|
id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str()));
|
||||||
|
id(LD1125H_Occupancy).publish_state("Movement");
|
||||||
|
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||||
|
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||||
|
}
|
||||||
|
if (id(LD1125H_Mov_Binary).state == false) {
|
||||||
|
id(LD1125H_Mov_Binary).publish_state(true);
|
||||||
|
}
|
||||||
|
id(LD1125H_Last_Mov_Time) = time(NULL);
|
||||||
|
id(LD1125H_Last_Time) = time(NULL);
|
||||||
|
if (id(LD1125H_Clearence_Status) == true) {
|
||||||
|
id(LD1125H_Clearence_Status) = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- platform: template
|
||||||
|
name: "mmWave Occupancy"
|
||||||
|
id: LD1125H_Occupancy
|
||||||
|
icon: "mdi:motion-sensor"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Binary Sensors
|
||||||
|
# https://esphome.io/components/binary_sensor/index.html
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: status
|
||||||
|
name: ${friendly_name} Status
|
||||||
|
- platform: template
|
||||||
|
name: "mmWave Occupancy or Movement"
|
||||||
|
id: LD1125H_MovOcc_Binary
|
||||||
|
device_class: occupancy
|
||||||
|
- platform: template
|
||||||
|
name: "mmWave Movement"
|
||||||
|
id: LD1125H_Mov_Binary
|
||||||
|
device_class: motion
|
456
esphome/archive/esp-occupancystair.yaml
Normal file
456
esphome/archive/esp-occupancystair.yaml
Normal file
@@ -0,0 +1,456 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# HiLink LD2410 mmWave sensor, with BME280 Temp/Hum/Pres Sensor and PIR on an ESP32
|
||||||
|
# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/tree/main
|
||||||
|
# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/blob/main/LD1125H/ESP32-LD1125H-Complete.yaml
|
||||||
|
#
|
||||||
|
# https://esphome.io/components/sensor/ld2410.html
|
||||||
|
# https://www.simplysmart.house/blog/presence-detection-ld2410-home-assistant
|
||||||
|
#
|
||||||
|
# The B and c versions of this device can use Bluetooth, but we are not using it here.
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# VARIABLE SUBSTITUTIONS
|
||||||
|
# Give the device a useful name & description here
|
||||||
|
# and change values accordingly.
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
devicename: "esp-occupancystair"
|
||||||
|
friendly_name: "Stair Occupancy and Underhouse Environment"
|
||||||
|
description_comment: "D1 Mini ESP32 with LD2410 mmWave for internal stairwell and environment sensors for under house"
|
||||||
|
#wifi_ssid: !secret wifi_ssid
|
||||||
|
#wifi_password: !secret wifi_password
|
||||||
|
#fallback_ap_password: !secret fallback_ap_password
|
||||||
|
#Add these if we are giving it a static ip, or remove them in the Wifi section
|
||||||
|
#static_ip_address: !secret esp-occupancystair_static_ip
|
||||||
|
#static_ip_gateway: !secret esp-occupancystair_gateway
|
||||||
|
#static_ip_subnet: !secret esp-occupancystair_subnet
|
||||||
|
api_key: !secret esp-occupancystair_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-occupancystair_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-occupancystair_ip
|
||||||
|
|
||||||
|
mqtt_server: !secret mqtt_server
|
||||||
|
mqtt_username: !secret mqtt_username
|
||||||
|
mqtt_password: !secret mqtt_password
|
||||||
|
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
||||||
|
|
||||||
|
#web_server_username: !secret web_server_username
|
||||||
|
#web_server_password: !secret web_server_password
|
||||||
|
|
||||||
|
update_time: 30s #update time for for general temp sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: ${devicename}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
comment: ${description_comment} #appears on the esphome page in HA
|
||||||
|
min_version: 2024.6.0
|
||||||
|
#on_boot: #Initial Setting, will remember previous values (if set)
|
||||||
|
#priority: -200
|
||||||
|
#then:
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp32:
|
||||||
|
board: esp32dev
|
||||||
|
framework:
|
||||||
|
#type: arduino
|
||||||
|
type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang.
|
||||||
|
version: recommended #recommended, latest or dev
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# i2s bus
|
||||||
|
# https://esphome.io/components/i2c.html
|
||||||
|
#############################################
|
||||||
|
i2c:
|
||||||
|
sda: GPIO19
|
||||||
|
scl: GPIO21
|
||||||
|
scan: True
|
||||||
|
frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: INFO #INFO Level suggested, or DEBUG for testing
|
||||||
|
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Enable the Home Assistant API
|
||||||
|
# https://esphome.io/components/api.html
|
||||||
|
#############################################
|
||||||
|
#api:
|
||||||
|
# encryption:
|
||||||
|
# key: ${api_key}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Enable Over the Air Update Capability
|
||||||
|
# https://esphome.io/components/ota.html?highlight=ota
|
||||||
|
#############################################
|
||||||
|
#ota:
|
||||||
|
# - platform: esphome
|
||||||
|
# password: ${ota_pass}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Safe Mode
|
||||||
|
# Safe mode will detect boot loops
|
||||||
|
# https://esphome.io/components/safe_mode
|
||||||
|
#############################################
|
||||||
|
#safe_mode:
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Wifi Settings
|
||||||
|
# https://esphome.io/components/wifi.html
|
||||||
|
#
|
||||||
|
# Power Save mode (can reduce wifi reliability)
|
||||||
|
# NONE (least power saving, Default for ESP8266)
|
||||||
|
# LIGHT (Default for ESP32)
|
||||||
|
# HIGH (most power saving)
|
||||||
|
#############################################
|
||||||
|
#wifi:
|
||||||
|
# ssid: ${wifi_ssid}
|
||||||
|
# password: ${wifi_password}
|
||||||
|
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
||||||
|
#manual_ip: #optional static IP address
|
||||||
|
#static_ip: ${static_ip_address}
|
||||||
|
#gateway: ${static_ip_gateway}
|
||||||
|
#subnet: ${static_ip_subnet}
|
||||||
|
# ap: #Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
||||||
|
# ssid: ${devicename} fallback AP
|
||||||
|
# password: ${fallback_ap_password}
|
||||||
|
# ap_timeout: 30min #Time until it brings up fallback AP. default is 1min
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Web Portal for display and monitoring
|
||||||
|
# Turning this off is probably a good idea to save resources.
|
||||||
|
# https://esphome.io/components/web_server.html
|
||||||
|
#############################################
|
||||||
|
#web_server:
|
||||||
|
# port: 80
|
||||||
|
# auth:
|
||||||
|
# username: ${web_server_username} #probably a good idea to secure it
|
||||||
|
# password: ${web_server_password}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# MQTT Monitoring
|
||||||
|
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
||||||
|
# MUST also have api enabled if you enable MQTT
|
||||||
|
#############################################
|
||||||
|
mqtt:
|
||||||
|
broker: ${mqtt_server}
|
||||||
|
topic_prefix: ${mqtt_topic}/${devicename}
|
||||||
|
username: ${mqtt_username}
|
||||||
|
password: ${mqtt_password}
|
||||||
|
discovery: False # enable entity discovery (true is default)
|
||||||
|
discover_ip: False # enable device discovery (true is default)
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Bluetooth
|
||||||
|
# https://esphome.io/components/bluetooth_proxy.html
|
||||||
|
# https://esphome.io/components/esp32_ble_tracker.html
|
||||||
|
# Remember that this takes a LOT of processing. On the
|
||||||
|
# ESP32, enable the IDF framework, and disable the
|
||||||
|
# Web server component. Changing to the IDF framework
|
||||||
|
# needs to be via cable not OTA to change the
|
||||||
|
# partition setup.
|
||||||
|
#############################################
|
||||||
|
#bluetooth_proxy:
|
||||||
|
|
||||||
|
#esp32_ble_tracker:
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# UART Serial
|
||||||
|
# hardware on EPS32, but software, and can be glitchy on ESP8266
|
||||||
|
# https://esphome.io/components/uart.html?highlight=uart
|
||||||
|
#############################################
|
||||||
|
uart:
|
||||||
|
id: ld2410_uart
|
||||||
|
rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang
|
||||||
|
tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang
|
||||||
|
baud_rate: 256000 # default for LD2410 is 25600, 8, 0, NONE
|
||||||
|
data_bits: 8
|
||||||
|
stop_bits: 1
|
||||||
|
parity: NONE
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# General esp status LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
status_led:
|
||||||
|
pin:
|
||||||
|
number: GPIO2 #ESP32 Onboard LED
|
||||||
|
ignore_strapping_warning: True #https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
|
||||||
|
inverted: false
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# LD2410 Sensors
|
||||||
|
# https://esphome.io/components/sensor/ld2410.html
|
||||||
|
# https://www.hlktech.net/index.php?id=988
|
||||||
|
#############################################
|
||||||
|
ld2410:
|
||||||
|
uart_id: ld2410_uart
|
||||||
|
#uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses.
|
||||||
|
#throttle (Optional, int): Time in milliseconds to control the rate of data updates. Defaults to 1000ms.
|
||||||
|
#id (Optional, ID): Manually specify the ID for this LD2410 Sensor component if you need multiple components.
|
||||||
|
|
||||||
|
# light (Optional, int): When in engineering mode, indicates the light sensitivity, otherwise unknown. Value between 0 and 255 inclusive. Though it seems that the value 85 is the lowest value at complete darkness. All options from Sensor.
|
||||||
|
# moving_distance (Optional, int): Distance in cm of detected moving target. All options from Sensor.
|
||||||
|
# still_distance (Optional, int): Distance in cm of detected still target. All options from Sensor.
|
||||||
|
# moving_energy (Optional, int): Energy for moving target. Value between 0 and 100 inclusive. All options from Sensor.
|
||||||
|
# still_energy (Optional, int): Energy for still target. Value between 0 and 100 inclusive. All options from Sensor.
|
||||||
|
# detection_distance (Optional, int): Distance in cm of target. All options from Sensor.
|
||||||
|
# gX (Optional): Energies for the Xth gate (X => 0 to 8).
|
||||||
|
# move_energy (Optional, int): When in engineering mode, the move energy of the gate, otherwise unknown. Value between 0 and 100 inclusive. All options from Sensor.
|
||||||
|
#still_energy (Optional, int): When in engineering mode, the still energy of the gate, otherwise unknown. Value between 0 and 100 inclusive. All options from Sensor.
|
||||||
|
#ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component if you are using multiple components.
|
||||||
|
|
||||||
|
#The ld2410 number values for setting thresholds
|
||||||
|
# timeout: 5s
|
||||||
|
# max_move_distance: 2.25m
|
||||||
|
# max_still_distance: 2.25m
|
||||||
|
# g0_move_threshold: 40 # 0m / 0'
|
||||||
|
# g0_still_threshold: 10 # 0m / 0'
|
||||||
|
# g1_move_threshold: 40 # 0 - 0.75m / 0 - 2.46'
|
||||||
|
# g1_still_threshold: 10 # 0 - 0.75m / 0 - 2.46'
|
||||||
|
# g2_move_threshold: 40 # 0.75 - 1.5m / 2.46' - 4.92'
|
||||||
|
# g2_still_threshold: 10 # 0.75 - 1.5m / 2.46' - 4.92'
|
||||||
|
# g3_move_threshold: 40 # 1.5 - 2.25m / 4.92' - 7.38'
|
||||||
|
# g3_still_threshold: 10 # 1.5 - 2.25m / 4.92' - 7.38'
|
||||||
|
# g4_move_threshold: 40 # 2.25 - 3m' / 7.38' - 9.84'
|
||||||
|
# g4_still_threshold: 40 # 2.25 - 3m' / 7.38' - 9.84'
|
||||||
|
# g5_move_threshold: 40 # 3 - 3.75 / 9.84' - 12.30'
|
||||||
|
# g5_still_threshold: 40 # 3 - 3.75 / 9.84' - 12.30'
|
||||||
|
# g6_move_threshold: 30 # 3.75 - 4.5m / 12.30' - 14.76'
|
||||||
|
# g6_still_threshold: 15 # 3.75 - 4.5m / 12.30' - 14.76'
|
||||||
|
# g7_move_threshold: 30 # 4.5 - 5.25m / 14.76' - 17.22'
|
||||||
|
# g7_still_threshold: 15 # 4.5 - 5.25m / 14.76' - 17.22'
|
||||||
|
# g8_move_threshold: 30 # 5.25 - 6m / 17.22' - 19.68'
|
||||||
|
# g8_still_threshold: 15 # 5.25 - 6m / 17.22' - 19.68'
|
||||||
|
number:
|
||||||
|
- platform: ld2410
|
||||||
|
timeout:
|
||||||
|
name: Timeout
|
||||||
|
light_threshold:
|
||||||
|
name: Light Threshold
|
||||||
|
max_move_distance_gate:
|
||||||
|
name: Max Move Distance Gate
|
||||||
|
max_still_distance_gate:
|
||||||
|
name: Max Still Distance Gate
|
||||||
|
g0:
|
||||||
|
move_threshold:
|
||||||
|
name: g0 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g0 still threshold
|
||||||
|
g1:
|
||||||
|
move_threshold:
|
||||||
|
name: g1 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g1 still threshold
|
||||||
|
g2:
|
||||||
|
move_threshold:
|
||||||
|
name: g2 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g2 still threshold
|
||||||
|
g3:
|
||||||
|
move_threshold:
|
||||||
|
name: g3 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g3 still threshold
|
||||||
|
g4:
|
||||||
|
move_threshold:
|
||||||
|
name: g4 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g4 still threshold
|
||||||
|
g5:
|
||||||
|
move_threshold:
|
||||||
|
name: g5 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g5 still threshold
|
||||||
|
g6:
|
||||||
|
move_threshold:
|
||||||
|
name: g6 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g6 still threshold
|
||||||
|
g7:
|
||||||
|
move_threshold:
|
||||||
|
name: g7 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g7 still threshold
|
||||||
|
g8:
|
||||||
|
move_threshold:
|
||||||
|
name: g8 move threshold
|
||||||
|
still_threshold:
|
||||||
|
name: g8 still threshold
|
||||||
|
|
||||||
|
#The ld2410 select allows you to control your LD2410 Sensor.
|
||||||
|
#distance_resolution (Optional): Control the gates distance resolution. Can be 0.75m or 0.2m. Defaults to 0.75m. All options from Select.
|
||||||
|
#baud_rate (Optional): Control the serial port baud rate. Defaults to 256000. Once changed, all sensors will stop working until a fresh install with an updated UART Component configuration. All options from Select.
|
||||||
|
#light_function (Optional): If set, will affect the OUT pin value, based on light threshold. Can be off, low or above. Defaults to off. All options from Select.
|
||||||
|
#out_pin_level (Optional): Control OUT pin away value. Can be low or high. Defaults to low. All options from Select.
|
||||||
|
#ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component if you are using multiple components.
|
||||||
|
select:
|
||||||
|
- platform: ld2410
|
||||||
|
distance_resolution:
|
||||||
|
name: ${friendly_name} LD2140 Distance Resolution
|
||||||
|
baud_rate:
|
||||||
|
name: ${friendly_name} LD2140 Baud Rate
|
||||||
|
light_function:
|
||||||
|
name: ${friendly_name} LD2140 Light Function
|
||||||
|
out_pin_level:
|
||||||
|
name: ${friendly_name} LD2140 Out Pin Level
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# General Sensors
|
||||||
|
# https://esphome.io/components/sensor/index.html
|
||||||
|
#############################################
|
||||||
|
sensor:
|
||||||
|
- platform: bme280_i2c
|
||||||
|
temperature:
|
||||||
|
name: ${friendly_name} BME280 Temp
|
||||||
|
accuracy_decimals: 1
|
||||||
|
oversampling: 2x
|
||||||
|
pressure:
|
||||||
|
name: ${friendly_name} BME280 Pressure
|
||||||
|
oversampling: 2x
|
||||||
|
humidity:
|
||||||
|
name: ${friendly_name} BME280 Humidity
|
||||||
|
accuracy_decimals: 1
|
||||||
|
oversampling: 2x
|
||||||
|
address: 0x76
|
||||||
|
update_interval: ${update_time}
|
||||||
|
- platform: uptime
|
||||||
|
name: ${friendly_name} Uptime
|
||||||
|
#The ld2410 sensor values
|
||||||
|
- platform: ld2410
|
||||||
|
light:
|
||||||
|
name: Light
|
||||||
|
moving_distance:
|
||||||
|
name : Moving Distance
|
||||||
|
still_distance:
|
||||||
|
name: Still Distance
|
||||||
|
moving_energy:
|
||||||
|
name: Move Energy
|
||||||
|
still_energy:
|
||||||
|
name: Still Energy
|
||||||
|
detection_distance:
|
||||||
|
name: Detection Distance
|
||||||
|
g0:
|
||||||
|
move_energy:
|
||||||
|
name: g0 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g0 still energy
|
||||||
|
g1:
|
||||||
|
move_energy:
|
||||||
|
name: g1 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g1 still energy
|
||||||
|
g2:
|
||||||
|
move_energy:
|
||||||
|
name: g2 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g2 still energy
|
||||||
|
g3:
|
||||||
|
move_energy:
|
||||||
|
name: g3 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g3 still energy
|
||||||
|
g4:
|
||||||
|
move_energy:
|
||||||
|
name: g4 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g4 still energy
|
||||||
|
g5:
|
||||||
|
move_energy:
|
||||||
|
name: g5 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g5 still energy
|
||||||
|
g6:
|
||||||
|
move_energy:
|
||||||
|
name: g6 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g6 still energy
|
||||||
|
g7:
|
||||||
|
move_energy:
|
||||||
|
name: g7 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g7 still energy
|
||||||
|
g8:
|
||||||
|
move_energy:
|
||||||
|
name: g8 move energy
|
||||||
|
still_energy:
|
||||||
|
name: g8 still energy
|
||||||
|
|
||||||
|
# The ld2410 switch allows you to control your LD2410 Sensor.
|
||||||
|
#Bluetooth switch is only useful of you have a B or C model
|
||||||
|
switch:
|
||||||
|
- platform: ld2410
|
||||||
|
engineering_mode:
|
||||||
|
name: ${friendly_name} LD2140 Engineering Mode
|
||||||
|
#bluetooth:
|
||||||
|
#name: ${friendly_name} LD2140 Control Bluetooth
|
||||||
|
|
||||||
|
#The ld2410 binary sensors to get presence notification
|
||||||
|
binary_sensor:
|
||||||
|
- platform: ld2410
|
||||||
|
has_target:
|
||||||
|
name: ${friendly_name} Presence
|
||||||
|
has_moving_target:
|
||||||
|
name: ${friendly_name} Moving Target
|
||||||
|
has_still_target:
|
||||||
|
name: ${friendly_name} Still Target
|
||||||
|
out_pin_presence_status:
|
||||||
|
name: ${friendly_name} LD2140 Out Pin Presence Status
|
||||||
|
|
||||||
|
#Standard PIR Sensor
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO13
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: true
|
||||||
|
inverted: true
|
||||||
|
name: ${friendly_name} PIR Sensor
|
||||||
|
device_class: motion
|
||||||
|
|
||||||
|
#The ld2410 button allows resetting
|
||||||
|
button:
|
||||||
|
- platform: ld2410
|
||||||
|
factory_reset:
|
||||||
|
name: ${friendly_name} LD2140 Factory reset"
|
||||||
|
restart:
|
||||||
|
name: ${friendly_name} LD2140 Restart
|
||||||
|
query_params:
|
||||||
|
name: Query Parameters
|
||||||
|
|
||||||
|
#The ld2410 text sensor allows you to get information about your LD2410 Sensor.
|
||||||
|
#Bluetooth sensor is only useful of you have a B or C model
|
||||||
|
text_sensor:
|
||||||
|
- platform: ld2410
|
||||||
|
version:
|
||||||
|
name: ${friendly_name} LD2140 Firmware Version
|
||||||
|
#mac_address:
|
||||||
|
#name: ${friendly_name} LD2140 BT MAC Address
|
||||||
|
|
||||||
|
|
30
esphome/archive/laundry-washer-power.yaml
Normal file
30
esphome/archive/laundry-washer-power.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
esphome:
|
||||||
|
name: laundry-washer-power
|
||||||
|
friendly_name: Laundry Washer Power
|
||||||
|
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
|
||||||
|
# Enable logging
|
||||||
|
logger:
|
||||||
|
|
||||||
|
# Enable Home Assistant API
|
||||||
|
api:
|
||||||
|
encryption:
|
||||||
|
key: "24fFKajbAkapEa24hpnFOpNrM2uJ11WM9k5E3sI4AGU="
|
||||||
|
|
||||||
|
ota:
|
||||||
|
- platform: esphome
|
||||||
|
password: "32516b91a48d43b4cdf0f13fc145752e"
|
||||||
|
|
||||||
|
wifi:
|
||||||
|
ssid: !secret wifi_ssid
|
||||||
|
password: !secret wifi_password
|
||||||
|
|
||||||
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||||
|
ap:
|
||||||
|
ssid: "Laundry-Washer-Power"
|
||||||
|
password: "tSoGV9xt4c2n"
|
||||||
|
|
||||||
|
captive_portal:
|
||||||
|
|
66
esphome/archive/sntp_common copy.yaml
Normal file
66
esphome/archive/sntp_common copy.yaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
##############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace
|
||||||
|
# these with the values (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
timezone: "Pacific/Auckland"
|
||||||
|
sntp_update_interval: 6h # Set the duration between the sntp service polling
|
||||||
|
# Network time servers https://www.ntppool.org/zone/@
|
||||||
|
sntp_server_1: !secret ntp_server_1
|
||||||
|
sntp_server_2: !secret ntp_server_2
|
||||||
|
sntp_server_3: !secret ntp_server_3
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Real time clock time source for ESPHome
|
||||||
|
# If it's invalid, we fall back to an internal clock
|
||||||
|
# https://esphome.io/components/time/index.html
|
||||||
|
# https://esphome.io/components/time/sntp
|
||||||
|
#############################################
|
||||||
|
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");'
|
||||||
|
|
||||||
|
text_sensor:
|
||||||
|
# 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
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "Internal Time"
|
||||||
|
id: time_text
|
||||||
|
update_interval: "1min"
|
||||||
|
entity_category: diagnostic
|
||||||
|
lambda: |-
|
||||||
|
auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
||||||
|
return { time_text };
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "Time Sync Status"
|
||||||
|
id: time_sync
|
||||||
|
update_interval: "1min"
|
||||||
|
entity_category: diagnostic
|
8
esphome/common/api_common.yaml
Normal file
8
esphome/common/api_common.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#############################################
|
||||||
|
# Enable the Home Assistant API
|
||||||
|
# https://esphome.io/components/api.html
|
||||||
|
#############################################
|
||||||
|
api:
|
||||||
|
encryption:
|
||||||
|
key: ${local_api_key}
|
||||||
|
|
@@ -17,5 +17,6 @@ mqtt:
|
|||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
topic_prefix: ${mqtt_topic}/${devicename}
|
||||||
username: ${mqtt_username}
|
username: ${mqtt_username}
|
||||||
password: ${mqtt_password}
|
password: ${mqtt_password}
|
||||||
discovery: false # enable entity discovery (true is default, we don't want two HA Instances)
|
discovery: False # enable entity discovery (true is default)
|
||||||
|
discover_ip: False # enable device discovery (true is default)
|
||||||
id: mqtt_client
|
id: mqtt_client
|
||||||
|
@@ -17,6 +17,9 @@ substitutions:
|
|||||||
# eg so you can use a single firmware for all devices
|
# eg so you can use a single firmware for all devices
|
||||||
add_mac_suffix: "false"
|
add_mac_suffix: "false"
|
||||||
|
|
||||||
|
# Enable or disable the use of IPv6 networking on the device
|
||||||
|
ipv6_enable: "false"
|
||||||
|
|
||||||
# Add these if we are giving it a static ip, or remove them in the Wifi section
|
# Add these if we are giving it a static ip, or remove them in the Wifi section
|
||||||
static_ip_subnet: !secret ha_wifi_subnet
|
static_ip_subnet: !secret ha_wifi_subnet
|
||||||
static_ip_gateway: !secret ha_wifi_gateway
|
static_ip_gateway: !secret ha_wifi_gateway
|
||||||
@@ -43,7 +46,7 @@ wifi:
|
|||||||
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
||||||
ssid: ${devicename} AP
|
ssid: ${devicename} AP
|
||||||
password: ${fallback_ap_password}
|
password: ${fallback_ap_password}
|
||||||
ap_timeout: 30min # Time until it brings up fallback AP. default is 1min
|
ap_timeout: 10min # Time until it brings up fallback AP. default is 1min
|
||||||
# Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
|
# Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
|
||||||
fast_connect: "${wifi_fast_connect}"
|
fast_connect: "${wifi_fast_connect}"
|
||||||
# Define dns domain / suffix to add to hostname
|
# Define dns domain / suffix to add to hostname
|
||||||
@@ -51,14 +54,6 @@ wifi:
|
|||||||
|
|
||||||
captive_portal: # extra fallback mechanism for when connecting if the configured WiFi fails
|
captive_portal: # extra fallback mechanism for when connecting if the configured WiFi fails
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${local_api_key}
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Enable Over the Air Update Capability
|
# Enable Over the Air Update Capability
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
# https://esphome.io/components/ota.html?highlight=ota
|
||||||
@@ -73,3 +68,11 @@ ota:
|
|||||||
# https://esphome.io/components/safe_mode
|
# https://esphome.io/components/safe_mode
|
||||||
#############################################
|
#############################################
|
||||||
safe_mode:
|
safe_mode:
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Network
|
||||||
|
# global configuration for all types of networks
|
||||||
|
# https://esphome.io/components/network.html
|
||||||
|
#############################################
|
||||||
|
network:
|
||||||
|
enable_ipv6: ${ipv6_enable}
|
111
esphome/common/sensors_common copy.yaml
Normal file
111
esphome/common/sensors_common copy.yaml
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#############################################
|
||||||
|
# GENERAL COMMON SENSORS
|
||||||
|
# https://esphome.io/components/sensor/
|
||||||
|
#############################################
|
||||||
|
sensor:
|
||||||
|
- platform: uptime # Uptime for this device in seconds
|
||||||
|
name: "Uptime (s):"
|
||||||
|
update_interval: ${local_update_interval}
|
||||||
|
id: uptime_sensor
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
- platform: wifi_signal # Wifi Strength
|
||||||
|
name: "Wifi (dB):"
|
||||||
|
id: wifi_signal_db
|
||||||
|
update_interval: ${local_update_interval}
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
- platform: copy # Reports the WiFi signal strength in %
|
||||||
|
source_id: wifi_signal_db
|
||||||
|
name: "WiFi (%):"
|
||||||
|
filters:
|
||||||
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
|
unit_of_measurement: "% Max"
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
device_class: ""
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: status
|
||||||
|
name: "Network Status"
|
||||||
|
icon: mdi:check-network-outline
|
||||||
|
entity_category: diagnostic
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Text Sensors
|
||||||
|
# https://esphome.io/components/text_sensor/index.html
|
||||||
|
#############################################
|
||||||
|
text_sensor:
|
||||||
|
######################################################
|
||||||
|
# General ESPHome Info
|
||||||
|
######################################################
|
||||||
|
- platform: version
|
||||||
|
name: "Version:"
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
- platform: wifi_info
|
||||||
|
ip_address:
|
||||||
|
icon: mdi:ip-network
|
||||||
|
entity_category: diagnostic
|
||||||
|
name: "IP Address:"
|
||||||
|
ssid:
|
||||||
|
name: "Connected SSID"
|
||||||
|
icon: mdi:wifi-strength-2
|
||||||
|
entity_category: diagnostic
|
||||||
|
mac_address:
|
||||||
|
name: "MAC Address:"
|
||||||
|
icon: mdi:network-pos
|
||||||
|
entity_category: diagnostic
|
||||||
|
- platform: uptime # Uptime for this device human readable
|
||||||
|
name: "Uptime:"
|
||||||
|
icon: mdi:clock-start
|
||||||
|
update_interval: ${local_update_interval}
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
|
|
||||||
|
######################################################
|
||||||
|
# Creates a sensor showing when the device was last restarted
|
||||||
|
# Uptime template sensor, and SNTP are needed
|
||||||
|
######################################################
|
||||||
|
#- platform: template
|
||||||
|
# name: ${local_friendly_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 (Days)"
|
||||||
|
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
|
||||||
|
|
||||||
|
button:
|
||||||
|
- platform: safe_mode
|
||||||
|
name: "Safe Mode Restart: ${local_friendly_name}"
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
- platform: restart
|
||||||
|
name: "Restart: ${local_friendly_name}"
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
disabled_by_default: true
|
||||||
|
- platform: factory_reset
|
||||||
|
name: "FACTORY RESET: ${local_friendly_name}"
|
||||||
|
entity_category: "diagnostic"
|
||||||
|
disabled_by_default: true
|
@@ -4,24 +4,30 @@
|
|||||||
#############################################
|
#############################################
|
||||||
sensor:
|
sensor:
|
||||||
- platform: uptime # Uptime for this device in seconds
|
- platform: uptime # Uptime for this device in seconds
|
||||||
name: "Uptime (s): ${local_friendly_name}"
|
name: "Uptime (s):"
|
||||||
update_interval: ${local_update_interval}
|
update_interval: ${local_update_interval}
|
||||||
id: uptime_sensor
|
id: uptime_sensor
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
- platform: wifi_signal # Wifi Strength
|
- platform: wifi_signal # Wifi Strength
|
||||||
name: "Wifi dB: ${local_friendly_name}"
|
name: "Wifi (dB):"
|
||||||
id: wifi_signal_db
|
id: wifi_signal_db
|
||||||
update_interval: ${local_update_interval}
|
update_interval: ${local_update_interval}
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
- platform: copy # Reports the WiFi signal strength in %
|
- platform: copy # Reports the WiFi signal strength in %
|
||||||
source_id: wifi_signal_db
|
source_id: wifi_signal_db
|
||||||
name: "WiFi Percent: ${local_friendly_name}"
|
name: "WiFi (%):"
|
||||||
filters:
|
filters:
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
||||||
unit_of_measurement: "% Max"
|
unit_of_measurement: "% Max"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
device_class: ""
|
device_class: ""
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: status
|
||||||
|
name: "Network Status"
|
||||||
|
icon: mdi:check-network-outline
|
||||||
|
entity_category: diagnostic
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Text Sensors
|
# Text Sensors
|
||||||
# https://esphome.io/components/text_sensor/index.html
|
# https://esphome.io/components/text_sensor/index.html
|
||||||
@@ -31,66 +37,88 @@ text_sensor:
|
|||||||
# General ESPHome Info
|
# General ESPHome Info
|
||||||
######################################################
|
######################################################
|
||||||
- platform: version
|
- platform: version
|
||||||
name: "Version: ${local_friendly_name}"
|
name: "Version:"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
- platform: wifi_info
|
- platform: wifi_info
|
||||||
ip_address:
|
ip_address:
|
||||||
name: "IP Address: ${local_friendly_name}"
|
icon: mdi:ip-network
|
||||||
|
entity_category: diagnostic
|
||||||
|
name: "IP Address:"
|
||||||
|
ssid:
|
||||||
|
name: "Connected SSID"
|
||||||
|
icon: mdi:wifi-strength-2
|
||||||
|
entity_category: diagnostic
|
||||||
|
mac_address:
|
||||||
|
name: "MAC Address:"
|
||||||
|
icon: mdi:network-pos
|
||||||
|
entity_category: diagnostic
|
||||||
- platform: uptime # Uptime for this device human readable
|
- platform: uptime # Uptime for this device human readable
|
||||||
name: "Uptime: ${local_friendly_name}"
|
name: "Uptime:"
|
||||||
icon: mdi:clock-start
|
icon: mdi:clock-start
|
||||||
update_interval: ${local_update_interval}
|
update_interval: ${local_update_interval}
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
|
|
||||||
######################################################
|
|
||||||
# Creates a sensor showing when the device was last restarted
|
|
||||||
# Uptime template sensor, and SNTP are needed
|
|
||||||
######################################################
|
|
||||||
#- platform: template
|
|
||||||
# name: ${local_friendly_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
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
######################################################
|
######################################################
|
||||||
#- platform: template
|
# - platform: template
|
||||||
# name: "Uptime"
|
# name: "Uptime (Days)"
|
||||||
# entity_category: diagnostic
|
# entity_category: diagnostic
|
||||||
# lambda: |-
|
# lambda: |-
|
||||||
# int seconds = (id(uptime_sensor).state);
|
# int seconds = (id(uptime_sensor).state);
|
||||||
# int days = seconds / (24 * 3600);
|
# int days = seconds / (24 * 3600);
|
||||||
# seconds = seconds % (24 * 3600);
|
# seconds = seconds % (24 * 3600);
|
||||||
# int hours = seconds / 3600;
|
# int hours = seconds / 3600;
|
||||||
# seconds = seconds % 3600;
|
# seconds = seconds % 3600;
|
||||||
# int minutes = seconds / 60;
|
# int minutes = seconds / 60;
|
||||||
# seconds = seconds % 60;
|
# seconds = seconds % 60;
|
||||||
# if ( days > 3650 ) {
|
# if ( days > 3650 ) {
|
||||||
# return { "Starting up" };
|
# return "Starting up" ;
|
||||||
# } else if ( days ) {
|
# } else if ( days ) {
|
||||||
# return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
# return (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() ;
|
||||||
# } else if ( hours ) {
|
# } else if ( hours ) {
|
||||||
# return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
# return (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() ;
|
||||||
# } else if ( minutes ) {
|
# } else if ( minutes ) {
|
||||||
# return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
|
# return (String(minutes) +"m "+ String(seconds) +"s").c_str() ;
|
||||||
# } else {
|
# } else {
|
||||||
# return { (String(seconds) +"s").c_str() };
|
# return (String(seconds) +"s").c_str() ;
|
||||||
# }
|
# }
|
||||||
# icon: mdi:clock-start
|
# icon: mdi:clock-start
|
||||||
|
|
||||||
|
# - platform: template
|
||||||
|
# name: "Uptime (Days)"
|
||||||
|
# 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
|
||||||
|
|
||||||
button:
|
button:
|
||||||
- platform: safe_mode
|
- platform: safe_mode
|
||||||
name: "Safe Mode Restart: ${local_friendly_name}"
|
name: "Safe Mode Restart:"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
|
disabled_by_default: true
|
||||||
- platform: restart
|
- platform: restart
|
||||||
name: "Restart: ${local_friendly_name}"
|
name: "Restart:"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
disabled_by_default: true
|
disabled_by_default: true
|
||||||
- platform: factory_reset
|
- platform: factory_reset
|
||||||
name: "FACTORY RESET: ${local_friendly_name}"
|
name: "FACTORY RESET:"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
disabled_by_default: true
|
disabled_by_default: true
|
||||||
|
75
esphome/common/sntp_common.yaml
Normal file
75
esphome/common/sntp_common.yaml
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
##############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace
|
||||||
|
# these with the values (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
timezone: "Pacific/Auckland"
|
||||||
|
sntp_update_interval: 6h # Set the duration between the sntp service polling
|
||||||
|
# Network time servers https://www.ntppool.org/zone/@
|
||||||
|
sntp_server_1: !secret ntp_server_1
|
||||||
|
sntp_server_2: !secret ntp_server_2
|
||||||
|
sntp_server_3: !secret ntp_server_3
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Real time clock time source for ESPHome
|
||||||
|
# If it's invalid, we fall back to an internal clock
|
||||||
|
# https://esphome.io/components/time/index.html
|
||||||
|
# https://esphome.io/components/time/sntp
|
||||||
|
#############################################
|
||||||
|
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:
|
||||||
|
- logger.log: "Synchronised SNTP clock"
|
||||||
|
- text_sensor.template.publish:
|
||||||
|
id: time_sync
|
||||||
|
state: "SNTP clock Syncd"
|
||||||
|
# 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");'
|
||||||
|
state: !lambda |-
|
||||||
|
// grab the current SNTP time
|
||||||
|
auto now = id(sntp_time).now();
|
||||||
|
// format it as e.g. "Fri 23 May 2025 - 03:45:12 PM"
|
||||||
|
return now.strftime("%a %d %b %Y - %I:%M:%S %p");
|
||||||
|
|
||||||
|
text_sensor:
|
||||||
|
# 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
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "Internal Time"
|
||||||
|
id: time_text
|
||||||
|
update_interval: "1min"
|
||||||
|
entity_category: diagnostic
|
||||||
|
lambda: |-
|
||||||
|
auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
||||||
|
return { time_text };
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
name: "Time Sync Status"
|
||||||
|
id: time_sync
|
||||||
|
update_interval: "1min"
|
||||||
|
entity_category: diagnostic
|
20
esphome/common/webportal_common.yaml
Normal file
20
esphome/common/webportal_common.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
##############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace
|
||||||
|
# these with the values (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
web_server_username: !secret web_server_username
|
||||||
|
web_server_password: !secret web_server_password
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Web Portal for display and monitoring
|
||||||
|
# Turning this off is maybe a good idea to save resources,
|
||||||
|
# especially on an esp8266.
|
||||||
|
# https://esphome.io/components/web_server.html
|
||||||
|
#############################################
|
||||||
|
web_server:
|
||||||
|
port: 80
|
||||||
|
auth:
|
||||||
|
username: ${web_server_username} # probably a good idea to secure it
|
||||||
|
password: ${web_server_password}
|
@@ -1,509 +0,0 @@
|
|||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
# Data Cupboard Power Monitor A
|
|
||||||
# Athom Smart Plug Power Monitor ESP32-C3
|
|
||||||
#
|
|
||||||
# V1.0 2025-03-13 Initial Version
|
|
||||||
#
|
|
||||||
# based on https://github.com/athom-tech/esp32-configs/blob/main/athom-smart-plug.yaml
|
|
||||||
#
|
|
||||||
# SUMMARY
|
|
||||||
# Smart plug with power moniroting. It has limited ability to
|
|
||||||
# accidentally turn it off as it powers equipment in a data cupboard.
|
|
||||||
# It does have the ability to turn off and back on automatically
|
|
||||||
# a short time later, just in case a remote system reset is needed.
|
|
||||||
# Also, the button on the side can't be bumped, you have to hold
|
|
||||||
# it down for a few seconds to power it off.
|
|
||||||
# The yaml code also calculates various power use summaries.
|
|
||||||
#
|
|
||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
|
|
||||||
substitutions:
|
|
||||||
#############################################
|
|
||||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
|
||||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
#############################################
|
|
||||||
devicename: "esp-datapower-a"
|
|
||||||
friendly_name: "Data Cupboard Power Monitor A"
|
|
||||||
description_comment: "Smart plug power Monitor A, Data Cupboard"
|
|
||||||
room: "Data Cupboard" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
|
||||||
|
|
||||||
api_key: !secret esp-datapower-a_api_key # unfortunately you can't use substitutions inside secrets names
|
|
||||||
ota_pass: !secret esp-datapower-a_ota_pass # unfortunately you can't use substitutions inside secrets names
|
|
||||||
static_ip_address: !secret esp-datapower-a_ip
|
|
||||||
|
|
||||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
|
||||||
|
|
||||||
update_interval: 10s # update time for for general sensors etc
|
|
||||||
|
|
||||||
# Project Details
|
|
||||||
project_name: "Athom Technology.Smart Plug V3"
|
|
||||||
project_version: "v1.0.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
|
||||||
|
|
||||||
# Restore the relay (GPO switch) upon reboot to state:
|
|
||||||
relay_restore_mode: RESTORE_DEFAULT_ON
|
|
||||||
|
|
||||||
# Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
|
|
||||||
current_limit : "10"
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
# Enable or disable the use of IPv6 networking on the device
|
|
||||||
ipv6_enable: "false"
|
|
||||||
# Power plug icon selection. Change to reflect the type/country of powr plug in use, this will update the power plug icon shown next to the switch
|
|
||||||
power_plug_type: "power-socket-au" # Options: power-socket-au | power-socket-ch | power-socket-de | power-socket-eu | power-socket-fr | power-socket-it | power-socket-jp | power-socket-uk | power-socket-us |
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# SYSTEM SPECIFIC VARIABLE SUBSTITUTIONS
|
|
||||||
#############################################
|
|
||||||
|
|
||||||
timezone: "Pacific/Auckland"
|
|
||||||
sntp_update_interval: 6h # Set the duration between the sntp service polling
|
|
||||||
# Network time servers https://www.ntppool.org/zone/@
|
|
||||||
sntp_server_1: !secret ntp_server_1
|
|
||||||
sntp_server_2: !secret ntp_server_2
|
|
||||||
sntp_server_3: !secret ntp_server_3
|
|
||||||
|
|
||||||
wifi_ssid: !secret ha_wifi_ssid
|
|
||||||
wifi_password: !secret ha_wifi_password
|
|
||||||
fallback_ap_password: !secret fallback_ap_password
|
|
||||||
|
|
||||||
# Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
|
|
||||||
wifi_fast_connect: "false"
|
|
||||||
|
|
||||||
# Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
|
|
||||||
dns_domain: ".local"
|
|
||||||
|
|
||||||
# Automatically add the mac address to the name
|
|
||||||
# eg so you can use a single firmware for all devices
|
|
||||||
add_mac_suffix: "false"
|
|
||||||
|
|
||||||
# Add these if we are giving it a static ip, or remove them in the Wifi section
|
|
||||||
static_ip_subnet: !secret ha_wifi_subnet
|
|
||||||
static_ip_gateway: !secret ha_wifi_gateway
|
|
||||||
|
|
||||||
mqtt_server: !secret ha_mqtt_server
|
|
||||||
mqtt_username: !secret ha_mqtt_username
|
|
||||||
mqtt_password: !secret ha_mqtt_password
|
|
||||||
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
|
||||||
|
|
||||||
# Add these if we are using the internal web server (this is pretty processor intensive)
|
|
||||||
#web_server_username: !secret web_server_username
|
|
||||||
#web_server_password: !secret web_server_password
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Included Common Packages
|
|
||||||
# https://esphome.io/components/esphome.html
|
|
||||||
#############################################
|
|
||||||
packages:
|
|
||||||
wifi: !include common/wifi_common.yaml
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESPHome
|
|
||||||
# https://esphome.io/components/esphome.html
|
|
||||||
#############################################
|
|
||||||
esphome:
|
|
||||||
name: ${devicename}
|
|
||||||
friendly_name: ${friendly_name}
|
|
||||||
comment: ${description_comment} #Appears on the esphome page in HA
|
|
||||||
area: "${room}"
|
|
||||||
name_add_mac_suffix: "${add_mac_suffix}"
|
|
||||||
min_version: 2024.6.0
|
|
||||||
project:
|
|
||||||
name: "${project_name}"
|
|
||||||
version: "${project_version}"
|
|
||||||
platformio_options:
|
|
||||||
board_build.mcu: esp32c3
|
|
||||||
board_build.variant: esp32c3
|
|
||||||
board_build.flash_mode: dio
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESP Platform and Framework
|
|
||||||
# https://esphome.io/components/esp32.html
|
|
||||||
#############################################
|
|
||||||
#esp8266:
|
|
||||||
# board: esp01_1m # The original sonoff basic
|
|
||||||
esp32:
|
|
||||||
board: esp32-c3-devkitm-1
|
|
||||||
flash_size: 4MB
|
|
||||||
variant: ESP32C3
|
|
||||||
framework:
|
|
||||||
type: arduino
|
|
||||||
version: recommended
|
|
||||||
|
|
||||||
preferences:
|
|
||||||
flash_write_interval: 5min
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESPHome Logging Enable
|
|
||||||
# https://esphome.io/components/logger.html
|
|
||||||
#############################################
|
|
||||||
logger:
|
|
||||||
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
|
||||||
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
|
||||||
#esp8266_store_log_strings_in_flash: false
|
|
||||||
#tx_buffer_size: 64
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${api_key}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- platform: esphome
|
|
||||||
password: ${ota_pass}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Safe Mode
|
|
||||||
# Safe mode will detect boot loops
|
|
||||||
# https://esphome.io/components/safe_mode
|
|
||||||
#############################################
|
|
||||||
safe_mode:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Wifi Settings
|
|
||||||
# https://esphome.io/components/wifi.html
|
|
||||||
#
|
|
||||||
# Power Save mode (can reduce wifi reliability)
|
|
||||||
# NONE (least power saving, Default for ESP8266)
|
|
||||||
# LIGHT (Default for ESP32)
|
|
||||||
# HIGH (most power saving)
|
|
||||||
#############################################
|
|
||||||
##ifi:
|
|
||||||
# ssid: ${wifi_ssid}
|
|
||||||
# password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT # https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
# manual_ip: # optional static IP address
|
|
||||||
# static_ip: ${static_ip_address}
|
|
||||||
# gateway: ${static_ip_gateway}
|
|
||||||
# subnet: ${static_ip_subnet}
|
|
||||||
# ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
|
||||||
# ssid: ${devicename} AP
|
|
||||||
# password: ${fallback_ap_password}
|
|
||||||
# ap_timeout: 30min # Time until it brings up fallback AP. default is 1min
|
|
||||||
# # 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: # extra fallback mechanism for when connecting if the configured WiFi fails
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Real time clock time source for ESPHome
|
|
||||||
# If it's invalid, we fall back to an internal clock
|
|
||||||
# https://esphome.io/components/time/index.html
|
|
||||||
# https://esphome.io/components/time/sntp
|
|
||||||
#############################################
|
|
||||||
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");'
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: false # enable entity discovery (true is default, we don't want two HA Instances)
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Web Portal for display and monitoring
|
|
||||||
# Turning this off is maybe a good idea to save resources,
|
|
||||||
# especially on an esp8266.
|
|
||||||
# https://esphome.io/components/web_server.html
|
|
||||||
#############################################
|
|
||||||
#web_server:
|
|
||||||
# port: 80
|
|
||||||
# auth:
|
|
||||||
# username: ${web_server_username} # probably a good idea to secure it
|
|
||||||
# password: ${web_server_password}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
network:
|
|
||||||
enable_ipv6: ${ipv6_enable}
|
|
||||||
|
|
||||||
esp32_improv:
|
|
||||||
authorizer: none
|
|
||||||
|
|
||||||
dashboard_import:
|
|
||||||
package_import_url: github://athom-tech/esp32-configs/athom-smart-plug.yaml
|
|
||||||
|
|
||||||
uart:
|
|
||||||
rx_pin: GPIO20
|
|
||||||
baud_rate: 4800
|
|
||||||
data_bits: 8
|
|
||||||
stop_bits: 1
|
|
||||||
parity: EVEN
|
|
||||||
|
|
||||||
globals:
|
|
||||||
- id: total_energy
|
|
||||||
type: float
|
|
||||||
restore_value: yes
|
|
||||||
initial_value: '0.0'
|
|
||||||
|
|
||||||
# - id: restore_mode
|
|
||||||
# type: int
|
|
||||||
# restore_value: yes
|
|
||||||
# initial_value: "2" # 0 = Always_Off. 1 = Restore_Power_Off. 2 = Always_On.
|
|
||||||
|
|
||||||
binary_sensor:
|
|
||||||
- platform: status
|
|
||||||
name: "Status"
|
|
||||||
icon: mdi:check-network-outline
|
|
||||||
entity_category: diagnostic
|
|
||||||
|
|
||||||
- platform: gpio
|
|
||||||
pin:
|
|
||||||
number: GPIO3
|
|
||||||
mode: INPUT_PULLUP
|
|
||||||
inverted: true
|
|
||||||
name: "Power Button"
|
|
||||||
id: power_button
|
|
||||||
disabled_by_default: true
|
|
||||||
on_multi_click:
|
|
||||||
- timing:
|
|
||||||
- ON for at most 10s
|
|
||||||
- OFF for at least 2s
|
|
||||||
then:
|
|
||||||
- switch.toggle: relay
|
|
||||||
# - timing:
|
|
||||||
# - ON for at least 4s
|
|
||||||
# then:
|
|
||||||
# - button.press: Reset
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Relay Status"
|
|
||||||
lambda: |-
|
|
||||||
return id(relay).state;
|
|
||||||
|
|
||||||
sensor:
|
|
||||||
- platform: uptime
|
|
||||||
name: "Uptime Sensor"
|
|
||||||
id: uptime_sensor
|
|
||||||
entity_category: diagnostic
|
|
||||||
internal: true
|
|
||||||
|
|
||||||
- platform: wifi_signal
|
|
||||||
name: "WiFi Signal dB"
|
|
||||||
id: wifi_signal_db
|
|
||||||
update_interval: 60s
|
|
||||||
entity_category: "diagnostic"
|
|
||||||
|
|
||||||
- platform: copy
|
|
||||||
source_id: wifi_signal_db
|
|
||||||
name: "WiFi Signal Percent"
|
|
||||||
filters:
|
|
||||||
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
|
||||||
unit_of_measurement: "Signal %"
|
|
||||||
entity_category: "diagnostic"
|
|
||||||
device_class: ""
|
|
||||||
|
|
||||||
- platform: cse7766
|
|
||||||
id: athom_cse7766
|
|
||||||
current:
|
|
||||||
name: "Current"
|
|
||||||
icon: mdi:current-ac
|
|
||||||
filters:
|
|
||||||
- throttle_average: ${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"
|
|
||||||
icon: mdi:sine-wave
|
|
||||||
filters:
|
|
||||||
- throttle_average: ${update_interval}
|
|
||||||
|
|
||||||
power:
|
|
||||||
name: "Power"
|
|
||||||
id: power_sensor
|
|
||||||
icon: mdi:power
|
|
||||||
filters:
|
|
||||||
- throttle_average: ${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
|
|
||||||
|
|
||||||
energy:
|
|
||||||
name: "Energy"
|
|
||||||
id: energy
|
|
||||||
icon: mdi:lightning-bolt
|
|
||||||
unit_of_measurement: kWh
|
|
||||||
filters:
|
|
||||||
- throttle: ${update_interval}
|
|
||||||
# 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();
|
|
||||||
|
|
||||||
apparent_power:
|
|
||||||
name: "Apparent Power"
|
|
||||||
icon: mdi:power
|
|
||||||
filters:
|
|
||||||
- throttle_average: ${update_interval}
|
|
||||||
|
|
||||||
reactive_power:
|
|
||||||
name: "Reactive Power"
|
|
||||||
icon: mdi:flash
|
|
||||||
filters:
|
|
||||||
- throttle_average: ${update_interval}
|
|
||||||
|
|
||||||
power_factor:
|
|
||||||
name: "Power Factor"
|
|
||||||
icon: mdi:percent-outline
|
|
||||||
filters:
|
|
||||||
- throttle_average: ${update_interval}
|
|
||||||
|
|
||||||
- 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: ${update_interval}
|
|
||||||
|
|
||||||
- platform: total_daily_energy
|
|
||||||
name: "Total Daily Energy"
|
|
||||||
restore: true
|
|
||||||
power_id: power_sensor
|
|
||||||
unit_of_measurement: kWh
|
|
||||||
icon: mdi:hours-24
|
|
||||||
accuracy_decimals: 3
|
|
||||||
filters:
|
|
||||||
- multiply: 0.001
|
|
||||||
|
|
||||||
button:
|
|
||||||
# - platform: restart
|
|
||||||
# name: "Restart"
|
|
||||||
# entity_category: config
|
|
||||||
|
|
||||||
# - platform: factory_reset
|
|
||||||
# name: "Factory Reset"
|
|
||||||
# id: Reset
|
|
||||||
# entity_category: config
|
|
||||||
|
|
||||||
# - platform: safe_mode
|
|
||||||
# name: "Safe Mode"
|
|
||||||
# internal: false
|
|
||||||
# entity_category: config
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Turn Off Relay Temporarily"
|
|
||||||
on_press:
|
|
||||||
then:
|
|
||||||
- switch.turn_off: relay
|
|
||||||
- delay: 5s
|
|
||||||
- switch.turn_on: relay
|
|
||||||
|
|
||||||
switch:
|
|
||||||
- platform: gpio
|
|
||||||
name: "Switch"
|
|
||||||
pin: GPIO5
|
|
||||||
id: relay
|
|
||||||
restore_mode: ALWAYS_ON # Ensures the relay is on at boot
|
|
||||||
internal: true # Hides the switch from Home Assistant
|
|
||||||
#icon: mdi:${power_plug_type} # Don't need an icon if we can't see it...
|
|
||||||
|
|
||||||
light:
|
|
||||||
- platform: status_led
|
|
||||||
name: "Status LED"
|
|
||||||
id: blue_led
|
|
||||||
icon: mdi:lightbulb-outline
|
|
||||||
disabled_by_default: false
|
|
||||||
pin:
|
|
||||||
inverted: true
|
|
||||||
number: GPIO6
|
|
||||||
|
|
||||||
text_sensor:
|
|
||||||
- platform: wifi_info
|
|
||||||
ip_address:
|
|
||||||
name: "IP Address"
|
|
||||||
icon: mdi:ip-network
|
|
||||||
entity_category: diagnostic
|
|
||||||
ssid:
|
|
||||||
name: "Connected SSID"
|
|
||||||
icon: mdi:wifi-strength-2
|
|
||||||
entity_category: diagnostic
|
|
||||||
mac_address:
|
|
||||||
name: "Mac Address"
|
|
||||||
icon: mdi:network-pos
|
|
||||||
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
|
|
||||||
|
|
@@ -1,32 +1,31 @@
|
|||||||
#############################################
|
#############################################
|
||||||
#############################################
|
#############################################
|
||||||
# DOWNSTAIRS BATHROOM MAIN LIGHTSWITCH
|
# DOWNSTAIRS BATHROOM MAIN LIGHTSWITCH
|
||||||
# Zemismart KS-811 Triple push button
|
|
||||||
#
|
|
||||||
# V1.0 2025-02-14 Initial Version
|
# V1.0 2025-02-14 Initial Version
|
||||||
#
|
#############################################
|
||||||
|
# Zemismart KS-811 Triple push button
|
||||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||||
#
|
#
|
||||||
# INSTRUCTIONS
|
# NOTES
|
||||||
# -
|
# -
|
||||||
#
|
#
|
||||||
#############################################
|
#############################################
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
substitutions:
|
|
||||||
#############################################
|
#############################################
|
||||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
#############################################
|
#############################################
|
||||||
|
substitutions:
|
||||||
devicename: "esp-downstbathswitch"
|
devicename: "esp-downstbathswitch"
|
||||||
friendly_name: "Downstairs Bath Lightswitch"
|
friendly_name: "Downstairs Bath Lightswitch (3)"
|
||||||
description_comment: "Downstairs Bathroom Main Lightswitch using a Zemismart KS-811 Triple Push Button. Main Light (1), Cabinet Light (2), Extract Fan (3)"
|
description_comment: "Downstairs Bathroom Main Lightswitch using a Zemismart KS-811 Triple Push Button. Main Light (1), Cabinet Light (2), Extract Fan (3)"
|
||||||
|
|
||||||
api_key: !secret esp-downstbathswitch_api_key # unfortunately you can't use substitutions inside secrets names
|
api_key: !secret esp-downstbathswitch_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-downstbathswitch_ota_pass # unfortunately you can't use substitutions inside secrets names
|
ota_pass: !secret esp-downstbathswitch_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
static_ip_address: !secret esp-downstbathswitch_ip
|
static_ip_address: !secret esp-downstbathswitch_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
update_interval: 60s # update time for for general sensors etc
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Downstairs Bathroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Included Common Packages
|
# Included Common Packages
|
||||||
@@ -37,17 +36,23 @@ packages:
|
|||||||
file: common/network_common.yaml
|
file: common/network_common.yaml
|
||||||
vars:
|
vars:
|
||||||
local_static_ip_address: ${static_ip_address}
|
local_static_ip_address: ${static_ip_address}
|
||||||
local_api_key: ${api_key}
|
|
||||||
local_ota_pass: ${ota_pass}
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
common_mqtt: !include
|
common_mqtt: !include
|
||||||
file: common/mqtt_common.yaml
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
common_general_sensors: !include
|
common_general_sensors: !include
|
||||||
file: common/sensors_common.yaml
|
file: common/sensors_common.yaml
|
||||||
vars:
|
vars:
|
||||||
local_friendly_name: ${friendly_name}
|
local_friendly_name: ${friendly_name}
|
||||||
local_update_interval: ${update_interval}
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
|
||||||
# common_multiclick_pushbutton_Switch_2: !include
|
# common_multiclick_pushbutton_Switch_2: !include
|
||||||
# file: common/multiclick_pushbutton_common.yaml
|
# file: common/multiclick_pushbutton_common.yaml
|
||||||
# vars:
|
# vars:
|
||||||
@@ -86,23 +91,11 @@ esp8266:
|
|||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: INFO #INFO Level suggested, or DEBUG for testing
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Real time clock time source for ESPHome
|
|
||||||
# If it's invalid, we fall back to an internal clock
|
|
||||||
# https://esphome.io/components/time/
|
|
||||||
# https://esphome.io/components/time/sntp
|
|
||||||
#############################################
|
|
||||||
time:
|
|
||||||
- platform: sntp
|
|
||||||
id: sntp_time
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# STATUS LED
|
# STATUS LED
|
||||||
# https://esphome.io/components/status_led.html
|
# https://esphome.io/components/status_led.html
|
||||||
@@ -112,7 +105,6 @@ status_led:
|
|||||||
number: GPIO2
|
number: GPIO2
|
||||||
inverted: yes
|
inverted: yes
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# BINARY SENSORS
|
# BINARY SENSORS
|
||||||
# https://esphome.io/components/binary_sensor/
|
# https://esphome.io/components/binary_sensor/
|
||||||
@@ -123,7 +115,7 @@ binary_sensor:
|
|||||||
number: GPIO16
|
number: GPIO16
|
||||||
mode: INPUT
|
mode: INPUT
|
||||||
inverted: True
|
inverted: True
|
||||||
name: "Button: Light Switch 1 (Main)"
|
name: "Button 1: Light Switch 1 (Main)"
|
||||||
on_press:
|
on_press:
|
||||||
- switch.toggle: Relay_1
|
- switch.toggle: Relay_1
|
||||||
|
|
||||||
@@ -132,7 +124,7 @@ binary_sensor:
|
|||||||
number: GPIO05
|
number: GPIO05
|
||||||
mode: INPUT
|
mode: INPUT
|
||||||
inverted: True
|
inverted: True
|
||||||
name: "Button: Light Switch 2 (Cabinet)"
|
name: "Button 2: Light Switch 2 (Cabinet)"
|
||||||
on_press:
|
on_press:
|
||||||
- switch.toggle: Relay_2
|
- switch.toggle: Relay_2
|
||||||
|
|
||||||
@@ -141,7 +133,7 @@ binary_sensor:
|
|||||||
number: GPIO4
|
number: GPIO4
|
||||||
mode: INPUT
|
mode: INPUT
|
||||||
inverted: True
|
inverted: True
|
||||||
name: "Button: Light Switch 3 (Fan)"
|
name: "Button 3: Light Switch 3 (Fan)"
|
||||||
on_multi_click:
|
on_multi_click:
|
||||||
# Single click: 1 press → relay on for 5 minutes
|
# Single click: 1 press → relay on for 5 minutes
|
||||||
- timing:
|
- timing:
|
||||||
@@ -206,40 +198,21 @@ binary_sensor:
|
|||||||
else:
|
else:
|
||||||
- switch.turn_on: Relay_3
|
- switch.turn_on: Relay_3
|
||||||
|
|
||||||
# - platform: gpio
|
|
||||||
# pin:
|
|
||||||
# number: GPIO04
|
|
||||||
# mode: INPUT
|
|
||||||
# inverted: True
|
|
||||||
# name: "Button: Light Switch 3 (Fan)"
|
|
||||||
# on_press:
|
|
||||||
# - switch.toggle: Relay_3
|
|
||||||
|
|
||||||
# - platform: gpio
|
|
||||||
# pin:
|
|
||||||
# number: GPIO05
|
|
||||||
# mode: INPUT
|
|
||||||
# inverted: True
|
|
||||||
# name: "Button: Light Switch 2 (Cabinet)"
|
|
||||||
# on_press:
|
|
||||||
# - switch.toggle: Relay_2
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# SWITCH COMPONENT
|
# SWITCH COMPONENT
|
||||||
# https://esphome.io/components/switch/
|
# https://esphome.io/components/switch/
|
||||||
#############################################
|
#############################################
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "Relay: Main Light"
|
name: "Relay 1: Main Light"
|
||||||
pin: GPIO13
|
pin: GPIO13
|
||||||
id: Relay_1
|
id: Relay_1
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "Relay: Cabinet Light"
|
name: "Relay 2: Cabinet Light"
|
||||||
pin: GPIO12
|
pin: GPIO12
|
||||||
id: Relay_2
|
id: Relay_2
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "Relay: Extract Fan"
|
name: "Relay 3: Extract Fan"
|
||||||
pin: GPIO14
|
pin: GPIO14
|
||||||
id: Relay_3
|
id: Relay_3
|
||||||
|
|
||||||
|
@@ -1,215 +0,0 @@
|
|||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
# DOWNSTAIRS BATHROOM MAIN LIGHTSWITCH
|
|
||||||
# Zemismart KS-811 Triple push button
|
|
||||||
#
|
|
||||||
# V1.0 2025-02-14 Initial Version
|
|
||||||
#
|
|
||||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
|
||||||
#
|
|
||||||
# INSTRUCTIONS
|
|
||||||
# -
|
|
||||||
#
|
|
||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
|
|
||||||
substitutions:
|
|
||||||
#############################################
|
|
||||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
|
||||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
#############################################
|
|
||||||
devicename: "esp-downstbathswitch"
|
|
||||||
friendly_name: "Downstairs Bath Lightswitch"
|
|
||||||
description_comment: "Downstairs Bathroom Main Lightswitch using a Zemismart KS-811 Triple Push Button. Main Light (1), Cabinet Light (2), Extract Fan (3)"
|
|
||||||
|
|
||||||
api_key: !secret esp-downstbathswitch_api_key # unfortunately you can't use substitutions inside secrets names
|
|
||||||
ota_pass: !secret esp-downstbathswitch_ota_pass # unfortunately you can't use substitutions inside secrets names
|
|
||||||
static_ip_address: !secret esp-downstbathswitch_ip
|
|
||||||
|
|
||||||
update_interval: 60s # update time for for general sensors etc
|
|
||||||
hold_threshold: "4000ms" # Hold threshold as a compile-time constant
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Included Common Packages
|
|
||||||
# https://esphome.io/components/esphome.html
|
|
||||||
#############################################
|
|
||||||
packages:
|
|
||||||
common_wifi: !include
|
|
||||||
file: common/network_common.yaml
|
|
||||||
vars:
|
|
||||||
local_static_ip_address: ${static_ip_address}
|
|
||||||
local_api_key: ${api_key}
|
|
||||||
local_ota_pass: ${ota_pass}
|
|
||||||
common_mqtt: !include
|
|
||||||
file: common/mqtt_common.yaml
|
|
||||||
common_general_sensors: !include
|
|
||||||
file: common/sensors_common.yaml
|
|
||||||
vars:
|
|
||||||
local_friendly_name: ${friendly_name}
|
|
||||||
local_update_interval: ${update_interval}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESPHome
|
|
||||||
# https://esphome.io/components/esphome.html
|
|
||||||
#############################################
|
|
||||||
esphome:
|
|
||||||
name: ${devicename}
|
|
||||||
friendly_name: ${friendly_name}
|
|
||||||
comment: ${description_comment} #Appears on the esphome page in HA
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESP Platform and Framework
|
|
||||||
# https://esphome.io/components/esp32.html
|
|
||||||
#############################################
|
|
||||||
esp8266:
|
|
||||||
board: esp01_1m
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESPHome Logging Enable
|
|
||||||
# https://esphome.io/components/logger.html
|
|
||||||
#############################################
|
|
||||||
logger:
|
|
||||||
level: INFO #INFO Level suggested, or DEBUG for testing
|
|
||||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
|
||||||
#esp8266_store_log_strings_in_flash: false
|
|
||||||
#tx_buffer_size: 64
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Real time clock time source for ESPHome
|
|
||||||
# If it's invalid, we fall back to an internal clock
|
|
||||||
# https://esphome.io/components/time/
|
|
||||||
# https://esphome.io/components/time/sntp
|
|
||||||
#############################################
|
|
||||||
time:
|
|
||||||
- platform: sntp
|
|
||||||
id: sntp_time
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# STATUS LED
|
|
||||||
# https://esphome.io/components/status_led.html
|
|
||||||
#############################################
|
|
||||||
status_led:
|
|
||||||
pin:
|
|
||||||
number: GPIO2
|
|
||||||
inverted: yes
|
|
||||||
|
|
||||||
globals:
|
|
||||||
- id: single_click_delay
|
|
||||||
type: long
|
|
||||||
restore_value: no
|
|
||||||
initial_value: '300000' # 5 minutes in ms
|
|
||||||
- id: double_click_delay
|
|
||||||
type: long
|
|
||||||
restore_value: no
|
|
||||||
initial_value: '1800000' # 30 minutes in ms
|
|
||||||
- id: triple_click_delay
|
|
||||||
type: long
|
|
||||||
restore_value: no
|
|
||||||
initial_value: '7200000' # 2 hours in ms
|
|
||||||
- id: hold_threshold_val
|
|
||||||
type: long
|
|
||||||
restore_value: no
|
|
||||||
initial_value: '4000' # 4 seconds in ms
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# BINARY SENSORS
|
|
||||||
# https://esphome.io/components/binary_sensor/
|
|
||||||
#############################################
|
|
||||||
binary_sensor:
|
|
||||||
- platform: gpio
|
|
||||||
pin:
|
|
||||||
number: GPIO16
|
|
||||||
mode: INPUT
|
|
||||||
inverted: True
|
|
||||||
name: "Button: Light Switch 1 (Main)"
|
|
||||||
on_press:
|
|
||||||
- switch.toggle: Relay_1
|
|
||||||
|
|
||||||
- platform: gpio
|
|
||||||
pin:
|
|
||||||
number: GPIO05
|
|
||||||
mode: INPUT
|
|
||||||
inverted: True
|
|
||||||
name: "Button: Light Switch 2 (Cabinet)"
|
|
||||||
on_press:
|
|
||||||
- switch.toggle: Relay_2
|
|
||||||
|
|
||||||
- platform: gpio
|
|
||||||
pin:
|
|
||||||
number: GPIO04
|
|
||||||
mode: INPUT
|
|
||||||
inverted: True
|
|
||||||
name: "Button: Extract Fan"
|
|
||||||
on_multi_click:
|
|
||||||
# Single Click: one press (short press/release)
|
|
||||||
- timing:
|
|
||||||
- ON for at most 1s
|
|
||||||
- OFF for at least 0.5s
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
if (id(Relay_3).state) {
|
|
||||||
ESP_LOGD("button3", "Single click: Relay_3 is on, turning it off.");
|
|
||||||
id(Relay_3).turn_off();
|
|
||||||
} else {
|
|
||||||
ESP_LOGD("button3", "Single click: Relay_3 is off, turning it on for %d ms.", id(single_click_delay));
|
|
||||||
id(Relay_3).turn_on();
|
|
||||||
delay(id(single_click_delay));
|
|
||||||
id(Relay_3).turn_off();
|
|
||||||
}
|
|
||||||
# Double Click: two quick press/release cycles
|
|
||||||
- timing:
|
|
||||||
- ON for at most 1s
|
|
||||||
- OFF for at most 1s
|
|
||||||
- ON for at most 1s
|
|
||||||
- OFF for at least 0.5s
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
ESP_LOGD("button3", "Double click detected: turning Relay_3 on for %d ms.", id(double_click_delay));
|
|
||||||
id(Relay_3).turn_on();
|
|
||||||
delay(id(double_click_delay));
|
|
||||||
id(Relay_3).turn_off();
|
|
||||||
# Triple Click: three quick press/release cycles
|
|
||||||
- timing:
|
|
||||||
- ON for at most 1s
|
|
||||||
- OFF for at most 1s
|
|
||||||
- ON for at most 1s
|
|
||||||
- OFF for at most 1s
|
|
||||||
- ON for at most 1s
|
|
||||||
- OFF for at least 0.5s
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
ESP_LOGD("button3", "Triple click detected: turning Relay_3 on for %d ms.", id(triple_click_delay));
|
|
||||||
id(Relay_3).turn_on();
|
|
||||||
delay(id(triple_click_delay));
|
|
||||||
id(Relay_3).turn_off();
|
|
||||||
# Hold: button held for at least 4 seconds
|
|
||||||
- timing:
|
|
||||||
- ON for at least 4s
|
|
||||||
then:
|
|
||||||
- lambda: |-
|
|
||||||
ESP_LOGD("button3", "Hold detected (threshold %d ms): turning Relay_3 on indefinitely.", id(hold_threshold_val));
|
|
||||||
id(Relay_3).turn_on();
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# SWITCH COMPONENT
|
|
||||||
# https://esphome.io/components/switch/
|
|
||||||
#############################################
|
|
||||||
switch:
|
|
||||||
- platform: gpio
|
|
||||||
name: "Relay: Main Light"
|
|
||||||
pin: GPIO13
|
|
||||||
id: Relay_1
|
|
||||||
- platform: gpio
|
|
||||||
name: "Relay: Cabinet Light"
|
|
||||||
pin: GPIO12
|
|
||||||
id: Relay_2
|
|
||||||
- platform: gpio
|
|
||||||
name: "Relay: Extract Fan"
|
|
||||||
pin: GPIO14
|
|
||||||
id: Relay_3
|
|
||||||
|
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
#############################################
|
#############################################
|
||||||
#############################################
|
#############################################
|
||||||
# MASTER BATHROOM HEATED TOWEL RAIL
|
# DOWNSTAIRS BATHROOM HEATED TOWEL RAIL
|
||||||
# Controlled by a Sonoff Basic
|
# Controlled by a Sonoff Basic
|
||||||
#
|
#
|
||||||
# V1.1 2025-04-12 Fixes to timers and offline modes
|
# V1.1 2025-04-12 Fixes to timers and offline modes
|
||||||
@@ -35,38 +35,26 @@
|
|||||||
#############################################
|
#############################################
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
|
devicename: "esp-downstbathtowelrail"
|
||||||
#############################################
|
friendly_name: "Downstairs Bathroom Towelrail"
|
||||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
description_comment: "Sonoff Basic controlling ON/OFF/Timer for the Heated Towel Rail in the Downstairs Bathroom"
|
||||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
api_key: !secret esp-downstbathtowelrail_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
#############################################
|
ota_pass: !secret esp-downstbathtowelrail_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-downstbathtowelrail_ip
|
||||||
mqtt_timer_topic: "viewroad-commands/masterbath-towelrail" # Topics you will use to change stuff
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
startup_duration: "10" # Minutes to stay ON in STARTUP mode before reverting to TIMER
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Downstairs Bathroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
devicename: "esp-masterbathtowelrail"
|
|
||||||
friendly_name: "Master Bathroom Towelrail"
|
|
||||||
description_comment: "Sonoff Basic controlling ON/OFF/Timer for the Heated Towel Rail in the Master Bathroom"
|
|
||||||
|
|
||||||
api_key: !secret esp-masterbathtowelrail_api_key # unfortunately you can't use substitutions inside secrets names
|
|
||||||
ota_pass: !secret esp-masterbathtowelrail_ota_pass # unfortunately you can't use substitutions inside secrets names
|
|
||||||
static_ip_address: !secret esp-masterbathtowelrail_ip
|
|
||||||
|
|
||||||
update_interval: "300s" # Update time for for general sensors etc.
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# SYSTEM SPECIFIC VARIABLE SUBSTITUTIONS
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
#############################################
|
#############################################
|
||||||
|
mqtt_timer_topic: "viewroad-commands/downstbath-towelrail" # Topics you will use to change stuff
|
||||||
timezone: "Pacific/Auckland"
|
startup_duration: "120" # Minutes to stay ON in STARTUP mode before reverting to TIMER
|
||||||
sntp_update_interval: 6h # Set the duration between the sntp service polling
|
|
||||||
# Network time servers https://www.ntppool.org/zone/@
|
|
||||||
# Make sure you have some DNS, or use IP addresses only here.
|
|
||||||
sntp_server_1: !secret ntp_server_1
|
|
||||||
sntp_server_2: !secret ntp_server_2
|
|
||||||
sntp_server_3: !secret ntp_server_3
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Included Common Packages
|
# Included Common Packages
|
||||||
@@ -77,10 +65,17 @@ packages:
|
|||||||
file: common/network_common.yaml
|
file: common/network_common.yaml
|
||||||
vars:
|
vars:
|
||||||
local_static_ip_address: ${static_ip_address}
|
local_static_ip_address: ${static_ip_address}
|
||||||
local_api_key: ${api_key}
|
|
||||||
local_ota_pass: ${ota_pass}
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
common_mqtt: !include
|
common_mqtt: !include
|
||||||
file: common/mqtt_common.yaml
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
common_general_sensors: !include
|
common_general_sensors: !include
|
||||||
file: common/sensors_common.yaml
|
file: common/sensors_common.yaml
|
||||||
vars:
|
vars:
|
||||||
@@ -95,12 +90,13 @@ esphome:
|
|||||||
name: ${devicename}
|
name: ${devicename}
|
||||||
friendly_name: ${friendly_name}
|
friendly_name: ${friendly_name}
|
||||||
comment: ${description_comment} # Appears on the esphome page in HA
|
comment: ${description_comment} # Appears on the esphome page in HA
|
||||||
|
area: "${room}"
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 900 # High priority to run after globals are initialized
|
priority: 900 # High priority to run after globals are initialized
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
// 1) Figure out the current time in "seconds from midnight"
|
// 1) Figure out the current time in "seconds from midnight"
|
||||||
// using SNTP if available, otherwise fallback_time * 60.
|
// using SNTP if available, otherwise current_mins * 60.
|
||||||
bool have_sntp = id(sntp_time).now().is_valid();
|
bool have_sntp = id(sntp_time).now().is_valid();
|
||||||
int current_time_s = 0;
|
int current_time_s = 0;
|
||||||
|
|
||||||
@@ -108,8 +104,8 @@ esphome:
|
|||||||
auto now = id(sntp_time).now();
|
auto now = id(sntp_time).now();
|
||||||
current_time_s = now.hour * 3600 + now.minute * 60 + now.second;
|
current_time_s = now.hour * 3600 + now.minute * 60 + now.second;
|
||||||
} else {
|
} else {
|
||||||
// fallback_time is in minutes; convert to seconds
|
// current_mins is in minutes; convert to seconds
|
||||||
current_time_s = id(fallback_time) * 60;
|
current_time_s = id(current_mins) * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Compare with the last boot time
|
// 2) Compare with the last boot time
|
||||||
@@ -148,45 +144,11 @@ esp8266:
|
|||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: DEBUG #INFO Level suggested, or DEBUG for testing
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Real time clock time source for ESPHome
|
|
||||||
# If it's invalid, we fall back to an internal clock
|
|
||||||
# https://esphome.io/components/time/index.html
|
|
||||||
# https://esphome.io/components/time/sntp
|
|
||||||
#############################################
|
|
||||||
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:
|
|
||||||
- logger.log: "Synchronised sntp clock"
|
|
||||||
- text_sensor.template.publish:
|
|
||||||
id: time_sync
|
|
||||||
state: "SNTP clock Syncd"
|
|
||||||
# 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");'
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Global Variables for use in automations etc
|
# Global Variables for use in automations etc
|
||||||
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
|
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
|
||||||
@@ -206,18 +168,18 @@ globals:
|
|||||||
initial_value: "0"
|
initial_value: "0"
|
||||||
|
|
||||||
# Morning On time (minutes from midnight),
|
# Morning On time (minutes from midnight),
|
||||||
# default 05:00 => 300
|
# default 07:00 => 420
|
||||||
- id: morning_on
|
- id: morning_on
|
||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "300"
|
initial_value: "420"
|
||||||
|
|
||||||
# Morning Off time (minutes from midnight),
|
# Morning Off time (minutes from midnight),
|
||||||
# default 07:00 => 420
|
# default 07:30 => 450
|
||||||
- id: morning_off
|
- id: morning_off
|
||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "420"
|
initial_value: "450"
|
||||||
|
|
||||||
# Evening On time (minutes from midnight),
|
# Evening On time (minutes from midnight),
|
||||||
# default 21:00 => 1260
|
# default 21:00 => 1260
|
||||||
@@ -227,11 +189,11 @@ globals:
|
|||||||
initial_value: "1260"
|
initial_value: "1260"
|
||||||
|
|
||||||
# Evening Off time (minutes from midnight),
|
# Evening Off time (minutes from midnight),
|
||||||
# default 00:00 => 0 => treat as midnight
|
# default 22:00 => 1320 => treat as midnight
|
||||||
- id: evening_off
|
- id: evening_off
|
||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "0"
|
initial_value: "1320"
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# operation_mode:
|
# operation_mode:
|
||||||
@@ -246,20 +208,15 @@ globals:
|
|||||||
initial_value: "3"
|
initial_value: "3"
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# fallback_time is used if SNTP is invalid.
|
# current_mins is set if SNTP is invalid.
|
||||||
# We assume user powers on the device at 12:00 noon
|
# We assume user powers on the device at 12:00 noon
|
||||||
# => 12 * 60 = 720 minutes from midnight.
|
# => 12 * 60 = 720 minutes from midnight.
|
||||||
# Not restored, so it resets each boot.
|
# Not restored, so it resets each boot.
|
||||||
####################################################
|
####################################################
|
||||||
- id: fallback_time
|
|
||||||
type: int
|
|
||||||
restore_value: false
|
|
||||||
initial_value: "720"
|
|
||||||
|
|
||||||
- id: current_mins
|
- id: current_mins
|
||||||
type: int
|
type: int
|
||||||
restore_value: false
|
restore_value: false
|
||||||
initial_value: '0'
|
initial_value: "720" # 720 is 12:00 Noon
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# startup_timer: counts minutes in STARTUP mode
|
# startup_timer: counts minutes in STARTUP mode
|
||||||
@@ -271,14 +228,6 @@ globals:
|
|||||||
restore_value: false
|
restore_value: false
|
||||||
initial_value: "0"
|
initial_value: "0"
|
||||||
|
|
||||||
|
|
||||||
# Time period string for converting to seconds
|
|
||||||
#- id: update_interval_string
|
|
||||||
# type: std::string
|
|
||||||
# restore_value: false
|
|
||||||
# max_restore_data_length: 12
|
|
||||||
# initial_value: ${update_interval}
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Text Sensors
|
# Text Sensors
|
||||||
# https://esphome.io/components/text_sensor/index.html
|
# https://esphome.io/components/text_sensor/index.html
|
||||||
@@ -404,7 +353,6 @@ text_sensor:
|
|||||||
ESP_LOGW("timer","Invalid operation mode: %s", x.c_str());
|
ESP_LOGW("timer","Invalid operation mode: %s", x.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################################
|
######################################################
|
||||||
# Expose the current operation mode (OFF, ON, TIMER, STARTUP)
|
# Expose the current operation mode (OFF, ON, TIMER, STARTUP)
|
||||||
######################################################
|
######################################################
|
||||||
@@ -421,8 +369,6 @@ text_sensor:
|
|||||||
}
|
}
|
||||||
update_interval: ${update_interval}
|
update_interval: ${update_interval}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
######################################################
|
######################################################
|
||||||
# Expose the "Morning On" time as a text (HH:MM)
|
# Expose the "Morning On" time as a text (HH:MM)
|
||||||
######################################################
|
######################################################
|
||||||
@@ -482,43 +428,20 @@ text_sensor:
|
|||||||
return { std::string(buff) };
|
return { std::string(buff) };
|
||||||
update_interval: ${update_interval}
|
update_interval: ${update_interval}
|
||||||
|
|
||||||
######################################################
|
#############################################
|
||||||
# Creates a sensor showing when the device was last restarted
|
# Sensors
|
||||||
# Uptime template sensor, and SNTP are needed
|
# https://esphome.io/components/text_sensor/index.html
|
||||||
######################################################
|
#############################################
|
||||||
- platform: template
|
|
||||||
name: "Last Restart: ${friendly_name}"
|
|
||||||
id: device_last_restart
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
icon: mdi:clock
|
|
||||||
entity_category: diagnostic
|
|
||||||
#device_class: timestamp
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Time Sync Status"
|
|
||||||
id: time_sync
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
entity_category: diagnostic
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Internal Time"
|
|
||||||
id: time_text
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
entity_category: diagnostic
|
|
||||||
lambda: |-
|
|
||||||
auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
|
||||||
return { time_text };
|
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Mins from Midnight"
|
name: "Mins from Midnight"
|
||||||
#unit_of_measurement: "s"
|
unit_of_measurement: "mins"
|
||||||
#accuracy_decimals: 0
|
accuracy_decimals: 0
|
||||||
update_interval: 1s
|
update_interval: ${update_interval}
|
||||||
|
internal: True
|
||||||
lambda: |-
|
lambda: |-
|
||||||
return id(current_mins);
|
return id(current_mins);
|
||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# Relay Switch (Sonoff Basic Relay on GPIO12)
|
# Relay Switch (Sonoff Basic Relay on GPIO12)
|
||||||
####################################################
|
####################################################
|
||||||
@@ -533,9 +456,27 @@ switch:
|
|||||||
# Check every minute to decide relay state
|
# Check every minute to decide relay state
|
||||||
####################################################
|
####################################################
|
||||||
interval:
|
interval:
|
||||||
- interval: "1min"
|
- interval: "1min" # Must be 1min as this is used to calculate times
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
|
|
||||||
|
// Do we have correct time from SNTP? If not...
|
||||||
|
if (!id(time_sync).has_state()) {
|
||||||
|
// Set minutes since midnight
|
||||||
|
id(current_mins) = id(current_mins) +1 ;
|
||||||
|
|
||||||
|
// wrap around at 1440 => next day
|
||||||
|
if (id(current_mins) >= 1440) {
|
||||||
|
id(current_mins) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we do have proper SNMP time...
|
||||||
|
} else {
|
||||||
|
// Use real time from SNTP
|
||||||
|
auto now = id(sntp_time).now();
|
||||||
|
id(current_mins) = now.hour * 60 + now.minute;
|
||||||
|
}
|
||||||
|
|
||||||
// operation_mode:
|
// operation_mode:
|
||||||
// 0 = OFF
|
// 0 = OFF
|
||||||
// 1 = ON
|
// 1 = ON
|
||||||
@@ -548,7 +489,7 @@ interval:
|
|||||||
// minutes, then automatically revert to TIMER.
|
// minutes, then automatically revert to TIMER.
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
if (mode == 3) {
|
if (mode == 3) {
|
||||||
id(startup_timer) = id(startup_timer) ++ ; // works as long as update_interval in seconds
|
id(startup_timer) = id(startup_timer) + 1 ; // works as long as update_interval in seconds
|
||||||
// Compare with the substitution startup_duration
|
// Compare with the substitution startup_duration
|
||||||
if (id(startup_timer) < (int) ${startup_duration}) {
|
if (id(startup_timer) < (int) ${startup_duration}) {
|
||||||
// Still within the STARTUP period => turn relay on
|
// Still within the STARTUP period => turn relay on
|
||||||
@@ -559,6 +500,7 @@ interval:
|
|||||||
id(mqtt_client).publish("${mqtt_timer_topic}/operation", "TIMER");
|
id(mqtt_client).publish("${mqtt_timer_topic}/operation", "TIMER");
|
||||||
}
|
}
|
||||||
// Skip the rest of the logic
|
// Skip the rest of the logic
|
||||||
|
ESP_LOGI("startup_timer", "startup_timer=%d", id(startup_timer));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,52 +522,26 @@ interval:
|
|||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// TIMER MODE => follow morning/evening schedule
|
// TIMER MODE => follow morning/evening schedule
|
||||||
// using SNTP if valid, else fallback_time
|
// using SNTP if valid, else current_mins
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
if (mode == 2) {
|
if (mode == 2)
|
||||||
//auto now = id(sntp_time).now();
|
{
|
||||||
//bool have_sntp = now.is_valid();
|
|
||||||
|
|
||||||
//int current_mins;
|
|
||||||
//if (!have_sntp) {
|
|
||||||
//if (!id(time_sync).has_state()) {
|
|
||||||
//if 1 == 1 {
|
|
||||||
// SNTP not available => fallback clock
|
|
||||||
current_mins = id(fallback_time);
|
|
||||||
// increment the fallback clock by 1 minute
|
|
||||||
id(fallback_time) += 1;
|
|
||||||
// wrap around at 1440 => next day
|
|
||||||
if (id(fallback_time) >= 1440) {
|
|
||||||
id(fallback_time) = 0;
|
|
||||||
//}
|
|
||||||
//} else {
|
|
||||||
// Use real time from SNTP
|
|
||||||
// current_mins = now.hour * 60 + now.minute;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool should_on = false;
|
bool should_on = false;
|
||||||
|
|
||||||
// If evening_off == 0 => treat as midnight => 1440
|
|
||||||
int evening_off_local = id(evening_off);
|
|
||||||
if (evening_off_local == 0) {
|
|
||||||
evening_off_local = 1440;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check morning window
|
// Check morning window
|
||||||
// Example: morning_on=360 => 06:00, morning_off=480 => 08:00
|
// Example: morning_on=360 => 06:00, morning_off=480 => 08:00
|
||||||
// If current_mins in [360..480), should_on = true
|
// If current_mins in [360..480), should_on = true
|
||||||
if (id(morning_on) < id(morning_off)) {
|
if (id(current_mins) >= id(morning_on) && id(current_mins) < id(morning_off) )
|
||||||
if (current_mins >= id(morning_on) && current_mins < id(morning_off)) {
|
{
|
||||||
should_on = true;
|
should_on = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check evening window
|
// Check evening window
|
||||||
// Example: evening_on=540 => 09:00, evening_off=1440 => midnight
|
// Example: evening_on=1260 => 21:00, evening_off=1440 => midnight
|
||||||
if (id(evening_on) < evening_off_local) {
|
if (id(current_mins) >= id(evening_on) && id(current_mins) < id(evening_off) )
|
||||||
if (current_mins >= id(evening_on) && current_mins < evening_off_local) {
|
{
|
||||||
should_on = true;
|
should_on = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final relay state based on schedule
|
// Final relay state based on schedule
|
||||||
@@ -637,3 +553,5 @@ interval:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
243
esphome/esp-downstdishwasher.yaml
Normal file
243
esphome/esp-downstdishwasher.yaml
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# Athom Smart Plug Power Monitor ESP32-C3
|
||||||
|
#
|
||||||
|
# based on https://github.com/athom-tech/esp32-configs/blob/main/athom-smart-plug.yaml
|
||||||
|
#
|
||||||
|
# SUMMARY
|
||||||
|
# Smart plug with power monitoring.
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
devicename: "esp-downstdishwasher"
|
||||||
|
friendly_name: "Downstairs Dishwasher Power"
|
||||||
|
description_comment: "Downstairs Dishwasher Power, Athom Smart Plug Power Monitor"
|
||||||
|
room: "Downstairs Kitchen" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
api_key: !secret esp-downstdishwasher_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-downstdishwasher_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-downstdishwasher_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
|
#############################################
|
||||||
|
project_name: "Athom Technology.Smart Plug V3" # Project Details
|
||||||
|
project_version: "v1.0.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
current_limit : "10" # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: ${devicename}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
comment: ${description_comment} #Appears on the esphome page in HA
|
||||||
|
area: "${room}"
|
||||||
|
name_add_mac_suffix: False
|
||||||
|
min_version: 2024.6.0
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
platformio_options:
|
||||||
|
board_build.mcu: esp32c3
|
||||||
|
board_build.variant: esp32c3
|
||||||
|
board_build.flash_mode: dio
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp32:
|
||||||
|
board: esp32-c3-devkitm-1
|
||||||
|
flash_size: 4MB
|
||||||
|
variant: ESP32C3
|
||||||
|
framework:
|
||||||
|
type: arduino
|
||||||
|
version: recommended
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
flash_write_interval: 5min
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
esp32_improv:
|
||||||
|
authorizer: none
|
||||||
|
|
||||||
|
dashboard_import:
|
||||||
|
package_import_url: github://athom-tech/esp32-configs/athom-smart-plug.yaml
|
||||||
|
|
||||||
|
uart:
|
||||||
|
rx_pin: GPIO20
|
||||||
|
baud_rate: 4800
|
||||||
|
data_bits: 8
|
||||||
|
stop_bits: 1
|
||||||
|
parity: EVEN
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: total_energy
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '0.0'
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO3
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
name: "Power Button"
|
||||||
|
id: power_button
|
||||||
|
filters:
|
||||||
|
- delayed_on: 20ms
|
||||||
|
on_click:
|
||||||
|
- switch.toggle: relay
|
||||||
|
- platform: template
|
||||||
|
name: "Relay Status"
|
||||||
|
lambda: |-
|
||||||
|
return id(relay).state;
|
||||||
|
|
||||||
|
status_led:
|
||||||
|
pin: GPIO06
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: "Power Output"
|
||||||
|
pin: GPIO5
|
||||||
|
id: relay
|
||||||
|
restore_mode: RESTORE_DEFAULT_OFF # Ensures the relay is restored (or off) at boot
|
||||||
|
#internal: true # Hides the switch from Home Assistant
|
||||||
|
icon: "mdi:power-socket-au"
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: cse7766
|
||||||
|
id: athom_cse7766
|
||||||
|
|
||||||
|
current:
|
||||||
|
name: "Current"
|
||||||
|
icon: mdi:current-ac
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${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"
|
||||||
|
icon: mdi:sine-wave
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
power:
|
||||||
|
name: "Power"
|
||||||
|
id: power_sensor
|
||||||
|
icon: mdi:power
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${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
|
||||||
|
|
||||||
|
energy:
|
||||||
|
name: "Energy"
|
||||||
|
id: energy
|
||||||
|
icon: mdi:lightning-bolt
|
||||||
|
unit_of_measurement: kWh
|
||||||
|
filters:
|
||||||
|
- throttle: ${update_interval}
|
||||||
|
# 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();
|
||||||
|
|
||||||
|
apparent_power:
|
||||||
|
name: "Apparent Power"
|
||||||
|
icon: mdi:power
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
reactive_power:
|
||||||
|
name: "Reactive Power"
|
||||||
|
icon: mdi:flash
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
power_factor:
|
||||||
|
name: "Power Factor"
|
||||||
|
icon: mdi:percent-outline
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
- 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: ${update_interval}
|
||||||
|
|
||||||
|
- platform: total_daily_energy
|
||||||
|
name: "Total Daily Energy"
|
||||||
|
restore: true
|
||||||
|
power_id: power_sensor
|
||||||
|
unit_of_measurement: kWh
|
||||||
|
icon: mdi:hours-24
|
||||||
|
accuracy_decimals: 3
|
||||||
|
filters:
|
||||||
|
- multiply: 0.001
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
159
esphome/esp-downstkitchlights.yaml
Normal file
159
esphome/esp-downstkitchlights.yaml
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# DOWNSTAIRS KITCHEN MAIN LIGHTSWITCH
|
||||||
|
# V1.0 2025-03-28 Initial Version
|
||||||
|
#############################################
|
||||||
|
# Zemismart KS-811 Triple push button
|
||||||
|
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||||
|
#
|
||||||
|
# NOTES
|
||||||
|
# -
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
devicename: "esp-downstkitchlights"
|
||||||
|
friendly_name: "Downstairs Kitchen Lightswitch (3)"
|
||||||
|
description_comment: "Downstairs Kitch Main Lightswitch using a Zemismart KS-811 Triple Push Button. Dining Light (1), Kitchen Light (2), Extract Fan (3)"
|
||||||
|
api_key: !secret esp-downstkitchlights_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-downstkitchlights_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-downstkitchlights_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Downstairs Kitchen" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
# common_multiclick_pushbutton_Switch_2: !include
|
||||||
|
# file: common/multiclick_pushbutton_common.yaml
|
||||||
|
# vars:
|
||||||
|
# local_name: "Button: Light Switch 2 (Cabinet)"
|
||||||
|
# local_gpio: GPIO05 # Switch 2 for KS-811 Triple is GPIO5
|
||||||
|
# local_relay_id: Relay_2 # ID of relay to turn on
|
||||||
|
# local_singleclick_duration: 7200000 # 2 hrs in ms
|
||||||
|
# common_multiclick_pushbutton_Switch_3: !include
|
||||||
|
# file: common/multiclick_pushbutton_common.yaml
|
||||||
|
# vars:
|
||||||
|
# local_name: "Button: Extract Fan"
|
||||||
|
# local_gpio: GPIO04 # Switch 3 for KS-811 Triple is GPIO4
|
||||||
|
# local_relay_id: Relay_3 # ID of relay to turn on
|
||||||
|
# local_singleclick_duration: 300000 # 5 minutes in ms
|
||||||
|
# local_doubleclick_duration: 1800000 # 30 minutes in ms
|
||||||
|
# local_tripleclick_duration: 7200000 # 2 hours in ms
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: ${devicename}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
comment: ${description_comment} #Appears on the esphome page in HA
|
||||||
|
area: ${room}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
status_led:
|
||||||
|
pin:
|
||||||
|
number: GPIO2
|
||||||
|
inverted: yes
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# BINARY SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO16
|
||||||
|
mode: INPUT
|
||||||
|
inverted: True
|
||||||
|
name: "Button 1: Light Switch 1 (Dining)"
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: Relay_1
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO05
|
||||||
|
mode: INPUT
|
||||||
|
inverted: True
|
||||||
|
name: "Button 2: Light Switch 2 (Kitchen)"
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: Relay_2
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO4
|
||||||
|
mode: INPUT
|
||||||
|
inverted: True
|
||||||
|
name: "Button 3: Switch 3 (Extract)"
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: Relay_3
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SWITCH COMPONENT
|
||||||
|
# https://esphome.io/components/switch/
|
||||||
|
#############################################
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay 1: Dining Light"
|
||||||
|
pin: GPIO13
|
||||||
|
id: Relay_1
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay 2: Kitchen Light"
|
||||||
|
pin: GPIO12
|
||||||
|
id: Relay_2
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay 3: Extract Fan"
|
||||||
|
pin: GPIO14
|
||||||
|
id: Relay_3
|
||||||
|
|
||||||
|
|
@@ -1,34 +1,56 @@
|
|||||||
#############################################
|
#############################################
|
||||||
# Variable Substitutions
|
#############################################
|
||||||
# Give the device a useful name & description here
|
# ESP32
|
||||||
# and change values accordingly.
|
# Bluetooth Proxy
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
#############################################
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
devicename: "esp-entbtproxy"
|
devicename: "esp-entbtproxy"
|
||||||
friendly_name: "Outside Entrance Bluetooth Proxy"
|
friendly_name: "Outside Entrance Bluetooth Proxy"
|
||||||
description_comment: "D1 Mini ESP32 outside entranceway with BT Proxy"
|
description_comment: "D1 Mini ESP32 outside entranceway with BT Proxy"
|
||||||
|
api_key: !secret esp-entbtproxy_api_key #unfortunately you can't use substitutions in secrets names
|
||||||
#if NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
api_key: !secret esp-entbyproxy_api_key #unfortunately you can't use substitutions in secrets names
|
|
||||||
ota_pass: !secret esp-entbtproxy_ota_pass #unfortunately you can't use substitutions in secrets names
|
ota_pass: !secret esp-entbtproxy_ota_pass #unfortunately you can't use substitutions in secrets names
|
||||||
wifi_ssid: !secret wifi_ssid
|
static_ip_address: !secret esp-entbtproxy_ip
|
||||||
wifi_password: !secret wifi_password
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
fallback_ap_password: !secret fallback_ap_password
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
#Add these if we are giving it a static ip, or remove them in the Wifi section
|
room: "Entranceway" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
#static_ip_address: !secret esp-entmulti_static_ip
|
|
||||||
#static_ip_gateway: !secret esp-entmulti_gateway
|
|
||||||
#static_ip_subnet: !secret esp-entmulti_subnet
|
|
||||||
|
|
||||||
mqtt_server: !secret mqtt_server
|
#############################################
|
||||||
mqtt_username: !secret mqtt_username
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
mqtt_password: !secret mqtt_password
|
#############################################
|
||||||
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
#
|
||||||
|
#
|
||||||
#web_server_username: !secret web_server_username
|
|
||||||
#web_server_password: !secret web_server_password
|
|
||||||
|
|
||||||
update_time: 30s #update time for for general temp sensors etc
|
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESPHome
|
# ESPHome
|
||||||
@@ -40,7 +62,6 @@ esphome:
|
|||||||
comment: ${description_comment} #appears on the esphome page in HA
|
comment: ${description_comment} #appears on the esphome page in HA
|
||||||
min_version: 2024.6.0 #
|
min_version: 2024.6.0 #
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESP Platform and Framework
|
# ESP Platform and Framework
|
||||||
# https://esphome.io/components/esp32.html
|
# https://esphome.io/components/esp32.html
|
||||||
@@ -52,94 +73,16 @@ esp32:
|
|||||||
type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang.
|
type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang.
|
||||||
version: recommended #recommended, latest or dev
|
version: recommended #recommended, latest or dev
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESPHome Logging Enable
|
# ESPHome Logging Enable
|
||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: INFO #INFO Level suggested, or DEBUG for testing
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${api_key}
|
|
||||||
# on_client_connected:
|
|
||||||
# - esp32_ble_tracker.start_scan:
|
|
||||||
# continuous: true
|
|
||||||
# on_client_disconnected:
|
|
||||||
# - esp32_ble_tracker.stop_scan:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- platform: esphome
|
|
||||||
password: ${ota_pass}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Safe Mode
|
|
||||||
# Safe mode will detect boot loops
|
|
||||||
# https://esphome.io/components/safe_mode
|
|
||||||
#############################################
|
|
||||||
safe_mode:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Wifi Settings
|
|
||||||
# https://esphome.io/components/wifi.html
|
|
||||||
#
|
|
||||||
# Power Save mode (can reduce wifi reliability)
|
|
||||||
# NONE (least power saving, Default for ESP8266)
|
|
||||||
# LIGHT (Default for ESP32)
|
|
||||||
# HIGH (most power saving)
|
|
||||||
#############################################
|
|
||||||
wifi:
|
|
||||||
ssid: ${wifi_ssid}
|
|
||||||
password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
#manual_ip: #optional static IP address
|
|
||||||
#static_ip: ${static_ip_address}
|
|
||||||
#gateway: ${static_ip_gateway}
|
|
||||||
#subnet: ${static_ip_subnet}
|
|
||||||
ap: #Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
|
||||||
ssid: $devicename fallback AP
|
|
||||||
password: !secret fallback_ap_password
|
|
||||||
ap_timeout: 5min #Time until it brings up fallback AP. default is 1min
|
|
||||||
|
|
||||||
captive_portal:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Web Portal for display and monitoring
|
|
||||||
# Turning this off is probably a good idea to save resources.
|
|
||||||
# https://esphome.io/components/web_server.html
|
|
||||||
#############################################
|
|
||||||
#web_server:
|
|
||||||
# port: 80
|
|
||||||
# auth:
|
|
||||||
# username: ${web_server_username} #probably a good idea to secure it
|
|
||||||
# password: ${web_server_password}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: false # enable entity discovery (true is default)
|
|
||||||
#discover_ip: True # enable device discovery (true is default)
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Bluetooth
|
# Bluetooth
|
||||||
# https://esphome.io/components/bluetooth_proxy.html
|
# https://esphome.io/components/bluetooth_proxy.html
|
||||||
@@ -160,32 +103,3 @@ esp32_ble_tracker:
|
|||||||
# enable the built-in coexistence logic in ESP-IDF
|
# enable the built-in coexistence logic in ESP-IDF
|
||||||
active: true
|
active: true
|
||||||
|
|
||||||
|
|
||||||
button:
|
|
||||||
- platform: safe_mode
|
|
||||||
id: button_safe_mode
|
|
||||||
name: Safe Mode Boot
|
|
||||||
|
|
||||||
- platform: factory_reset
|
|
||||||
id: factory_reset_btn
|
|
||||||
name: Factory reset
|
|
||||||
|
|
||||||
|
|
||||||
sensor:
|
|
||||||
################################
|
|
||||||
# WIFI SIGNAL
|
|
||||||
# Quality of Wifi in dBm
|
|
||||||
# https://esphome.io/components/sensor/wifi_signal.html
|
|
||||||
################################
|
|
||||||
- platform: wifi_signal
|
|
||||||
name: ${friendly_name} WiFi Signal
|
|
||||||
update_interval: 20s
|
|
||||||
#retain: true #retain useful if sleeping
|
|
||||||
|
|
||||||
- platform: uptime
|
|
||||||
name: ${friendly_name} Uptime
|
|
||||||
update_interval: 10s
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,36 +6,69 @@
|
|||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Variable Substitutions
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
# Give the device a useful name & description here
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
# and change values accordingly.
|
|
||||||
#############################################
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
devicename: "esp-entmulti"
|
devicename: "esp-entmulti"
|
||||||
friendly_name: "Outside Entrance Multisensor"
|
friendly_name: "Outside Entrance Multisensor"
|
||||||
description_comment: "D1 Mini ESP32 outside entranceway with, mmWave presence, PIR and more"
|
description_comment: "D1 Mini ESP32 outside entranceway with, mmWave presence, PIR and more"
|
||||||
|
|
||||||
#if NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
api_key: !secret esp-entmulti_api_key #unfortunately you can't use substitutions in secrets names
|
api_key: !secret esp-entmulti_api_key #unfortunately you can't use substitutions in secrets names
|
||||||
ota_pass: !secret esp-entmulti_ota_pass #unfortunately you can't use substitutions in secrets names
|
ota_pass: !secret esp-entmulti_ota_pass #unfortunately you can't use substitutions in secrets names
|
||||||
wifi_ssid: !secret wifi_ssid
|
static_ip_address: !secret esp-entmulti_ip
|
||||||
wifi_password: !secret wifi_password
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
fallback_ap_password: !secret fallback_ap_password
|
update_time: 30s #update time for for general temp sensors etc
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Entranceway" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
|
#############################################
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
#if NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#wifi_ssid: !secret wifi_ssid
|
||||||
|
#wifi_password: !secret wifi_password
|
||||||
|
#fallback_ap_password: !secret fallback_ap_password
|
||||||
#Add these if we are giving it a static ip, or remove them in the Wifi section
|
#Add these if we are giving it a static ip, or remove them in the Wifi section
|
||||||
#static_ip_address: !secret esp-entmulti_static_ip
|
#static_ip_address: !secret esp-entmulti_static_ip
|
||||||
#static_ip_gateway: !secret esp-entmulti_gateway
|
#static_ip_gateway: !secret esp-entmulti_gateway
|
||||||
#static_ip_subnet: !secret esp-entmulti_subnet
|
#static_ip_subnet: !secret esp-entmulti_subnet
|
||||||
|
|
||||||
mqtt_server: !secret mqtt_server
|
#mqtt_server: !secret mqtt_server
|
||||||
mqtt_username: !secret mqtt_username
|
#mqtt_username: !secret mqtt_username
|
||||||
mqtt_password: !secret mqtt_password
|
#mqtt_password: !secret mqtt_password
|
||||||
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
#mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
||||||
|
|
||||||
#web_server_username: !secret web_server_username
|
#web_server_username: !secret web_server_username
|
||||||
#web_server_password: !secret web_server_password
|
#web_server_password: !secret web_server_password
|
||||||
|
|
||||||
update_time: 30s #update time for for general temp sensors etc
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
common_webportal: !include
|
||||||
|
file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
# common_sntp: !include
|
||||||
|
# file: common/sntp_common.yaml
|
||||||
|
# common_general_sensors: !include
|
||||||
|
# file: common/sensors_common.yaml
|
||||||
|
# vars:
|
||||||
|
# local_friendly_name: ${friendly_name}
|
||||||
|
# local_update_interval: ${update_interval}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESPHome
|
# ESPHome
|
||||||
@@ -75,8 +108,8 @@ esp32:
|
|||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: INFO #INFO Level suggested, or DEBUG for testing
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
@@ -84,9 +117,9 @@ logger:
|
|||||||
# Enable the Home Assistant API
|
# Enable the Home Assistant API
|
||||||
# https://esphome.io/components/api.html
|
# https://esphome.io/components/api.html
|
||||||
#############################################
|
#############################################
|
||||||
api:
|
#api:
|
||||||
encryption:
|
# encryption:
|
||||||
key: ${api_key}
|
# key: ${api_key}
|
||||||
# on_client_connected:
|
# on_client_connected:
|
||||||
# - esp32_ble_tracker.start_scan:
|
# - esp32_ble_tracker.start_scan:
|
||||||
# continuous: true
|
# continuous: true
|
||||||
@@ -97,16 +130,16 @@ api:
|
|||||||
# Enable Over the Air Update Capability
|
# Enable Over the Air Update Capability
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
# https://esphome.io/components/ota.html?highlight=ota
|
||||||
#############################################
|
#############################################
|
||||||
ota:
|
#ota:
|
||||||
- platform: esphome
|
# - platform: esphome
|
||||||
password: ${ota_pass}
|
# password: ${ota_pass}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Safe Mode
|
# Safe Mode
|
||||||
# Safe mode will detect boot loops
|
# Safe mode will detect boot loops
|
||||||
# https://esphome.io/components/safe_mode
|
# https://esphome.io/components/safe_mode
|
||||||
#############################################
|
#############################################
|
||||||
safe_mode:
|
#safe_mode:
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Wifi Settings
|
# Wifi Settings
|
||||||
@@ -117,18 +150,18 @@ safe_mode:
|
|||||||
# LIGHT (Default for ESP32)
|
# LIGHT (Default for ESP32)
|
||||||
# HIGH (most power saving)
|
# HIGH (most power saving)
|
||||||
#############################################
|
#############################################
|
||||||
wifi:
|
#wifi:
|
||||||
ssid: ${wifi_ssid}
|
# ssid: ${wifi_ssid}
|
||||||
password: ${wifi_password}
|
# password: ${wifi_password}
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
||||||
#manual_ip: #optional static IP address
|
#manual_ip: #optional static IP address
|
||||||
#static_ip: ${static_ip_address}
|
#static_ip: ${static_ip_address}
|
||||||
#gateway: ${static_ip_gateway}
|
#gateway: ${static_ip_gateway}
|
||||||
#subnet: ${static_ip_subnet}
|
#subnet: ${static_ip_subnet}
|
||||||
ap: #Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
# ap: #Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
||||||
ssid: $devicename fallback AP
|
# ssid: $devicename fallback AP
|
||||||
password: !secret fallback_ap_password
|
# password: !secret fallback_ap_password
|
||||||
ap_timeout: 5min #Time until it brings up fallback AP. default is 1min
|
# ap_timeout: 5min #Time until it brings up fallback AP. default is 1min
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Web Portal for display and monitoring
|
# Web Portal for display and monitoring
|
||||||
@@ -146,13 +179,13 @@ wifi:
|
|||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
||||||
# MUST also have api enabled if you enable MQTT
|
# MUST also have api enabled if you enable MQTT
|
||||||
#############################################
|
#############################################
|
||||||
mqtt:
|
#mqtt:
|
||||||
broker: ${mqtt_server}
|
# broker: ${mqtt_server}
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
# topic_prefix: ${mqtt_topic}/${devicename}
|
||||||
username: ${mqtt_username}
|
# username: ${mqtt_username}
|
||||||
password: ${mqtt_password}
|
# password: ${mqtt_password}
|
||||||
discovery: False # enable entity discovery (true is default)
|
# discovery: False # enable entity discovery (true is default)
|
||||||
#discover_ip: True # enable device discovery (true is default)
|
# discover_ip: False # enable device discovery (true is default)
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# i2c bus
|
# i2c bus
|
||||||
|
180
esphome/esp-laundrydrypow.yaml
Normal file
180
esphome/esp-laundrydrypow.yaml
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# LAUNDRY DRYER MACHINE POWER
|
||||||
|
# V1.0 2025-05-28 Initial Version
|
||||||
|
#############################################
|
||||||
|
# Sonoff POW R1
|
||||||
|
# https://devices.esphome.io/devices/Sonoff-POW-R1
|
||||||
|
#
|
||||||
|
# NOTES
|
||||||
|
# -
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
device_name: "esp-laundrydrypow" # Reference name for the device in the system.
|
||||||
|
project_name: "Sonoff Technologies.POW R1" # Project Details
|
||||||
|
project_version: "v1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
entity_prefix: "Load" # Simple device name where we want to prefix a sensor or switch, eg "Load" Current.
|
||||||
|
friendly_name: "Laundry Dryer Power"
|
||||||
|
description_comment: "Laundry Dryer Power using a Sonoff Pow R1."
|
||||||
|
device_area: "Laundry" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
api_key: !secret esp-laundrydrypow_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-laundrydrypow_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-laundrydrypow_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
# common_mqtt: !include
|
||||||
|
# file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: "${device_name}"
|
||||||
|
friendly_name: "${friendly_name}"
|
||||||
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
|
area: "${device_area}"
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
on_boot:
|
||||||
|
priority: 200
|
||||||
|
then:
|
||||||
|
- switch.turn_on: "virtual_button"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||||
|
board_flash_mode: dout # Default is dout
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
#status_led:
|
||||||
|
# pin:
|
||||||
|
# number: GPIO2
|
||||||
|
# inverted: yes
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO0
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
name: Button
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: virtual_button
|
||||||
|
- platform: template
|
||||||
|
name: ${entity_prefix} Running
|
||||||
|
filters:
|
||||||
|
- delayed_off: 15s
|
||||||
|
lambda: |-
|
||||||
|
if (isnan(id(power).state)) {
|
||||||
|
return {};
|
||||||
|
} else if (id(power).state > 4) {
|
||||||
|
// Running
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Not running
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: hlw8012
|
||||||
|
sel_pin: 5
|
||||||
|
cf_pin: 14
|
||||||
|
cf1_pin: 13
|
||||||
|
update_interval: 2s
|
||||||
|
current:
|
||||||
|
name: ${entity_prefix} Current
|
||||||
|
voltage:
|
||||||
|
name: ${entity_prefix} Voltage
|
||||||
|
power:
|
||||||
|
name: ${entity_prefix} Power
|
||||||
|
id: power
|
||||||
|
#on_value_range:
|
||||||
|
# - above: 4.0
|
||||||
|
# then:
|
||||||
|
# - light.turn_on: led
|
||||||
|
# - below: 3.0
|
||||||
|
# then:
|
||||||
|
# - light.turn_off: led
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: template
|
||||||
|
name: "Relay"
|
||||||
|
optimistic: true
|
||||||
|
id: virtual_button
|
||||||
|
turn_on_action:
|
||||||
|
- switch.turn_on: relay
|
||||||
|
- light.turn_on: led
|
||||||
|
turn_off_action:
|
||||||
|
- switch.turn_off: relay
|
||||||
|
- light.turn_off: led
|
||||||
|
- platform: gpio
|
||||||
|
id: relay
|
||||||
|
pin: GPIO12
|
||||||
|
#restore_mode: ALWAYS_ON # Or RESTORE_DEFAULT_ON/RESTORE_DEFAULT_OFF
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: esp8266_pwm
|
||||||
|
id: pow_blue_led
|
||||||
|
pin:
|
||||||
|
number: GPIO15
|
||||||
|
inverted: True
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: monochromatic
|
||||||
|
name: Status LED
|
||||||
|
output: pow_blue_led
|
||||||
|
id: led
|
126
esphome/esp-laundryenv.yaml
Normal file
126
esphome/esp-laundryenv.yaml
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# LAUNDRY ENVIRONMENT - SONOFF DEV
|
||||||
|
# V1.0 2025-03-28 Initial Version
|
||||||
|
#############################################
|
||||||
|
# Sonoff Dev
|
||||||
|
# https://wiki.iteadstudio.com/Sonoff_DEV
|
||||||
|
#
|
||||||
|
# NOTES
|
||||||
|
# -
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
device_name: "esp-laundryenv" # Reference name for the device in the system.
|
||||||
|
project_name: "Sonoff Technologies.Sonoff DEV" # Project Details
|
||||||
|
project_version: "v1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
entity_prefix: "Laundry" # Simple device name where we want to prefix a sensor or switch, eg "Load" Current.
|
||||||
|
friendly_name: "Laundry Environment"
|
||||||
|
description_comment: "Laundry Environment Sensor, PIR and Smoke Detector using Sonoff DEV"
|
||||||
|
device_area: "Laundry" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
api_key: !secret esp-laundryenv_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-laundryenv_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-laundryenv_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
# common_mqtt: !include
|
||||||
|
# file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: "${device_name}"
|
||||||
|
friendly_name: "${friendly_name}"
|
||||||
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
|
area: "${device_area}"
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||||
|
board_flash_mode: dout # Default is dout
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
#############################################
|
||||||
|
sensor:
|
||||||
|
- platform: dht
|
||||||
|
pin: GPIO14
|
||||||
|
temperature:
|
||||||
|
name: ${entity_prefix} Temperature
|
||||||
|
humidity:
|
||||||
|
name: ${entity_prefix} Humidity
|
||||||
|
update_interval: ${update_interval}
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO13
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: false
|
||||||
|
name: ${entity_prefix} PIR
|
||||||
|
device_class: motion
|
||||||
|
#filters:
|
||||||
|
# - invert:
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO05
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: false
|
||||||
|
inverted: True
|
||||||
|
name: ${entity_prefix} Smoke Detector
|
||||||
|
|
||||||
|
|
||||||
|
|
154
esphome/esp-laundrylights.yaml
Normal file
154
esphome/esp-laundrylights.yaml
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# LAUNDRY MAIN LIGHTSWITCH
|
||||||
|
# V1.0 2025-05-30 Initial Version
|
||||||
|
#############################################
|
||||||
|
# Zemismart KS-811 Triple push button
|
||||||
|
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||||
|
#
|
||||||
|
# NOTES
|
||||||
|
# -
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
device_name: "esp-laundrylights"
|
||||||
|
project_name: "Zemismart Technologies.KS-811 Triple" # Project Details
|
||||||
|
project_version: "v1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
entity_prefix: "Laundry" # Simple device name where we want to prefix a sensor or switch, eg "Load" Current.
|
||||||
|
friendly_name: "Laundry Main Lightswitch (3)"
|
||||||
|
description_comment: "Laundry Main Lightswitch using a Zemismart KS-811 Triple Push Button. Laundry Lights (1), Spare (2), Laundry Power Signal (3)"
|
||||||
|
device_area: "Laundry" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
api_key: !secret esp-laundrylights_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-laundrylights_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-laundrylights_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: ${device_name}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
comment: ${description_comment} #Appears on the esphome page in HA
|
||||||
|
area: ${device_area}
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
on_boot:
|
||||||
|
priority: 200
|
||||||
|
then:
|
||||||
|
- switch.turn_on: Relay_3
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||||
|
board_flash_mode: dout # Default is dout
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
status_led:
|
||||||
|
pin:
|
||||||
|
number: GPIO2
|
||||||
|
inverted: yes
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# BINARY SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO16
|
||||||
|
mode: INPUT
|
||||||
|
inverted: True
|
||||||
|
name: "Button 1: Light Switch (Laundry)"
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: Relay_1
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO05
|
||||||
|
mode: INPUT
|
||||||
|
inverted: True
|
||||||
|
name: "Button 2: Spare"
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: Relay_2
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO4
|
||||||
|
mode: INPUT
|
||||||
|
inverted: True
|
||||||
|
name: "Button 3: Laundry Power Enable"
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: Relay_3
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SWITCH COMPONENT
|
||||||
|
# https://esphome.io/components/switch/
|
||||||
|
#############################################
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay 1: Laundry Lights"
|
||||||
|
pin: GPIO13
|
||||||
|
id: Relay_1
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay 2: Spare"
|
||||||
|
pin: GPIO12
|
||||||
|
id: Relay_2
|
||||||
|
- platform: gpio
|
||||||
|
name: "Relay 3: Laundry Power Enable Signal"
|
||||||
|
pin: GPIO14
|
||||||
|
id: Relay_3
|
||||||
|
|
||||||
|
|
180
esphome/esp-laundryplugpow.yaml
Normal file
180
esphome/esp-laundryplugpow.yaml
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# LAUNDRY BENCH PLUGS POWER AND SWITCH
|
||||||
|
# V1.0 2025-03-28 Initial Version
|
||||||
|
#############################################
|
||||||
|
# Sonoff POW R1
|
||||||
|
# https://devices.esphome.io/devices/Sonoff-POW-R1
|
||||||
|
#
|
||||||
|
# NOTES
|
||||||
|
# -
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
device_name: "esp-laundryplugpow" # Reference name for the device in the system.
|
||||||
|
project_name: "Sonoff Technologies.POW R1" # Project Details
|
||||||
|
project_version: "v1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
entity_prefix: "Load" # Simple device name where we want to prefix a sensor or switch, eg "Load" Current.
|
||||||
|
friendly_name: "Laundry Bench Plug Power"
|
||||||
|
description_comment: "Laundry Bench Plug Power and switch override using a Sonoff Pow R1."
|
||||||
|
device_area: "Laundry" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
api_key: !secret esp-laundryplugpow_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-laundryplugpow_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-laundryplugpow_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
# common_mqtt: !include
|
||||||
|
# file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: "${device_name}"
|
||||||
|
friendly_name: "${friendly_name}"
|
||||||
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
|
area: "${device_area}"
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
on_boot:
|
||||||
|
priority: 200
|
||||||
|
then:
|
||||||
|
- switch.turn_on: "virtual_button"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||||
|
board_flash_mode: dout # Default is dout
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
#status_led:
|
||||||
|
# pin:
|
||||||
|
# number: GPIO2
|
||||||
|
# inverted: yes
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO0
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
name: Button
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: virtual_button
|
||||||
|
- platform: template
|
||||||
|
name: ${entity_prefix} Running
|
||||||
|
filters:
|
||||||
|
- delayed_off: 15s
|
||||||
|
lambda: |-
|
||||||
|
if (isnan(id(power).state)) {
|
||||||
|
return {};
|
||||||
|
} else if (id(power).state > 4) {
|
||||||
|
// Running
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Not running
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: hlw8012
|
||||||
|
sel_pin: 5
|
||||||
|
cf_pin: 14
|
||||||
|
cf1_pin: 13
|
||||||
|
update_interval: 2s
|
||||||
|
current:
|
||||||
|
name: ${entity_prefix} Current
|
||||||
|
voltage:
|
||||||
|
name: ${entity_prefix} Voltage
|
||||||
|
power:
|
||||||
|
name: ${entity_prefix} Power
|
||||||
|
id: power
|
||||||
|
#on_value_range:
|
||||||
|
# - above: 4.0
|
||||||
|
# then:
|
||||||
|
# - light.turn_on: led
|
||||||
|
# - below: 3.0
|
||||||
|
# then:
|
||||||
|
# - light.turn_off: led
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: template
|
||||||
|
name: "Relay"
|
||||||
|
optimistic: true
|
||||||
|
id: virtual_button
|
||||||
|
turn_on_action:
|
||||||
|
- switch.turn_on: relay
|
||||||
|
- light.turn_on: led
|
||||||
|
turn_off_action:
|
||||||
|
- switch.turn_off: relay
|
||||||
|
- light.turn_off: led
|
||||||
|
- platform: gpio
|
||||||
|
id: relay
|
||||||
|
pin: GPIO12
|
||||||
|
#restore_mode: ALWAYS_ON # Or RESTORE_DEFAULT_ON/RESTORE_DEFAULT_OFF
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: esp8266_pwm
|
||||||
|
id: pow_blue_led
|
||||||
|
pin:
|
||||||
|
number: GPIO15
|
||||||
|
inverted: True
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: monochromatic
|
||||||
|
name: Status LED
|
||||||
|
output: pow_blue_led
|
||||||
|
id: led
|
180
esphome/esp-laundrywashpow.yaml
Normal file
180
esphome/esp-laundrywashpow.yaml
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# LAUNDRY WASHING MACHINE POWER
|
||||||
|
# V1.0 2025-03-28 Initial Version
|
||||||
|
#############################################
|
||||||
|
# Sonoff POW R1
|
||||||
|
# https://devices.esphome.io/devices/Sonoff-POW-R1
|
||||||
|
#
|
||||||
|
# NOTES
|
||||||
|
# -
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
substitutions:
|
||||||
|
device_name: "esp-laundrywashpow" # Reference name for the device in the system.
|
||||||
|
project_name: "Sonoff Technologies.POW R1" # Project Details
|
||||||
|
project_version: "v1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
entity_prefix: "Load" # Simple device name where we want to prefix a sensor or switch, eg "Load" Current.
|
||||||
|
friendly_name: "Laundry Washing Machine Power" # Friendly name to show in Home Assistant.
|
||||||
|
description_comment: "Laundry Washing Machine Power using a Sonoff Pow R1."
|
||||||
|
device_area: "Laundry" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
api_key: !secret esp-laundrywashpow_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-laundrywashpow_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-laundrywashpow_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
# file: common/mqtt_common.yaml
|
||||||
|
# common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: "${device_name}"
|
||||||
|
friendly_name: "${friendly_name}"
|
||||||
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
|
area: "${device_area}"
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
on_boot:
|
||||||
|
priority: 200
|
||||||
|
then:
|
||||||
|
- switch.turn_on: "virtual_button"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m
|
||||||
|
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||||
|
board_flash_mode: dout # Default is dout
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
#############################################
|
||||||
|
#status_led:
|
||||||
|
# pin:
|
||||||
|
# number: GPIO2
|
||||||
|
# inverted: yes
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO0
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
name: Button
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: virtual_button
|
||||||
|
- platform: template
|
||||||
|
name: ${entity_prefix} Running
|
||||||
|
filters:
|
||||||
|
- delayed_off: 15s
|
||||||
|
lambda: |-
|
||||||
|
if (isnan(id(power).state)) {
|
||||||
|
return {};
|
||||||
|
} else if (id(power).state > 4) {
|
||||||
|
// Running
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Not running
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: hlw8012
|
||||||
|
sel_pin: 5
|
||||||
|
cf_pin: 14
|
||||||
|
cf1_pin: 13
|
||||||
|
update_interval: 2s
|
||||||
|
current:
|
||||||
|
name: ${entity_prefix} Current
|
||||||
|
voltage:
|
||||||
|
name: ${entity_prefix} Voltage
|
||||||
|
power:
|
||||||
|
name: ${entity_prefix} Power
|
||||||
|
id: power
|
||||||
|
#on_value_range:
|
||||||
|
# - above: 4.0
|
||||||
|
# then:
|
||||||
|
# - light.turn_on: led
|
||||||
|
# - below: 3.0
|
||||||
|
# then:
|
||||||
|
# - light.turn_off: led
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: template
|
||||||
|
name: "Relay"
|
||||||
|
optimistic: true
|
||||||
|
id: virtual_button
|
||||||
|
turn_on_action:
|
||||||
|
- switch.turn_on: relay
|
||||||
|
- light.turn_on: led
|
||||||
|
turn_off_action:
|
||||||
|
- switch.turn_off: relay
|
||||||
|
- light.turn_off: led
|
||||||
|
- platform: gpio
|
||||||
|
id: relay
|
||||||
|
pin: GPIO12
|
||||||
|
#restore_mode: ALWAYS_ON # Or RESTORE_DEFAULT_ON/RESTORE_DEFAULT_OFF
|
||||||
|
|
||||||
|
output:
|
||||||
|
- platform: esp8266_pwm
|
||||||
|
id: pow_blue_led
|
||||||
|
pin:
|
||||||
|
number: GPIO15
|
||||||
|
inverted: True
|
||||||
|
|
||||||
|
light:
|
||||||
|
- platform: monochromatic
|
||||||
|
name: Status LED
|
||||||
|
output: pow_blue_led
|
||||||
|
id: led
|
@@ -35,37 +35,26 @@
|
|||||||
#############################################
|
#############################################
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
|
|
||||||
#############################################
|
|
||||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
|
||||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
#############################################
|
|
||||||
|
|
||||||
mqtt_timer_topic: "viewroad-commands/masterbath-towelrail" # Topics you will use to change stuff
|
|
||||||
startup_duration: "120" # Minutes to stay ON in STARTUP mode before reverting to TIMER
|
|
||||||
|
|
||||||
devicename: "esp-masterbathtowelrail"
|
devicename: "esp-masterbathtowelrail"
|
||||||
friendly_name: "Master Bathroom Towelrail"
|
friendly_name: "Master Bathroom Towelrail"
|
||||||
description_comment: "Sonoff Basic controlling ON/OFF/Timer for the Heated Towel Rail in the Master Bathroom"
|
description_comment: "Sonoff Basic controlling ON/OFF/Timer for the Heated Towel Rail in the Master Bathroom"
|
||||||
|
|
||||||
api_key: !secret esp-masterbathtowelrail_api_key # unfortunately you can't use substitutions inside secrets names
|
api_key: !secret esp-masterbathtowelrail_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-masterbathtowelrail_ota_pass # unfortunately you can't use substitutions inside secrets names
|
ota_pass: !secret esp-masterbathtowelrail_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
static_ip_address: !secret esp-masterbathtowelrail_ip
|
static_ip_address: !secret esp-masterbathtowelrail_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
update_interval: "60s" # Update time for for general sensors etc.
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Main Bathroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# SYSTEM SPECIFIC VARIABLE SUBSTITUTIONS
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
#############################################
|
#############################################
|
||||||
|
mqtt_timer_topic: "viewroad-commands/masterbath-towelrail" # Topics you will use to change stuff
|
||||||
timezone: "Pacific/Auckland"
|
startup_duration: "120" # Minutes to stay ON in STARTUP mode before reverting to TIMER
|
||||||
sntp_update_interval: 6h # Set the duration between the sntp service polling
|
|
||||||
# Network time servers https://www.ntppool.org/zone/@
|
|
||||||
# Make sure you have some DNS, or use IP addresses only here.
|
|
||||||
sntp_server_1: !secret ntp_server_1
|
|
||||||
sntp_server_2: !secret ntp_server_2
|
|
||||||
sntp_server_3: !secret ntp_server_3
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Included Common Packages
|
# Included Common Packages
|
||||||
@@ -76,10 +65,17 @@ packages:
|
|||||||
file: common/network_common.yaml
|
file: common/network_common.yaml
|
||||||
vars:
|
vars:
|
||||||
local_static_ip_address: ${static_ip_address}
|
local_static_ip_address: ${static_ip_address}
|
||||||
local_api_key: ${api_key}
|
|
||||||
local_ota_pass: ${ota_pass}
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
common_mqtt: !include
|
common_mqtt: !include
|
||||||
file: common/mqtt_common.yaml
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
common_general_sensors: !include
|
common_general_sensors: !include
|
||||||
file: common/sensors_common.yaml
|
file: common/sensors_common.yaml
|
||||||
vars:
|
vars:
|
||||||
@@ -94,6 +90,7 @@ esphome:
|
|||||||
name: ${devicename}
|
name: ${devicename}
|
||||||
friendly_name: ${friendly_name}
|
friendly_name: ${friendly_name}
|
||||||
comment: ${description_comment} # Appears on the esphome page in HA
|
comment: ${description_comment} # Appears on the esphome page in HA
|
||||||
|
area: "${room}"
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 900 # High priority to run after globals are initialized
|
priority: 900 # High priority to run after globals are initialized
|
||||||
then:
|
then:
|
||||||
@@ -147,45 +144,11 @@ esp8266:
|
|||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: DEBUG #INFO Level suggested, or DEBUG for testing
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Real time clock time source for ESPHome
|
|
||||||
# If it's invalid, we fall back to an internal clock
|
|
||||||
# https://esphome.io/components/time/index.html
|
|
||||||
# https://esphome.io/components/time/sntp
|
|
||||||
#############################################
|
|
||||||
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:
|
|
||||||
- logger.log: "Synchronised sntp clock"
|
|
||||||
- text_sensor.template.publish:
|
|
||||||
id: time_sync
|
|
||||||
state: "SNTP clock Syncd"
|
|
||||||
# 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");'
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Global Variables for use in automations etc
|
# Global Variables for use in automations etc
|
||||||
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
|
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
|
||||||
@@ -466,32 +429,6 @@ text_sensor:
|
|||||||
return { std::string(buff) };
|
return { std::string(buff) };
|
||||||
update_interval: ${update_interval}
|
update_interval: ${update_interval}
|
||||||
|
|
||||||
######################################################
|
|
||||||
# Creates a sensor showing when the device was last restarted
|
|
||||||
# Uptime template sensor, and SNTP are needed
|
|
||||||
######################################################
|
|
||||||
- platform: template
|
|
||||||
name: "Last Restart: ${friendly_name}"
|
|
||||||
id: device_last_restart
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
icon: mdi:clock
|
|
||||||
entity_category: diagnostic
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Time Sync Status"
|
|
||||||
id: time_sync
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
entity_category: diagnostic
|
|
||||||
|
|
||||||
- platform: template
|
|
||||||
name: "Internal Time"
|
|
||||||
id: time_text
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
entity_category: diagnostic
|
|
||||||
lambda: |-
|
|
||||||
auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
|
|
||||||
return { time_text };
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Sensors
|
# Sensors
|
||||||
# https://esphome.io/components/text_sensor/index.html
|
# https://esphome.io/components/text_sensor/index.html
|
||||||
@@ -506,7 +443,6 @@ sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
return id(current_mins);
|
return id(current_mins);
|
||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# Relay Switch (Sonoff Basic Relay on GPIO12)
|
# Relay Switch (Sonoff Basic Relay on GPIO12)
|
||||||
####################################################
|
####################################################
|
||||||
|
@@ -30,37 +30,51 @@
|
|||||||
# web_server_password (Optional)
|
# web_server_password (Optional)
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# VARIABLE SUBSTITUTIONS
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
# Give the device a useful name & description here
|
# If NOT using a secrets file, just replace
|
||||||
# and change values accordingly.
|
# these with the passwords etc (in quotes)
|
||||||
#############################################
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
device_name: esp-midesklamp1s
|
device_name: esp-midesklamp1s
|
||||||
friendly_name: "Mi 1S Lamp Office"
|
friendly_name: "Mi 1S Lamp Office"
|
||||||
description_comment: "Office Desk Lamp with variable white colour temp and rotary encoder for brightness"
|
description_comment: "Office Desk Lamp with variable white colour temp and rotary encoder for brightness"
|
||||||
|
|
||||||
# if NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
api_key: !secret esp-midesklamp1s_api_key # unfortunately you can't use substitutions in secrets names
|
api_key: !secret esp-midesklamp1s_api_key # unfortunately you can't use substitutions in secrets names
|
||||||
ota_pass: !secret esp-midesklamp1s_ota_pass # unfortunately you can't use substitutions in secrets names
|
ota_pass: !secret esp-midesklamp1s_ota_pass # unfortunately you can't use substitutions in secrets names
|
||||||
wifi_ssid: !secret wifi_ssid
|
static_ip_address: !secret esp-midesklamp1s_ip
|
||||||
wifi_password: !secret wifi_password
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
fallback_ap_password: !secret fallback_ap_password
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
room: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
# Add these if we are giving it a static ip, or remove them in the Wifi section
|
#############################################
|
||||||
#static_ip_address: !secret esp-midesklamp1s_static_ip
|
# Included Common Packages
|
||||||
#static_ip_gateway: !secret esp-midesklamp1s_gateway
|
# https://esphome.io/components/esphome.html
|
||||||
#static_ip_subnet: !secret esp-midesklamp1s_subnet
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
mqtt_server: !secret mqtt_server
|
#web_server: !remove
|
||||||
mqtt_username: !secret mqtt_username
|
|
||||||
mqtt_password: !secret mqtt_password
|
|
||||||
mqtt_topic: "esphome" # main topic for the mqtt server, call it what you like
|
|
||||||
|
|
||||||
web_server_username: !secret web_server_username
|
|
||||||
web_server_password: !secret web_server_password
|
|
||||||
|
|
||||||
update_time: 60s # update time for for general temp sensors etc
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESPHome
|
# ESPHome
|
||||||
@@ -70,6 +84,7 @@ esphome:
|
|||||||
name: ${device_name}
|
name: ${device_name}
|
||||||
friendly_name: ${friendly_name} # appears as main name on the esphome page in HA
|
friendly_name: ${friendly_name} # appears as main name on the esphome page in HA
|
||||||
comment: ${description_comment} # appears as comment on the esphome page in HA
|
comment: ${description_comment} # appears as comment on the esphome page in HA
|
||||||
|
area: ${room}
|
||||||
#min_version: 2024.6.0
|
#min_version: 2024.6.0
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
@@ -94,113 +109,25 @@ esp32:
|
|||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: INFO # INFO Level suggested, or DEBUG for testing
|
level: ${log_level} # INFO Level suggested, or DEBUG for testing
|
||||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${api_key}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- platform: esphome
|
|
||||||
password: ${ota_pass}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Safe Mode
|
|
||||||
# Safe mode will detect boot loops
|
|
||||||
# https://esphome.io/components/safe_mode
|
|
||||||
#############################################
|
|
||||||
safe_mode:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Wifi Settings
|
|
||||||
# https://esphome.io/components/wifi.html
|
|
||||||
#
|
|
||||||
# Power Save mode (can reduce wifi reliability)
|
|
||||||
# NONE (least power saving, Default for ESP8266)
|
|
||||||
# LIGHT (Default for ESP32)
|
|
||||||
# HIGH (most power saving)
|
|
||||||
#############################################
|
|
||||||
wifi:
|
|
||||||
ssid: ${wifi_ssid}
|
|
||||||
password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
#manual_ip: #optional static IP address
|
|
||||||
#static_ip: ${static_ip_address}
|
|
||||||
#gateway: ${static_ip_gateway}
|
|
||||||
#subnet: ${static_ip_subnet}
|
|
||||||
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
|
||||||
ssid: ${device_name} fallback AP
|
|
||||||
password: ${fallback_ap_password}
|
|
||||||
ap_timeout: 30min # Time until it brings up fallback AP. default is 1min
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Web Portal for display and monitoring
|
|
||||||
# Turning this off is probably a good idea to save resources.
|
|
||||||
# https://esphome.io/components/web_server.html
|
|
||||||
#############################################
|
|
||||||
#web_server:
|
|
||||||
# port: 80
|
|
||||||
# auth:
|
|
||||||
# username: ${web_server_username} #probably a good idea to secure it
|
|
||||||
# password: ${web_server_password}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${device_name}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: False # enable entity discovery (true is default)
|
|
||||||
#discover_ip: True # enable device discovery (true is default)
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Time Component
|
# Time Component
|
||||||
# https://esphome.io/components/time/index.html#time-component
|
# https://esphome.io/components/time/index.html#time-component
|
||||||
# Sync with HA Time. Probably not really necessary.
|
# Sync with HA Time. Probably not really necessary.
|
||||||
#############################################
|
#############################################
|
||||||
time:
|
#time:
|
||||||
- platform: homeassistant
|
# - platform: homeassistant
|
||||||
id: homeassistant_time
|
# id: homeassistant_time
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Text Sensors
|
|
||||||
# https://esphome.io/components/text_sensor/index.html
|
|
||||||
#############################################
|
|
||||||
text_sensor:
|
|
||||||
- platform: version
|
|
||||||
name: ${friendly_name} Version
|
|
||||||
- platform: wifi_info
|
|
||||||
ip_address:
|
|
||||||
name: ${friendly_name} IP Address
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# General Sensors
|
# General Sensors
|
||||||
# https://esphome.io/components/sensor/index.html
|
# https://esphome.io/components/sensor/index.html
|
||||||
#############################################
|
#############################################
|
||||||
sensor:
|
sensor:
|
||||||
- platform: uptime # Uptime for this device
|
|
||||||
name: ${friendly_name} Uptime
|
|
||||||
update_interval: ${update_time}
|
|
||||||
- platform: wifi_signal # Wifi Strength
|
|
||||||
name: ${friendly_name} Wifi Signal
|
|
||||||
update_interval: ${update_time}
|
|
||||||
|
|
||||||
# Mi Desk Lamp 1S Configuration
|
# Mi Desk Lamp 1S Configuration
|
||||||
- platform: rotary_encoder
|
- platform: rotary_encoder
|
||||||
id: rotation
|
id: rotation
|
||||||
@@ -212,7 +139,7 @@ sensor:
|
|||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
# Check if Button is pressed while rotating
|
# Check if Button is pressed while rotating
|
||||||
lambda: "return id(button).state;"
|
lambda: "return id(pushbutton).state;"
|
||||||
then:
|
then:
|
||||||
# If Button is pressed, change CW/WW
|
# If Button is pressed, change CW/WW
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -240,7 +167,7 @@ sensor:
|
|||||||
#############################################
|
#############################################
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: button
|
id: pushbutton
|
||||||
pin:
|
pin:
|
||||||
number: GPIO33
|
number: GPIO33
|
||||||
inverted: True
|
inverted: True
|
||||||
|
@@ -17,35 +17,51 @@
|
|||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# VARIABLE SUBSTITUTIONS
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
# Give the device a useful name & description here
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
# and change values accordingly.
|
|
||||||
#############################################
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
devicename: "esp-occupancyoffice"
|
devicename: "esp-occupancyoffice"
|
||||||
friendly_name: "Office Occupancy & Environment"
|
friendly_name: "Office Occupancy & Environment"
|
||||||
description_comment: "D1 Mini ESP32 with LD1125H mmWave and environment sensors for downstairs office"
|
description_comment: "D1 Mini ESP32 with LD1125H mmWave and environment sensors for downstairs office"
|
||||||
|
|
||||||
#if NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
|
||||||
api_key: !secret esp-occupancyoffice_api_key #unfortunately you can't use substitutions inside secrets names
|
api_key: !secret esp-occupancyoffice_api_key #unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-occupancyoffice_ota_pass #unfortunately you can't use substitutions inside secrets names
|
ota_pass: !secret esp-occupancyoffice_ota_pass #unfortunately you can't use substitutions inside secrets names
|
||||||
wifi_ssid: !secret wifi_ssid
|
static_ip_address: !secret esp-occupancyoffice_ip
|
||||||
wifi_password: !secret wifi_password
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
fallback_ap_password: !secret fallback_ap_password
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
#Add these if we are giving it a static ip, or remove them in the Wifi section
|
room: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
#static_ip_address: !secret esp-occupancyoffice_static_ip
|
|
||||||
#static_ip_gateway: !secret esp-occupancyoffice_gateway
|
|
||||||
#static_ip_subnet: !secret esp-occupancyoffice_subnet
|
|
||||||
|
|
||||||
mqtt_server: !secret mqtt_server
|
#############################################
|
||||||
mqtt_username: !secret mqtt_username
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
mqtt_password: !secret mqtt_password
|
#############################################
|
||||||
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
#
|
||||||
|
#
|
||||||
|
|
||||||
#web_server_username: !secret web_server_username
|
#############################################
|
||||||
#web_server_password: !secret web_server_password
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
update_time: 30s #update time for for general temp sensors etc
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
# common_api: !include
|
||||||
|
# file: common/api_common.yaml
|
||||||
|
# vars:
|
||||||
|
# local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESPHome
|
# ESPHome
|
||||||
@@ -56,6 +72,7 @@ esphome:
|
|||||||
friendly_name: ${friendly_name}
|
friendly_name: ${friendly_name}
|
||||||
comment: ${description_comment} #appears on the esphome page in HA
|
comment: ${description_comment} #appears on the esphome page in HA
|
||||||
min_version: 2024.6.0
|
min_version: 2024.6.0
|
||||||
|
area: "${room}"
|
||||||
on_boot: #LD1125H Initial Setting, will remember previous values (if set)
|
on_boot: #LD1125H Initial Setting, will remember previous values (if set)
|
||||||
priority: -200
|
priority: -200
|
||||||
then:
|
then:
|
||||||
@@ -107,7 +124,7 @@ external_components:
|
|||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
#############################################
|
#############################################
|
||||||
logger:
|
logger:
|
||||||
level: INFO #INFO Level suggested, or DEBUG for testing
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
@@ -119,72 +136,13 @@ logger:
|
|||||||
api:
|
api:
|
||||||
encryption:
|
encryption:
|
||||||
key: ${api_key}
|
key: ${api_key}
|
||||||
|
#key: "puCd6EGmFp3hU56N8dOo5u17bXwDr0aVRWiDoNdPDoE="
|
||||||
on_client_connected:
|
on_client_connected:
|
||||||
- esp32_ble_tracker.start_scan:
|
- esp32_ble_tracker.start_scan:
|
||||||
continuous: true
|
continuous: true
|
||||||
on_client_disconnected:
|
on_client_disconnected:
|
||||||
- esp32_ble_tracker.stop_scan:
|
- esp32_ble_tracker.stop_scan:
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- platform: esphome
|
|
||||||
password: ${ota_pass}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Safe Mode
|
|
||||||
# Safe mode will detect boot loops
|
|
||||||
# https://esphome.io/components/safe_mode
|
|
||||||
#############################################
|
|
||||||
safe_mode:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Wifi Settings
|
|
||||||
# https://esphome.io/components/wifi.html
|
|
||||||
#
|
|
||||||
# Power Save mode (can reduce wifi reliability)
|
|
||||||
# NONE (least power saving, Default for ESP8266)
|
|
||||||
# LIGHT (Default for ESP32)
|
|
||||||
# HIGH (most power saving)
|
|
||||||
#############################################
|
|
||||||
wifi:
|
|
||||||
ssid: ${wifi_ssid}
|
|
||||||
password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
#manual_ip: #optional static IP address
|
|
||||||
#static_ip: ${static_ip_address}
|
|
||||||
#gateway: ${static_ip_gateway}
|
|
||||||
#subnet: ${static_ip_subnet}
|
|
||||||
ap: #Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
|
||||||
ssid: ${devicename} fallback AP
|
|
||||||
password: ${fallback_ap_password}
|
|
||||||
ap_timeout: 30min #Time until it brings up fallback AP. default is 1min
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Web Portal for display and monitoring
|
|
||||||
# Turning this off is probably a good idea to save resources.
|
|
||||||
# https://esphome.io/components/web_server.html
|
|
||||||
#############################################
|
|
||||||
#web_server:
|
|
||||||
# port: 80
|
|
||||||
# auth:
|
|
||||||
# username: ${web_server_username} #probably a good idea to secure it
|
|
||||||
# password: ${web_server_password}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: False # enable entity discovery (true is default)
|
|
||||||
#discover_ip: True # enable device discovery (true is default)
|
|
||||||
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
@@ -239,11 +197,15 @@ globals:
|
|||||||
- id: LD1125H_Last_Time
|
- id: LD1125H_Last_Time
|
||||||
type: time_t
|
type: time_t
|
||||||
restore_value: no
|
restore_value: no
|
||||||
initial_value: time(NULL)
|
#initial_value: time(NULL)
|
||||||
|
#initial_value: !lambda 'return ::time(nullptr);'
|
||||||
|
initial_value: "0"
|
||||||
- id: LD1125H_Last_Mov_Time
|
- id: LD1125H_Last_Mov_Time
|
||||||
type: time_t
|
type: time_t
|
||||||
restore_value: no
|
restore_value: no
|
||||||
initial_value: time(NULL)
|
#initial_value: time(NULL)
|
||||||
|
#initial_value: !lambda 'return ::time(nullptr);'
|
||||||
|
initial_value: "0"
|
||||||
- id: LD1125H_Clearence_Status
|
- id: LD1125H_Clearence_Status
|
||||||
type: bool
|
type: bool
|
||||||
restore_value: no
|
restore_value: no
|
||||||
@@ -264,22 +226,26 @@ status_led:
|
|||||||
# https://esphome.io/guides/automations.html
|
# https://esphome.io/guides/automations.html
|
||||||
#############################################
|
#############################################
|
||||||
interval:
|
interval:
|
||||||
- interval: 1s #Clearance Scan Time
|
- interval: 1s # Clearance Scan Time
|
||||||
setup_priority: -200
|
setup_priority: -200
|
||||||
then:
|
then:
|
||||||
lambda: |-
|
- lambda: |-
|
||||||
if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) {
|
// Use the global C time() function (::time(nullptr))
|
||||||
if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) {
|
if ((::time(nullptr) - id(LD1125H_Last_Time)) > id(LD1125H_Clear_Time).state) {
|
||||||
id(LD1125H_Occupancy).publish_state("Clearance");
|
if ((id(LD1125H_Clearence_Status) == false) ||
|
||||||
id(LD1125H_Clearence_Status) = true;
|
(id(LD1125H_Occupancy).state != "Clearance")) {
|
||||||
|
id(LD1125H_Occupancy).publish_state("Clearance");
|
||||||
|
id(LD1125H_Clearence_Status) = true;
|
||||||
|
}
|
||||||
|
if (id(LD1125H_MovOcc_Binary).state == true) {
|
||||||
|
id(LD1125H_MovOcc_Binary).publish_state(false);
|
||||||
|
}
|
||||||
|
if (id(LD1125H_Mov_Binary).state == true) {
|
||||||
|
id(LD1125H_Mov_Binary).publish_state(false);
|
||||||
|
}
|
||||||
|
// Update the last-seen timestamp
|
||||||
|
id(LD1125H_Last_Time) = ::time(nullptr);
|
||||||
}
|
}
|
||||||
if (id(LD1125H_MovOcc_Binary).state == true) {
|
|
||||||
id(LD1125H_MovOcc_Binary).publish_state(false);
|
|
||||||
}
|
|
||||||
if (id(LD1125H_Mov_Binary).state == true) {
|
|
||||||
id(LD1125H_Mov_Binary).publish_state(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Number Sensors (custom component)
|
# Number Sensors (custom component)
|
||||||
@@ -382,24 +348,21 @@ number:
|
|||||||
sensor:
|
sensor:
|
||||||
- platform: bme280_i2c
|
- platform: bme280_i2c
|
||||||
temperature:
|
temperature:
|
||||||
name: ${friendly_name} BME280 Temp
|
name: "Temperature"
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
oversampling: 2x
|
oversampling: 2x
|
||||||
pressure:
|
pressure:
|
||||||
name: ${friendly_name} BME280 Pressure
|
name: "Pressure"
|
||||||
oversampling: 2x
|
oversampling: 2x
|
||||||
humidity:
|
humidity:
|
||||||
name: ${friendly_name} BME280 Humidity
|
name: "Humidity"
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
oversampling: 2x
|
oversampling: 2x
|
||||||
address: 0x76
|
address: 0x76
|
||||||
update_interval: ${update_time}
|
update_interval: ${update_interval}
|
||||||
|
|
||||||
- platform: uptime
|
|
||||||
name: ${friendly_name} Uptime
|
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
name: ${friendly_name} LD1125H Distance
|
name: "mmWave Distance"
|
||||||
id: LD1125H_Distance
|
id: LD1125H_Distance
|
||||||
icon: "mdi:signal-distance-variant"
|
icon: "mdi:signal-distance-variant"
|
||||||
unit_of_measurement: "m"
|
unit_of_measurement: "m"
|
||||||
@@ -420,12 +383,15 @@ text_sensor:
|
|||||||
name: ${friendly_name} LD1125H UART Text
|
name: ${friendly_name} LD1125H UART Text
|
||||||
id: LD1125H_UART_Text
|
id: LD1125H_UART_Text
|
||||||
icon: "mdi:format-text"
|
icon: "mdi:format-text"
|
||||||
internal: True #If Don't Want to See UART Receive Data, Set To True
|
internal: True
|
||||||
on_value:
|
on_value:
|
||||||
lambda: |-
|
lambda: |-
|
||||||
if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") {
|
if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") {
|
||||||
id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str()));
|
id(LD1125H_Distance).publish_state(
|
||||||
if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) {
|
atof(id(LD1125H_UART_Text).state.substr(9).c_str())
|
||||||
|
);
|
||||||
|
if ((::time(nullptr) - id(LD1125H_Last_Mov_Time)) >
|
||||||
|
id(LD1125H_Mov_Time).state) {
|
||||||
id(LD1125H_Occupancy).publish_state("Occupancy");
|
id(LD1125H_Occupancy).publish_state("Occupancy");
|
||||||
if (id(LD1125H_MovOcc_Binary).state == false) {
|
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||||
id(LD1125H_MovOcc_Binary).publish_state(true);
|
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||||
@@ -437,13 +403,16 @@ text_sensor:
|
|||||||
if (id(LD1125H_MovOcc_Binary).state == false) {
|
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||||
id(LD1125H_MovOcc_Binary).publish_state(true);
|
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||||
}
|
}
|
||||||
id(LD1125H_Last_Time) = time(NULL);
|
// Update both last-movement and last-anything timestamps
|
||||||
|
id(LD1125H_Last_Time) = ::time(nullptr);
|
||||||
if (id(LD1125H_Clearence_Status) == true) {
|
if (id(LD1125H_Clearence_Status) == true) {
|
||||||
id(LD1125H_Clearence_Status) = false;
|
id(LD1125H_Clearence_Status) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") {
|
else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") {
|
||||||
id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str()));
|
id(LD1125H_Distance).publish_state(
|
||||||
|
atof(id(LD1125H_UART_Text).state.substr(9).c_str())
|
||||||
|
);
|
||||||
id(LD1125H_Occupancy).publish_state("Movement");
|
id(LD1125H_Occupancy).publish_state("Movement");
|
||||||
if (id(LD1125H_MovOcc_Binary).state == false) {
|
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||||
id(LD1125H_MovOcc_Binary).publish_state(true);
|
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||||
@@ -451,14 +420,15 @@ text_sensor:
|
|||||||
if (id(LD1125H_Mov_Binary).state == false) {
|
if (id(LD1125H_Mov_Binary).state == false) {
|
||||||
id(LD1125H_Mov_Binary).publish_state(true);
|
id(LD1125H_Mov_Binary).publish_state(true);
|
||||||
}
|
}
|
||||||
id(LD1125H_Last_Mov_Time) = time(NULL);
|
// Update both movement-specific and general timestamps
|
||||||
id(LD1125H_Last_Time) = time(NULL);
|
id(LD1125H_Last_Mov_Time) = ::time(nullptr);
|
||||||
|
id(LD1125H_Last_Time) = ::time(nullptr);
|
||||||
if (id(LD1125H_Clearence_Status) == true) {
|
if (id(LD1125H_Clearence_Status) == true) {
|
||||||
id(LD1125H_Clearence_Status) = false;
|
id(LD1125H_Clearence_Status) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- platform: template
|
- platform: template
|
||||||
name: ${friendly_name} LD1125H Occupancy Status
|
name: "mmWave Occupancy"
|
||||||
id: LD1125H_Occupancy
|
id: LD1125H_Occupancy
|
||||||
icon: "mdi:motion-sensor"
|
icon: "mdi:motion-sensor"
|
||||||
|
|
||||||
@@ -467,13 +437,11 @@ text_sensor:
|
|||||||
# https://esphome.io/components/binary_sensor/index.html
|
# https://esphome.io/components/binary_sensor/index.html
|
||||||
#############################################
|
#############################################
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: status
|
|
||||||
name: ${friendly_name} Status
|
|
||||||
- platform: template
|
- platform: template
|
||||||
name: ${friendly_name} LD1125H Occupancy or Movement
|
name: "mmWave Occupancy or Movement"
|
||||||
id: LD1125H_MovOcc_Binary
|
id: LD1125H_MovOcc_Binary
|
||||||
device_class: occupancy
|
device_class: occupancy
|
||||||
- platform: template
|
- platform: template
|
||||||
name: ${friendly_name} LD1125H Movement
|
name: "mmWave Movement"
|
||||||
id: LD1125H_Mov_Binary
|
id: LD1125H_Mov_Binary
|
||||||
device_class: motion
|
device_class: motion
|
@@ -12,33 +12,45 @@
|
|||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# VARIABLE SUBSTITUTIONS
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
# Give the device a useful name & description here
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
# and change values accordingly.
|
|
||||||
#############################################
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
devicename: "esp-occupancystair"
|
devicename: "esp-occupancystair"
|
||||||
friendly_name: "Stair Occupancy and Underhouse Environment"
|
friendly_name: "Stair Occupancy and Underhouse Environment"
|
||||||
description_comment: "D1 Mini ESP32 with LD2410 mmWave for internal stairwell and environment sensors for under house"
|
description_comment: "D1 Mini ESP32 with LD2410 mmWave for internal stairwell and environment sensors for under house"
|
||||||
api_key: !secret esp-occupancystair_api_key #unfortunately you can't use substitutions in secrets names
|
api_key: !secret esp-occupancystair_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-occupancystair_ota_pass #unfortunately you can't use substitutions in secrets names
|
ota_pass: !secret esp-occupancystair_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
wifi_ssid: !secret wifi_ssid
|
static_ip_address: !secret esp-occupancystair_ip
|
||||||
wifi_password: !secret wifi_password
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
fallback_ap_password: !secret fallback_ap_password
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
#Add these if we are giving it a static ip, or remove them in the Wifi section
|
room: "Outside" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
#static_ip_address: !secret esp-occupancystair_static_ip
|
|
||||||
#static_ip_gateway: !secret esp-occupancystair_gateway
|
|
||||||
#static_ip_subnet: !secret esp-occupancystair_subnet
|
|
||||||
|
|
||||||
mqtt_server: !secret mqtt_server
|
#############################################
|
||||||
mqtt_username: !secret mqtt_username
|
# Included Common Packages
|
||||||
mqtt_password: !secret mqtt_password
|
# https://esphome.io/components/esphome.html
|
||||||
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
|
#############################################
|
||||||
|
packages:
|
||||||
#web_server_username: !secret web_server_username
|
common_wifi: !include
|
||||||
#web_server_password: !secret web_server_password
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
update_time: 30s #update time for for general temp sensors etc
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
common_webportal: !include
|
||||||
|
file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# ESPHome
|
# ESPHome
|
||||||
@@ -49,6 +61,7 @@ esphome:
|
|||||||
friendly_name: ${friendly_name}
|
friendly_name: ${friendly_name}
|
||||||
comment: ${description_comment} #appears on the esphome page in HA
|
comment: ${description_comment} #appears on the esphome page in HA
|
||||||
min_version: 2024.6.0
|
min_version: 2024.6.0
|
||||||
|
area: "${room}"
|
||||||
#on_boot: #Initial Setting, will remember previous values (if set)
|
#on_boot: #Initial Setting, will remember previous values (if set)
|
||||||
#priority: -200
|
#priority: -200
|
||||||
#then:
|
#then:
|
||||||
@@ -84,75 +97,6 @@ logger:
|
|||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${api_key}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- platform: esphome
|
|
||||||
password: ${ota_pass}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Safe Mode
|
|
||||||
# Safe mode will detect boot loops
|
|
||||||
# https://esphome.io/components/safe_mode
|
|
||||||
#############################################
|
|
||||||
safe_mode:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Wifi Settings
|
|
||||||
# https://esphome.io/components/wifi.html
|
|
||||||
#
|
|
||||||
# Power Save mode (can reduce wifi reliability)
|
|
||||||
# NONE (least power saving, Default for ESP8266)
|
|
||||||
# LIGHT (Default for ESP32)
|
|
||||||
# HIGH (most power saving)
|
|
||||||
#############################################
|
|
||||||
wifi:
|
|
||||||
ssid: ${wifi_ssid}
|
|
||||||
password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
#manual_ip: #optional static IP address
|
|
||||||
#static_ip: ${static_ip_address}
|
|
||||||
#gateway: ${static_ip_gateway}
|
|
||||||
#subnet: ${static_ip_subnet}
|
|
||||||
ap: #Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
|
|
||||||
ssid: ${devicename} fallback AP
|
|
||||||
password: ${fallback_ap_password}
|
|
||||||
ap_timeout: 30min #Time until it brings up fallback AP. default is 1min
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Web Portal for display and monitoring
|
|
||||||
# Turning this off is probably a good idea to save resources.
|
|
||||||
# https://esphome.io/components/web_server.html
|
|
||||||
#############################################
|
|
||||||
#web_server:
|
|
||||||
# port: 80
|
|
||||||
# auth:
|
|
||||||
# username: ${web_server_username} #probably a good idea to secure it
|
|
||||||
# password: ${web_server_password}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: false # enable entity discovery (true is default)
|
|
||||||
#discover_ip: True # enable device discovery (true is default)
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# Bluetooth
|
# Bluetooth
|
||||||
# https://esphome.io/components/bluetooth_proxy.html
|
# https://esphome.io/components/bluetooth_proxy.html
|
||||||
@@ -315,79 +259,78 @@ select:
|
|||||||
sensor:
|
sensor:
|
||||||
- platform: bme280_i2c
|
- platform: bme280_i2c
|
||||||
temperature:
|
temperature:
|
||||||
name: ${friendly_name} BME280 Temp
|
name: "Temperature"
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
oversampling: 2x
|
oversampling: 2x
|
||||||
pressure:
|
pressure:
|
||||||
name: ${friendly_name} BME280 Pressure
|
name: "Pressure"
|
||||||
oversampling: 2x
|
oversampling: 2x
|
||||||
humidity:
|
humidity:
|
||||||
name: ${friendly_name} BME280 Humidity
|
name: "Humidity"
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
oversampling: 2x
|
oversampling: 2x
|
||||||
address: 0x76
|
address: 0x76
|
||||||
update_interval: ${update_time}
|
update_interval: ${update_interval}
|
||||||
- platform: uptime
|
|
||||||
name: ${friendly_name} Uptime
|
|
||||||
#The ld2410 sensor values
|
#The ld2410 sensor values
|
||||||
- platform: ld2410
|
- platform: ld2410
|
||||||
light:
|
light:
|
||||||
name: Light
|
name: "Light"
|
||||||
moving_distance:
|
moving_distance:
|
||||||
name : Moving Distance
|
name: "Moving Distance"
|
||||||
still_distance:
|
still_distance:
|
||||||
name: Still Distance
|
name: "Still Distance"
|
||||||
moving_energy:
|
moving_energy:
|
||||||
name: Move Energy
|
name: "Move Energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: Still Energy
|
name: "Still Energy"
|
||||||
detection_distance:
|
detection_distance:
|
||||||
name: Detection Distance
|
name: "Detection Distance"
|
||||||
g0:
|
g0:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g0 move energy
|
name: "g0 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g0 still energy
|
name: "g0 still energy"
|
||||||
g1:
|
g1:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g1 move energy
|
name: "g1 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g1 still energy
|
name: "g1 still energy"
|
||||||
g2:
|
g2:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g2 move energy
|
name: "g2 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g2 still energy
|
name: "g2 still energy"
|
||||||
g3:
|
g3:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g3 move energy
|
name: "g3 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g3 still energy
|
name: "g3 still energy"
|
||||||
g4:
|
g4:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g4 move energy
|
name: "g4 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g4 still energy
|
name: "g4 still energy"
|
||||||
g5:
|
g5:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g5 move energy
|
name: "g5 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g5 still energy
|
name: "g5 still energy"
|
||||||
g6:
|
g6:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g6 move energy
|
name: "g6 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g6 still energy
|
name: "g6 still energy"
|
||||||
g7:
|
g7:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g7 move energy
|
name: "g7 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g7 still energy
|
name: "g7 still energy"
|
||||||
g8:
|
g8:
|
||||||
move_energy:
|
move_energy:
|
||||||
name: g8 move energy
|
name: "g8 move energy"
|
||||||
still_energy:
|
still_energy:
|
||||||
name: g8 still energy
|
name: "g8 still energy"
|
||||||
|
|
||||||
# The ld2410 switch allows you to control your LD2410 Sensor.
|
# The ld2410 switch allows you to control your LD2410 Sensor.
|
||||||
#Bluetooth switch is only useful of you have a B or C model
|
#Bluetooth switch is only useful of you have a B or C model
|
||||||
@@ -402,13 +345,14 @@ switch:
|
|||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: ld2410
|
- platform: ld2410
|
||||||
has_target:
|
has_target:
|
||||||
name: ${friendly_name} Presence
|
name: "mmWave Presence"
|
||||||
has_moving_target:
|
has_moving_target:
|
||||||
name: ${friendly_name} Moving Target
|
name: "mmWave Moving Target"
|
||||||
has_still_target:
|
has_still_target:
|
||||||
name: ${friendly_name} Still Target
|
name: "mmWave Still Target"
|
||||||
out_pin_presence_status:
|
out_pin_presence_status:
|
||||||
name: ${friendly_name} LD2140 Out Pin Presence Status
|
name: "LD2140 Out Pin Presence Status"
|
||||||
|
entity_category: diagnostic
|
||||||
|
|
||||||
#Standard PIR Sensor
|
#Standard PIR Sensor
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -418,7 +362,7 @@ binary_sensor:
|
|||||||
input: true
|
input: true
|
||||||
pullup: true
|
pullup: true
|
||||||
inverted: true
|
inverted: true
|
||||||
name: ${friendly_name} PIR Sensor
|
name: "PIR Sensor"
|
||||||
device_class: motion
|
device_class: motion
|
||||||
|
|
||||||
#The ld2410 button allows resetting
|
#The ld2410 button allows resetting
|
||||||
|
242
esphome/esp-poolpumppower.yaml
Normal file
242
esphome/esp-poolpumppower.yaml
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# Athom Smart Plug Power Monitor ESP32-C3
|
||||||
|
#
|
||||||
|
# based on https://github.com/athom-tech/esp32-configs/blob/main/athom-smart-plug.yaml
|
||||||
|
#
|
||||||
|
# SUMMARY
|
||||||
|
# Smart plug with power monitoring.
|
||||||
|
#
|
||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
substitutions:
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
#############################################
|
||||||
|
devicename: "esp-poolpumppower"
|
||||||
|
friendly_name: "Pool Pump Power"
|
||||||
|
description_comment: "Pool Pump Power, Athom Smart Plug Power Monitor"
|
||||||
|
api_key: !secret esp-poolpumppower_api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-poolpumppower_ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-poolpumppower_ip
|
||||||
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "10s" # update time for for general sensors etc
|
||||||
|
room: "Outside" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||||
|
#############################################
|
||||||
|
project_name: "Athom Technology.Smart Plug V3" # Project Details
|
||||||
|
project_version: "v1.0.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
current_limit : "10" # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: ${static_ip_address}
|
||||||
|
local_ota_pass: ${ota_pass}
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: ${api_key}
|
||||||
|
# common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: ${friendly_name}
|
||||||
|
local_update_interval: ${update_interval}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
#############################################
|
||||||
|
esphome:
|
||||||
|
name: ${devicename}
|
||||||
|
friendly_name: ${friendly_name}
|
||||||
|
comment: ${description_comment} #Appears on the esphome page in HA
|
||||||
|
area: "${room}"
|
||||||
|
name_add_mac_suffix: False
|
||||||
|
min_version: 2024.6.0
|
||||||
|
project:
|
||||||
|
name: "${project_name}"
|
||||||
|
version: "${project_version}"
|
||||||
|
platformio_options:
|
||||||
|
board_build.mcu: esp32c3
|
||||||
|
board_build.variant: esp32c3
|
||||||
|
board_build.flash_mode: dio
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
#############################################
|
||||||
|
esp32:
|
||||||
|
board: esp32-c3-devkitm-1
|
||||||
|
flash_size: 4MB
|
||||||
|
variant: ESP32C3
|
||||||
|
framework:
|
||||||
|
type: arduino
|
||||||
|
version: recommended
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
flash_write_interval: 5min
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
#############################################
|
||||||
|
logger:
|
||||||
|
level: ${log_level} #INFO Level suggested, or DEBUG for testing
|
||||||
|
baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
esp32_improv:
|
||||||
|
authorizer: none
|
||||||
|
|
||||||
|
dashboard_import:
|
||||||
|
package_import_url: github://athom-tech/esp32-configs/athom-smart-plug.yaml
|
||||||
|
|
||||||
|
uart:
|
||||||
|
rx_pin: GPIO20
|
||||||
|
baud_rate: 4800
|
||||||
|
data_bits: 8
|
||||||
|
stop_bits: 1
|
||||||
|
parity: EVEN
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: total_energy
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '0.0'
|
||||||
|
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO3
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
name: "Power Button"
|
||||||
|
id: power_button
|
||||||
|
filters:
|
||||||
|
- delayed_on: 20ms
|
||||||
|
on_click:
|
||||||
|
- switch.toggle: relay
|
||||||
|
- platform: template
|
||||||
|
name: "Relay Status"
|
||||||
|
lambda: |-
|
||||||
|
return id(relay).state;
|
||||||
|
|
||||||
|
status_led:
|
||||||
|
pin: GPIO06
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: "Power Output"
|
||||||
|
pin: GPIO5
|
||||||
|
id: relay
|
||||||
|
restore_mode: RESTORE_DEFAULT_OFF # Ensures the relay is restored (or off) at boot
|
||||||
|
#internal: true # Hides the switch from Home Assistant
|
||||||
|
icon: "mdi:power-socket-au"
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: cse7766
|
||||||
|
id: athom_cse7766
|
||||||
|
|
||||||
|
current:
|
||||||
|
name: "Current"
|
||||||
|
icon: mdi:current-ac
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${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"
|
||||||
|
icon: mdi:sine-wave
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
power:
|
||||||
|
name: "Power"
|
||||||
|
id: power_sensor
|
||||||
|
icon: mdi:power
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${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
|
||||||
|
|
||||||
|
energy:
|
||||||
|
name: "Energy"
|
||||||
|
id: energy
|
||||||
|
icon: mdi:lightning-bolt
|
||||||
|
unit_of_measurement: kWh
|
||||||
|
filters:
|
||||||
|
- throttle: ${update_interval}
|
||||||
|
# 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();
|
||||||
|
|
||||||
|
apparent_power:
|
||||||
|
name: "Apparent Power"
|
||||||
|
icon: mdi:power
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
reactive_power:
|
||||||
|
name: "Reactive Power"
|
||||||
|
icon: mdi:flash
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
power_factor:
|
||||||
|
name: "Power Factor"
|
||||||
|
icon: mdi:percent-outline
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
|
- 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: ${update_interval}
|
||||||
|
|
||||||
|
- platform: total_daily_energy
|
||||||
|
name: "Total Daily Energy"
|
||||||
|
restore: true
|
||||||
|
power_id: power_sensor
|
||||||
|
unit_of_measurement: kWh
|
||||||
|
icon: mdi:hours-24
|
||||||
|
accuracy_decimals: 3
|
||||||
|
filters:
|
||||||
|
- multiply: 0.001
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,25 +1,24 @@
|
|||||||
automation:
|
automation:
|
||||||
|
# Automation to turn on the heat pump at 9pm in the master bedroom (if switched on with the helper)
|
||||||
# Automation to turn on drying at 9pm in the master bedroom (if switched on ith the helper)
|
|
||||||
- id: master_bedroom_offpeak_dehumidify
|
- id: master_bedroom_offpeak_dehumidify
|
||||||
alias: Master Bedroom Off-Peak Dehumidify
|
alias: Master Bedroom Off-Peak Dehumidify
|
||||||
mode: single
|
mode: single
|
||||||
trigger:
|
triggers:
|
||||||
- platform: time
|
- trigger: time
|
||||||
at: "21:20:00"
|
at: "21:00:00"
|
||||||
condition:
|
conditions:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: input_boolean.master_bedroom_offpeak_dehumidify
|
entity_id: input_boolean.master_bedroom_offpeak_dehumidify
|
||||||
state: "on"
|
state: "on"
|
||||||
action:
|
actions:
|
||||||
- service: climate.set_hvac_mode
|
- action: climate.set_hvac_mode
|
||||||
target:
|
target:
|
||||||
entity_id: climate.master_bedroom
|
entity_id: climate.master_bedroom
|
||||||
data:
|
data:
|
||||||
hvac_mode: auto
|
hvac_mode: "heat_cool"
|
||||||
- wait_for_trigger:
|
- wait_for_trigger:
|
||||||
- platform: time
|
- trigger: time
|
||||||
at: "00:00:00"
|
at: "00:00:00"
|
||||||
- service: climate.turn_off
|
- action: climate.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id: climate.master_bedroom
|
entity_id: climate.master_bedroom
|
Reference in New Issue
Block a user