laundry esphome migration
This commit is contained in:
@@ -17,35 +17,51 @@
|
||||
#############################################
|
||||
|
||||
#############################################
|
||||
# VARIABLE SUBSTITUTIONS
|
||||
# Give the device a useful name & description here
|
||||
# and change values accordingly.
|
||||
# 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"
|
||||
|
||||
#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
|
||||
ota_pass: !secret esp-occupancyoffice_ota_pass #unfortunately you can't use substitutions inside secrets names
|
||||
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-occupancyoffice_static_ip
|
||||
#static_ip_gateway: !secret esp-occupancyoffice_gateway
|
||||
#static_ip_subnet: !secret esp-occupancyoffice_subnet
|
||||
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.
|
||||
|
||||
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
|
||||
#############################################
|
||||
# SPECIFIC PROJECT VARIABLE SUBSTITUTIONS
|
||||
#############################################
|
||||
#
|
||||
#
|
||||
|
||||
#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
|
||||
@@ -56,6 +72,7 @@ esphome:
|
||||
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:
|
||||
@@ -107,7 +124,7 @@ external_components:
|
||||
# https://esphome.io/components/logger.html
|
||||
#############################################
|
||||
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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
@@ -119,72 +136,13 @@ logger:
|
||||
api:
|
||||
encryption:
|
||||
key: ${api_key}
|
||||
#key: "puCd6EGmFp3hU56N8dOo5u17bXwDr0aVRWiDoNdPDoE="
|
||||
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: ${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
|
||||
type: time_t
|
||||
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
|
||||
type: time_t
|
||||
restore_value: no
|
||||
initial_value: time(NULL)
|
||||
#initial_value: time(NULL)
|
||||
#initial_value: !lambda 'return ::time(nullptr);'
|
||||
initial_value: "0"
|
||||
- id: LD1125H_Clearence_Status
|
||||
type: bool
|
||||
restore_value: no
|
||||
@@ -264,22 +226,26 @@ status_led:
|
||||
# https://esphome.io/guides/automations.html
|
||||
#############################################
|
||||
interval:
|
||||
- interval: 1s #Clearance Scan Time
|
||||
- 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;
|
||||
- lambda: |-
|
||||
// Use the global C time() function (::time(nullptr))
|
||||
if ((::time(nullptr) - 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);
|
||||
}
|
||||
// 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)
|
||||
@@ -382,24 +348,21 @@ number:
|
||||
sensor:
|
||||
- platform: bme280_i2c
|
||||
temperature:
|
||||
name: ${friendly_name} BME280 Temp
|
||||
name: "Temperature"
|
||||
accuracy_decimals: 1
|
||||
oversampling: 2x
|
||||
pressure:
|
||||
name: ${friendly_name} BME280 Pressure
|
||||
name: "Pressure"
|
||||
oversampling: 2x
|
||||
humidity:
|
||||
name: ${friendly_name} BME280 Humidity
|
||||
name: "Humidity"
|
||||
accuracy_decimals: 1
|
||||
oversampling: 2x
|
||||
address: 0x76
|
||||
update_interval: ${update_time}
|
||||
update_interval: ${update_interval}
|
||||
|
||||
- platform: uptime
|
||||
name: ${friendly_name} Uptime
|
||||
|
||||
- platform: template
|
||||
name: ${friendly_name} LD1125H Distance
|
||||
name: "mmWave Distance"
|
||||
id: LD1125H_Distance
|
||||
icon: "mdi:signal-distance-variant"
|
||||
unit_of_measurement: "m"
|
||||
@@ -420,12 +383,15 @@ text_sensor:
|
||||
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
|
||||
internal: 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_Distance).publish_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");
|
||||
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||
id(LD1125H_MovOcc_Binary).publish_state(true);
|
||||
@@ -437,13 +403,16 @@ text_sensor:
|
||||
if (id(LD1125H_MovOcc_Binary).state == false) {
|
||||
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) {
|
||||
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_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);
|
||||
@@ -451,14 +420,15 @@ text_sensor:
|
||||
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);
|
||||
// Update both movement-specific and general timestamps
|
||||
id(LD1125H_Last_Mov_Time) = ::time(nullptr);
|
||||
id(LD1125H_Last_Time) = ::time(nullptr);
|
||||
if (id(LD1125H_Clearence_Status) == true) {
|
||||
id(LD1125H_Clearence_Status) = false;
|
||||
}
|
||||
}
|
||||
- platform: template
|
||||
name: ${friendly_name} LD1125H Occupancy Status
|
||||
name: "mmWave Occupancy"
|
||||
id: LD1125H_Occupancy
|
||||
icon: "mdi:motion-sensor"
|
||||
|
||||
@@ -467,13 +437,11 @@ text_sensor:
|
||||
# https://esphome.io/components/binary_sensor/index.html
|
||||
#############################################
|
||||
binary_sensor:
|
||||
- platform: status
|
||||
name: ${friendly_name} Status
|
||||
- platform: template
|
||||
name: ${friendly_name} LD1125H Occupancy or Movement
|
||||
name: "mmWave Occupancy or Movement"
|
||||
id: LD1125H_MovOcc_Binary
|
||||
device_class: occupancy
|
||||
- platform: template
|
||||
name: ${friendly_name} LD1125H Movement
|
||||
name: "mmWave Movement"
|
||||
id: LD1125H_Mov_Binary
|
||||
device_class: motion
|
Reference in New Issue
Block a user