Compare commits

...

2 Commits

Author SHA1 Message Date
root
29c092232b weather station esphome updates 2024-06-02 18:49:57 +12:00
root
9467d25271 weather station esphome updates 2024-06-02 18:46:17 +12:00
9 changed files with 411 additions and 913 deletions

View File

@@ -128,6 +128,14 @@ mqtt:
payload: 'ON' payload: 'ON'
then: then:
- deep_sleep.enter: deep_sleep_1 - deep_sleep.enter: deep_sleep_1
- topic: viewroad-commands/attobat/deepsleep
payload: 'OFF'
then:
- deep_sleep.prevent: deep_sleep_1
- topic: viewroad-commands/attobat/deepsleep
payload: 'ON'
then:
- deep_sleep.enter: deep_sleep_1
######################################## ########################################
# Deep Sleep # Deep Sleep

131
esphome/esp-btproxy1.yaml Normal file
View File

@@ -0,0 +1,131 @@
#############################################
#############################################
#
#############################################
#############################################
#############################################
# Variable Substitutions
#############################################
substitutions:
devicename: "esp-btproxy1"
friendly_name: "BT Proxy 1"
description_comment: "D1 Mini ESP32 with BT Proxy Test"
api_key: !secret esp-btproxy1_api_key #unfortunately you can't use substitutions in secrets names
ota_pass: !secret esp-btproxy1_ota_pass #unfortunately you can't use substitutions in secrets names
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
update_time: 30s #update time for for temp sensors etc
#############################################
# ESPHome
# https://esphome.io/components/esphome.html
#############################################
esphome:
name: ${devicename}
comment: ${description_comment} #appears on the esphome page in HA
#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
#############################################
# 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:
safe_mode: true #Safe mode will detect boot loops
password: ${ota_pass}
#############################################
# Wifi Settings
# https://esphome.io/components/wifi.html
#############################################
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
#manual_ip: #optional static IP address
#static_ip: 192.168.x.x
#gateway: 192.168.X.x
#subnet: 255.255.255.0
ap: #Details for fallback hotspot (captive portal) 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 #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
# username: !secret web_server_username #probably a good idea to secure it
# password: !secret web_server_password
#############################################
# MQTT Monitoring
# https://esphome.io/components/mqtt.html?highlight=mqtt
# MUST also have api enabled if you enable MQTT
#############################################
mqtt:
broker: !secret mqtt_server
topic_prefix: ${mqtt_topic}/${devicename}
username: !secret mqtt_username
password: !secret mqtt_password
#############################################
# 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
esp32_ble_tracker:
#############################################
# 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

View File

@@ -1,11 +1,31 @@
#############################################
#############################################
# HiLink LD1125H mmWave sensor, with BME280 Temp/Hum/Pres Sensor 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
#
# 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
#
#############################################
#############################################
############################################# #############################################
# Variable Substitutions # Variable Substitutions
############################################# #############################################
substitutions: substitutions:
devicename: "esp-mmwaveoffice-7776ec" devicename: "esp-occupancylaundry"
friendly_name: "Office Occupancy" friendly_name: "Laundry Occupancy"
mqtt_topic: "esphome" description_comment: "D1 Mini ESP32 with LD1125H mmWave and environment sensors for laundry"
update_time: 30s #for temp sensors etc api_key: !secret esp-occupancylaundry_api_key #unfortunately you can't use substitutions in secrets names
ota_pass: !secret esp-occupancylaundry_ota_pass #unfortunately you can't use substitutions in secrets names
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
update_time: 30s #update time for for temp sensors etc
############################################# #############################################
# ESPHome # ESPHome
@@ -13,8 +33,8 @@ substitutions:
############################################# #############################################
esphome: esphome:
name: ${devicename} name: ${devicename}
comment: D1 Mini ESP32 with mmWave and environment sensors for main office #appears on the esphome page in HA comment: ${description_comment} #appears on the esphome page in HA
on_boot: #LD1125H Initial Setting on_boot: #LD1125H Initial Setting, will remember previous values (if set)
priority: -200 priority: -200
then: then:
- uart.write: - uart.write:
@@ -43,10 +63,11 @@ esphome:
# https://esphome.io/components/esp32.html # https://esphome.io/components/esp32.html
############################################# #############################################
esp32: esp32:
board: nodemcu-32s #board: nodemcu-32s
board: esp32dev
framework: framework:
type: arduino #type: arduino
#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
############################################# #############################################
@@ -75,7 +96,7 @@ external_components:
############################################# #############################################
logger: logger:
level: INFO #INFO Level suggested, or DEBUG for testing 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) #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
@@ -85,16 +106,15 @@ logger:
############################################# #############################################
api: api:
encryption: encryption:
key: !secret esp-mmwaveoffice_api_key key: ${api_key}
############################################# #############################################
# Enable Over the Air Update Capability # Enable Over the Air Update Capability
# Safe mode will detect boot loops
# https://esphome.io/components/ota.html?highlight=ota # https://esphome.io/components/ota.html?highlight=ota
############################################# #############################################
ota: ota:
safe_mode: true safe_mode: true #Safe mode will detect boot loops
password: !secret esp-mmwaveoffice_ota_pass password: ${ota_pass}
############################################# #############################################
# Wifi Settings # Wifi Settings
@@ -104,22 +124,23 @@ wifi:
ssid: !secret wifi_ssid ssid: !secret wifi_ssid
password: !secret wifi_password password: !secret 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: #manual_ip: #optional static IP address
#static_ip: 192.168.x.x #static_ip: 192.168.x.x
#gateway: 192.168.X.x #gateway: 192.168.X.x
#subnet: 255.255.255.0 #subnet: 255.255.255.0
#ap: #Details for fallback hotspot (captive portal) in case wifi connection fails ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
#ssid: "? Fallback Hotspot" ssid: $devicename fallback AP
#password: !secret fallback_ap_password password: !secret fallback_ap_password
ap_timeout: 5min #default is 1min
############################################# #############################################
# Web Portal for display and monitoring # Web Portal for display and monitoring
# Turning this off is probably a good idea to save resources. # Turning this off is probably a good idea to save resources.
# https://esphome.io/components/web_server.html # https://esphome.io/components/web_server.html
############################################# #############################################
web_server: #web_server:
port: 80 # port: 80
# username: !secret web_server_username # username: !secret web_server_username #probably a good idea to secure it
# password: !secret web_server_password # password: !secret web_server_password
############################################# #############################################
@@ -133,6 +154,22 @@ mqtt:
username: !secret mqtt_username username: !secret mqtt_username
password: !secret mqtt_password password: !secret mqtt_password
#############################################
# 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.
#############################################
#esp32_ble_tracker:
#bluetooth_proxy:
#active: true
############################################# #############################################
# UART Serial # UART Serial
# hardware on EPS32, but software, and can be glitchy on ESP8266 # hardware on EPS32, but software, and can be glitchy on ESP8266
@@ -181,6 +218,7 @@ globals:
status_led: status_led:
pin: pin:
number: GPIO2 #ESP32 Onboard LED 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 inverted: false
############################################# #############################################

View File

@@ -138,8 +138,8 @@ wifi:
# Turning this off is probably a good idea to save resources. # Turning this off is probably a good idea to save resources.
# https://esphome.io/components/web_server.html # https://esphome.io/components/web_server.html
############################################# #############################################
web_server: #web_server:
port: 80 # port: 80
# username: !secret web_server_username #probably a good idea to secure it # username: !secret web_server_username #probably a good idea to secure it
# password: !secret web_server_password # password: !secret web_server_password
@@ -165,6 +165,7 @@ mqtt:
# partition setup. # partition setup.
############################################# #############################################
#bluetooth_proxy: #bluetooth_proxy:
# active: true
#esp32_ble_tracker: #esp32_ble_tracker:

View File

@@ -276,13 +276,13 @@ number:
select: select:
- platform: ld2410 - platform: ld2410
distance_resolution: distance_resolution:
name: "distance resolution" name: ${friendly_name} LD2140 Distance Resolution
baud_rate: baud_rate:
name: "baud rate" name: ${friendly_name} LD2140 Baud Rate
light_function: light_function:
name: light function name: ${friendly_name} LD2140 Light Function
out_pin_level: out_pin_level:
name: out pin level name: ${friendly_name} LD2140 Out Pin Level
############################################# #############################################
# General Sensors # General Sensors
@@ -369,29 +369,40 @@ sensor:
switch: switch:
- platform: ld2410 - platform: ld2410
engineering_mode: engineering_mode:
name: "Engineering Mode" name: ${friendly_name} LD2140 Engineering Mode
bluetooth: bluetooth:
name: "Control Bluetooth" name: ${friendly_name} LD2140 Control Bluetooth
#The ld2410 binary sensors to get presence notification #The ld2410 binary sensors to get presence notification
binary_sensor: binary_sensor:
- platform: ld2410 - platform: ld2410
has_target: has_target:
name: Presence name: ${friendly_name} Presence
has_moving_target: has_moving_target:
name: Moving Target name: ${friendly_name} Moving Target
has_still_target: has_still_target:
name: Still Target name: ${friendly_name} Still Target
out_pin_presence_status: out_pin_presence_status:
name: 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 #The ld2410 button allows resetting
button: button:
- platform: ld2410 - platform: ld2410
factory_reset: factory_reset:
name: "Factory reset" name: ${friendly_name} LD2140 Factory reset"
restart: restart:
name: "Restart" name: ${friendly_name} LD2140 Restart
query_params: query_params:
name: Query Parameters name: Query Parameters
@@ -399,6 +410,8 @@ button:
text_sensor: text_sensor:
- platform: ld2410 - platform: ld2410
version: version:
name: "Firmware Version" name: ${friendly_name} LD2140 Firmware Version
mac_address: mac_address:
name: "MAC Address" name: ${friendly_name} LD2140 BT MAC Address

View File

@@ -6,6 +6,7 @@
# zorruno 2024-05-23 V1.0 Tidied up sensor info and added BMP280 # zorruno 2024-05-23 V1.0 Tidied up sensor info and added BMP280
# zorruno 2024-05-24 V1.1 Tested ok and added some V calibration for mine # zorruno 2024-05-24 V1.1 Tested ok and added some V calibration for mine
# zorruno 2024-05-25 V2 A bunch more sensors added (wind direction not yet sorted) # zorruno 2024-05-25 V2 A bunch more sensors added (wind direction not yet sorted)
# zorruno 2024-05-25 V3 Shuffled some sensors, rain count added
############################################# #############################################
############################################# #############################################
@@ -19,46 +20,58 @@
# battery voltage (adc A0) # battery voltage (adc A0)
# #
# ads1115: 4 Channel A->D (0x48 i2c) # ads1115: 4 Channel A->D (0x48 i2c)
# dht: DHT22 Temp/Humidity, Remote (GPIO15) # dht: DHT22 Temp/Humidity, Remote (GPIO13)
# bmp280: Temp/pressure on the board (0x76 i2c) # bmp280: Temp/pressure on the board (0x76 i2c)
# pulse_meter: Wind Speed (GPIO13) # pulse_meter: Wind Speed (GPIO14)
# # pulse_meter: Rainfall (GPIO12)
# text_sensor: Beaufort Wind Scale Labelling # text_sensor: Beaufort Wind Scale Labelling
# text:sensor: Temp (av) Average of all temps # text_sensor: Temp (av) Average of all temps
# #
# TO TEST (HAVE SENSOR or doesn't need one) # TO TEST (HAVE SENSOR or doesn't need one)
# tsl2561: Ambient Light sensor (0x39 i2c) # tsl2561: Ambient Light sensor (0x39 i2c)
# ads1115 A1_GND: UV Index # ads1115 A1_GND: UV Index
# ads1115 A0_GND: Wind Direction # ads1115 A0_GND: Wind Direction
# pulse_meter: Rainfall (GPIO??) #
# battery life: Time from battery starting to drop (retain) # Battery Calcs:
# template: Last 20mins battery MAX
# template: battery now - max (discharge/charge)
# template binary: discharging, charging, stable
# #
# ORDERED BUT DON'T HAVE YET # ORDERED BUT DON'T HAVE YET
# ltr390: Ambient Light and UV sensor (0x53 i2c) # ltr390: Ambient Light and UV sensor (0x53 i2c)
# pmsx003: PM Particulate Filter (UART) # pmsx003: PM Particulate Filter (UART)
# AS3935: lightning sensor (i2c, but needs design)
# #
# NOT USED (code commented) # NOT USED (code commented)
# bme280_i2c: Temp/humid/press (not used) # bme280_i2c: Temp/humid/press (not used)
# #
# POSSIBLY ADD # POSSIBLY ADD
# Analogue for Solar V? # Analogue for Solar V?
# Lightning?
# ground movement/earthquake? # ground movement/earthquake?
# water sensor (rain now) # water sensor (rain now)
# #
############################################# #############################################
############################################# #############################################
# WIND SENSOR # WEMOS D1 Mini GPIO, and Weather station Use
# looks like this one
# https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf
############################################# #############################################
# PIN HEADERS ON Weatherstation board:
############################################# # D1, GPIO5 Used as SCL (I2C)
# USEFUL LINKS # D2, GPIO4 Used as SDA (I2C)
# Wind Sensing # D3, GPIO0 connected to FLASH button, boot fails if pulled LOW
# https://community.home-assistant.io/t/measuring-wind-speed/395693/20 # D4, GPIO2 connected to on-board LED, boot fails if pulled LOW
# https://community.home-assistant.io/t/measuring-wind-speed/395693/21 # D5, GPIO14 Used as Wind Speed Count
# D6, GPIO12 Used as Rainfall count
# D7, GPIO13 Used for DHT
# D8, GPIO15 (Boot fails if pulled HIGH)
#
# NO HEADERS ON Weatherstation board:
# D0, GPIO16, (used to wake up from deep sleep)
# RX, GPIO3 (HIGH at boot)
# TX, GPIO1 (HIGH at boot, boot fails if pulled LOW)
# A0, ADC0 Used here to measure battery V
#
############################################# #############################################
############################################# #############################################
@@ -79,13 +92,18 @@ substitutions:
devicename: "esp-weatherstation" devicename: "esp-weatherstation"
friendly_name: "Weather Station" friendly_name: "Weather Station"
description_comment: "Opengreen energy board, with BME280 Temp/Hum/Pres Sensor on an ESP8266 D1 Mini" description_comment: "Opengreen energy board, with BME280 Temp/Hum/Pres Sensor on an ESP8266 D1 Mini"
#if NOT using a secrets file, just replace these with the passwords etc in speech marks
api_key: !secret esp-weatherstation_api_key #unfortunately you can't use substitutions in secrets names api_key: !secret esp-weatherstation_api_key #unfortunately you can't use substitutions in secrets names
ota_pass: !secret esp-weatherstation_ota_pass #unfortunately you can't use substitutions in secrets names ota_pass: !secret esp-weatherstation_ota_pass #unfortunately you can't use substitutions in secrets names
wifi_ssid: !secret wifi_ssid wifi_ssid: !secret wifi_ssid
wifi_pass: !secret wifi_password wifi_pass: !secret wifi_password
mqtt_server: 192.168.3.200 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 mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
update_time: 30s #update time for for temp sensors etc update_time: 30s #update time for for various temp sensors etc
############################################# #############################################
# ESPHome # ESPHome
@@ -177,8 +195,8 @@ wifi:
# and not compile, or it will crash occasionally) # and not compile, or it will crash occasionally)
# https://esphome.io/components/web_server.html # https://esphome.io/components/web_server.html
############################################# #############################################
#web_server: web_server:
# port: 80 port: 80
# version: 1 #V1 occasionally works better, V2 The nicer page # version: 1 #V1 occasionally works better, V2 The nicer page
# username: !secret web_server_username #probably a good idea to secure it # username: !secret web_server_username #probably a good idea to secure it
# password: !secret web_server_password # password: !secret web_server_password
@@ -191,16 +209,16 @@ wifi:
mqtt: mqtt:
broker: ${mqtt_server} broker: ${mqtt_server}
topic_prefix: ${mqtt_topic}/${devicename} topic_prefix: ${mqtt_topic}/${devicename}
#username: !secret mqtt_username username: ${mqtt_username}
#password: !secret mqtt_password password: ${mqtt_password}
#A way to prevent deep sleep using MQTT command #Method to prevent deep sleep using MQTT command
#on_message: #on_message:
#- topic: ${mqtt_topic}/${devicename}/deepsleepoff #- topic: ${mqtt_topic}/${devicename}/deepsleep
#payload: 'ON' #payload: 'ON'
#then: #then:
#- deep_sleep.prevent: deep_sleep_1 #- deep_sleep.prevent: deep_sleep_1
#- topic: ${mqtt_topic}/${devicename}/deepsleepon #- topic: ${mqtt_topic}/${devicename}/deepsleep
#payload: 'ON' #payload: 'ON'
#then: #then:
#- deep_sleep.enter: deep_sleep_1 #- deep_sleep.enter: deep_sleep_1
@@ -277,7 +295,7 @@ sensor:
################################ ################################
# BME280 temp/humidity/pressure # BME280 temp/humidity/pressure (Note, BME and BMP Are different...)
# https://esphome.io/cookbook/bme280_environment.html # https://esphome.io/cookbook/bme280_environment.html
################################ ################################
#- platform: bme280_i2c #- platform: bme280_i2c
@@ -306,10 +324,10 @@ sensor:
################################ ################################
# DHT temp/humidity # DHT temp/humidity
# https://esphome.io/components/sensor/dht.html # https://esphome.io/components/sensor/dht.html
# These DHTs are not very accurate...
################################ ################################
- platform: dht - platform: dht
pin: GPIO15 #D8 on the D1 Mini ESP8266 pin: GPIO13 #D7 on the D1 Mini ESP8266
update_interval: ${update_time}
temperature: temperature:
name: ${friendly_name} DHT22 Temperature name: ${friendly_name} DHT22 Temperature
id: dht_temp id: dht_temp
@@ -385,30 +403,62 @@ sensor:
id: battery_voltage id: battery_voltage
pin: A0 pin: A0
unit_of_measurement: "V" unit_of_measurement: "V"
accuracy_decimals: 5 accuracy_decimals: 6
update_interval: ${update_time} update_interval: 10s
#retain: true #retain useful if sleeping #retain: true #retain useful if sleeping
filters: filters:
- multiply: 5.223 # tested with multimeter - multiply: 5.223 # tested with multimeter
- calibrate_linear: - calibrate_linear:
- 3.321 -> 3.125
- 3.89 -> 3.90 - 3.89 -> 3.90
- 3.85 -> 3.92
- 4.09 -> 4.14 - 4.09 -> 4.14
################################
# A Calculation of recent Av V
# So we can see if battery is charging/discharging
################################
- platform: template - platform: template
name: ${friendly_name} Av Battery Voltage over 5 mins name: ${friendly_name} Av Battery Voltage over recent period
id: battery_voltage_5minav id: battery_voltage_recentav
unit_of_measurement: "V" unit_of_measurement: "V"
accuracy_decimals: 5 accuracy_decimals: 6
update_interval: 30s #updates every 30s update_interval: 30s #updates every 30s
lambda: > lambda: >
return id(battery_voltage).state; //grabs values from the battery_voltage return id(battery_voltage).state; //grabs values from the battery_voltage
filters: filters:
- sliding_window_moving_average: - sliding_window_moving_average:
window_size: 20 #20x 30s = 10 mins window_size: 40 #40x 30s = 20 min average period
send_every: 1 send_every: 1
send_first_at: 1 send_first_at: 1
################################
# A Calculation of recent Max V
# So we can see if battery is charging/discharging
################################
- platform: template
name: ${friendly_name} Max Battery Voltage over recent period
id: battery_voltage_recentmax
unit_of_measurement: "V"
accuracy_decimals: 6
update_interval: 30s #updates every 30s
lambda: >
return id(battery_voltage).state; //grabs values from the battery_voltage
filters:
- max:
window_size: 40 #40x 30s = 20 min average period
send_every: 1
send_first_at: 1
- platform: template
name: ${friendly_name} Battery Voltage loss over 10 mins
id: battery_voltage_recentloss
unit_of_measurement: "V"
accuracy_decimals: 5
update_interval: 30s #updates every 30s
lambda: >
return {id(battery_voltage_recentmax).state - id(battery_voltage).state}; //recent av voltage - now
- platform: duty_time - platform: duty_time
id: battery_discharge_time id: battery_discharge_time
name: ${friendly_name} Time battery is discharging name: ${friendly_name} Time battery is discharging
@@ -420,9 +470,21 @@ sensor:
- multiply: 0.01666666 - multiply: 0.01666666
- round: 0 - round: 0
lambda: > lambda: >
return { id(battery_voltage).state <= id(battery_voltage_5minav).state }; return { id(battery_voltage).state <= id(battery_voltage_recentav).state };
#############################################
# WIND SENSOR
# looks like this one
# https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf
#############################################
#############################################
# USEFUL LINKS
# Wind Sensing
# https://community.home-assistant.io/t/measuring-wind-speed/395693/20
# https://community.home-assistant.io/t/measuring-wind-speed/395693/21
#############################################
################################ ################################
# Wind Direction, Analogue on ADS115 # Wind Direction, Analogue on ADS115
@@ -543,7 +605,7 @@ sensor:
- platform: pulse_meter # https://community.home-assistant.io/t/measuring-wind-speed/395693 - platform: pulse_meter # https://community.home-assistant.io/t/measuring-wind-speed/395693
id: wind_meter id: wind_meter
pin: pin:
number: GPIO13 number: GPIO14 #D5 on D1 Mini
mode: mode:
input: true input: true
pullup: true pullup: true
@@ -556,13 +618,14 @@ sensor:
accuracy_decimals: 1 accuracy_decimals: 1
timeout: 5s timeout: 5s
filters: filters:
- timeout: - heartbeat: 2s
timeout: "5s" #after 5 seconds, if no pulses received.... #- timeout:
value: 0 #make the value = 0 # timeout: "5s" #after 5 seconds, if no pulses received....
# value: 0 #make the value = 0
- multiply: 0.04 #kmh - multiply: 0.04 #kmh
- sliding_window_moving_average: # Moving average to prevent too many data points - sliding_window_moving_average: # Moving average to prevent too many data points
window_size: 10 window_size: 4
send_every: 10 send_every: 1
- clamp: - clamp:
min_value: 0 min_value: 0
max_value: 250 #if anything over that, we have debounce issues or are going to die max_value: 250 #if anything over that, we have debounce issues or are going to die
@@ -747,46 +810,47 @@ sensor:
# Template for Beaufort for measuring wind speed # Template for Beaufort for measuring wind speed
# https://windy.app/blog/wind-speed-beaufort-scale.html # https://windy.app/blog/wind-speed-beaufort-scale.html
################################ ################################
# - platform: template - platform: template
# name: ${friendly_name} Windspeed Scale name: ${friendly_name} Windspeed Scale
# icon: "mdi:weather-windy" icon: "mdi:weather-windy"
# id: wind_meter_scale id: wind_meter_scale
# lambda: return id(wind_meter).state; lambda: return id(wind_meter).state;
# unit_of_measurement: "m/s" unit_of_measurement: "m/s"
# update_interval: 5s update_interval: 5s
# filters: filters:
# - throttle_average: 5s - throttle_average: 5s
# on_value: - multiply: 0.278 #to get m/s from km/h
# lambda: |- on_value:
# if (id(wind_meter_scale).state < 0.1) { lambda: |-
# id(wind_scale).publish_state("Calm"); if (id(wind_meter_scale).state < 0.1) {
# } else if (id(wind_meter_scale).state > 0 && id(wind_meter_scale).state < 2) { id(wind_scale).publish_state("Calm");
# id(wind_scale).publish_state("Light Air"); } else if (id(wind_meter_scale).state > 0 && id(wind_meter_scale).state < 2) {
# } else if (id(wind_meter_scale).state >= 2 && id(wind_meter_scale).state < 3) { id(wind_scale).publish_state("Light Air");
# id(wind_scale).publish_state("Light Breeze"); } else if (id(wind_meter_scale).state >= 2 && id(wind_meter_scale).state < 3) {
# } else if (id(wind_meter_scale).state >= 3 && id(wind_meter_scale).state < 5) { id(wind_scale).publish_state("Light Breeze");
# id(wind_scale).publish_state("Gentle Breeze"); } else if (id(wind_meter_scale).state >= 3 && id(wind_meter_scale).state < 5) {
# } else if (id(wind_meter_scale).state >= 5 && id(wind_meter_scale).state < 8) { id(wind_scale).publish_state("Gentle Breeze");
# id(wind_scale).publish_state("Moderate Breeze"); } else if (id(wind_meter_scale).state >= 5 && id(wind_meter_scale).state < 8) {
# } else if (id(wind_meter_scale).state >= 8 && id(wind_meter_scale).state < 11) { id(wind_scale).publish_state("Moderate Breeze");
# id(wind_scale).publish_state("Fresh Breeze"); } else if (id(wind_meter_scale).state >= 8 && id(wind_meter_scale).state < 11) {
# } else if (id(wind_meter_scale).state >= 11 && id(wind_meter_scale).state < 14) { id(wind_scale).publish_state("Fresh Breeze");
# id(wind_scale).publish_state("Strong Breeze"); } else if (id(wind_meter_scale).state >= 11 && id(wind_meter_scale).state < 14) {
# } else if (id(wind_meter_scale).state >= 14 && id(wind_meter_scale).state < 17) { id(wind_scale).publish_state("Strong Breeze");
# id(wind_scale).publish_state("Near Gale"); } else if (id(wind_meter_scale).state >= 14 && id(wind_meter_scale).state < 17) {
# } else if (id(wind_meter_scale).state >= 17 && id(wind_meter_scale).state < 21) { id(wind_scale).publish_state("Near Gale");
# id(wind_scale).publish_state("Gale"); } else if (id(wind_meter_scale).state >= 17 && id(wind_meter_scale).state < 21) {
# } else if (id(wind_meter_scale).state >= 21 && id(wind_meter_scale).state < 24) { id(wind_scale).publish_state("Gale");
# id(wind_scale).publish_state("Severe Gale"); } else if (id(wind_meter_scale).state >= 21 && id(wind_meter_scale).state < 24) {
# } else if (id(wind_meter_scale).state >= 24 && id(wind_meter_scale).state < 28) { id(wind_scale).publish_state("Severe Gale");
# id(wind_scale).publish_state("Storm"); } else if (id(wind_meter_scale).state >= 24 && id(wind_meter_scale).state < 28) {
# } else if (id(wind_meter_scale).state >= 28 && id(wind_meter_scale).state < 33) { id(wind_scale).publish_state("Storm");
# id(wind_scale).publish_state("Violent Storm"); } else if (id(wind_meter_scale).state >= 28 && id(wind_meter_scale).state < 33) {
# } else if (id(wind_meter_scale).state >= 33) { id(wind_scale).publish_state("Violent Storm");
# id(wind_scale).publish_state("Hurricane Force"); } else if (id(wind_meter_scale).state >= 33) {
# } else { id(wind_scale).publish_state("Hurricane Force");
# id(wind_scale).publish_state(""); } else {
# } id(wind_scale).publish_state("");
}
#switch: #switch:
# - platform: template # - platform: template
@@ -853,3 +917,40 @@ sensor:
# type: float # type: float
# restore_value: no # restore_value: no
# initial_value: '0.0' # initial_value: '0.0'
################################
# Pulse Meter for measuring rainfall
# https://esphome.io/components/sensor/pulse_meter.html
#
################################
# CALIBRATION HINTS
# https://forum.mysensors.org/topic/9594/misol-rain-gauge-tipping-bucket-rain-amount/2
################################
- platform: pulse_meter
id: rainfall_meter
pin:
number: GPIO12 #D6 on D1 Mini
mode:
input: true
pullup: true
#internal: true # If true, don't send to HA/MQTT etc
internal_filter_mode: EDGE
internal_filter: 10ms
name: ${friendly_name} Rainfall
#icon: mdi:
unit_of_measurement: "mm"
accuracy_decimals: 1
timeout: 5s
filters:
- heartbeat: 2s
#- timeout:
# timeout: "5s" #after 5 seconds, if no pulses received....
# value: 0 #make the value = 0
- multiply: 0.2794 #mm of rain from tip bucket, 0.28 mm per pulse, or 3.57 pulse per mm (NEEDS CALIBRATION)
- sliding_window_moving_average: # Moving average to prevent too many data points
window_size: 4
send_every: 1
#- clamp:
# min_value: 0
# max_value: 250 #if anything over that, we have debounce issues or are going to die
# ignore_out_of_range: true

View File

@@ -1,370 +0,0 @@
# https://digiblur.com/2023/05/24/esphome-mmwave-presence-how-to-guide/
substitutions:
name: esp-mmwave-office-7776ec
friendly_name: esp-mmwave-office
update_time: 30s
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
#project:
#name: esphome.web
#version: '1.0'
on_boot: #LD1125H Initial Setting
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());
#############################################
# ESPHome Logging Enable
#############################################
# NOTE: Baudrate set to 0 as we are using the UART with PZEM
logger:
level: INFO #You Can Use "INFO" Level
baud_rate: 0
#############################################
# Enable the Home Assistant API
#############################################
api:
#encryption:
# key: !secret esp-mainovenmonitor_api_key
#############################################
# Enable Over the Air Update Capability
# Safe mode will detect boot loops
#############################################
ota:
# safe_mode: true
# password: !secret esp-mainovenmonitor_ota_pass
#############################################
# Use Wifi
#############################################
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: LIGHT
# Details for fallback hotspot (captive portal)
# in case wifi connection fails
ap:
ssid: "MMwave Office Fallback Hotspot"
password: !secret fallback_ap_password
# manual_ip:
# static_ip: 192.168.x.x
# gateway: 192.168.X.x
# subnet: 255.255.255.0
# Allow provisioning Wi-Fi via serial
#improv_serial:
#############################################
# Fallback captive portal
#############################################
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
#dashboard_import:
# package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
# import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
##esp32_improv:
## authorizer: none
#############################################
# Web Portal for display and monitoring
#############################################
#web_server:
# port: 80
# auth:
# username: !secret web_server_username
# password: !secret web_server_password
i2c:
sda: GPIO19
scl: GPIO21
scan: True
#esp32:
# board: esp32dev
# framework:
# type: arduino
esp32:
board: nodemcu-32s
framework:
type: esp-idf #Suggest Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang.
external_components:
- source:
type: git
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
components: [ serial ]
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
# rx_pin: GPIO1 #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: GPIO0 #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
# debug:
# direction: BOTH
# dummy_receiver: false
# after:
# delimiter: "\n"
# sequence:
# - lambda: UARTDebug::log_string(direction, bytes);
globals:
- id: LD1125H_Last_Time
type: time_t
restore_value: no
initial_value: time(NULL)
- id: LD1125H_Last_Mov_Time
type: time_t
restore_value: no
initial_value: time(NULL)
- id: LD1125H_Clearence_Status
type: bool
restore_value: no
initial_value: "false"
status_led:
pin:
number: GPIO2 #ESP32 OnBroad LED
inverted: false
#web_server: #Avoid Using Web Server To Prevent Hang
# port: 80
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:
- platform: template
name: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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
sensor:
- platform: bme280_i2c
temperature:
name: ${upper_devicename} BME280 Temp
accuracy_decimals: 1
oversampling: 2x
pressure:
name: ${upper_devicename} BME280 Pressure
oversampling: 2x
humidity:
name: ${upper_devicename} BME280 Humidity
accuracy_decimals: 1
oversampling: 2x
address: 0x76
update_interval: ${update_time}
# - platform: aht10
# temperature:
# accuracy_decimals: 2
# name: ${upper_devicename} AHT21 Temp
# humidity:
# accuracy_decimals: 2
# name: ${upper_devicename} AHT21 Humidity
# update_interval: ${update_time}
# - platform: wifi_signal
# name: ${upper_devicename} WiFi Signal
# update_interval: 60s
- platform: uptime
name: ${upper_devicename} Uptime
- platform: template
name: ${upper_devicename} LD1125H 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_sensor:
- platform: serial
uart_id: LD1125H_UART_BUS
name: ${upper_devicename} 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: ${upper_devicename} LD1125H Occupancy Status
id: LD1125H_Occupancy
icon: "mdi:motion-sensor"
binary_sensor:
- platform: status
name: ${upper_devicename} Status
- platform: template
name: ${upper_devicename} LD1125H Occupancy or Movement
id: LD1125H_MovOcc_Binary
device_class: occupancy
- platform: template
name: ${upper_devicename} LD1125H Movement
id: LD1125H_Mov_Binary
device_class: motion

View File

@@ -1,31 +0,0 @@
esphome:
name: esp-mmwave-office
friendly_name: esp-mmwave-office
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "KbgRoOmslFkhfRnWgr3RKK6P3Ed3dhHJ+l9FVYZX8lo="
ota:
password: "b3a0a1de8ea89ebf360fbeac40af7a0a"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Mmwave-Office"
password: "EsNR8kqAOUu8"
captive_portal:

View File

@@ -1,393 +0,0 @@
#############################################
# Variable Substitutions
#############################################
substitutions:
devicename: "esphome-web-7776ec"
friendly_name: "esp-web-7776ec"
upper_devicename: "esp-web-7776ec"
mqtt_topic: "esphome"
update_time: 30s #for temp sensors etc
#############################################
# ESPHome
# https://esphome.io/components/esphome.html#esphome-core-configuration
#############################################
esphome:
name: ${devicename}
comment: D1 Mini ESP32 with mmWave and environment sensors for main office #appears on the esphome page in HA
on_boot: #LD1125H Initial Setting
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: nodemcu-32s
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 external or custom components to use
#############################################
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 values from the uart.
#############################################
# ESPHome Logging Enable
#############################################
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
#############################################
api:
#encryption:
#key: !secret esp-?_api_key
#############################################
# Enable Over the Air Update Capability
# Safe mode will detect boot loops
#############################################
ota:
safe_mode: true
password: !secret esp-mmwaveoffice_ota_pass
#############################################
# Wifi Settings
#############################################
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
#manual_ip:
#static_ip: 192.168.x.x
#gateway: 192.168.X.x
#subnet: 255.255.255.0
#ap: #Details for fallback hotspot (captive portal) in case wifi connection fails
#ssid: "? Fallback Hotspot"
#password: !secret fallback_ap_password
#############################################
# Web Portal for display and monitoring
# Turning this off is probably a good idea to save resources.
#############################################
web_server:
port: 80
# username: !secret web_server_username
# password: !secret web_server_password
#############################################
# MQTT Monitoring
#############################################
mqtt:
broker: !secret mqtt_server
topic_prefix: ${mqtt_topic}/${devicename}
username: !secret mqtt_username
password: !secret mqtt_password
#############################################
#############################################
# MAIN SENSORS
#############################################
#############################################
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
# rx_pin: GPIO1 #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: GPIO0 #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
# debug:
# direction: BOTH
# dummy_receiver: false
# after:
# delimiter: "\n"
# sequence:
# - lambda: UARTDebug::log_string(direction, bytes);
#############################################
# Global Variables for use in templates etc
#############################################
globals:
- id: LD1125H_Last_Time
type: time_t
restore_value: no
initial_value: time(NULL)
- id: LD1125H_Last_Mov_Time
type: time_t
restore_value: no
initial_value: time(NULL)
- id: LD1125H_Clearence_Status
type: bool
restore_value: no
initial_value: "false"
#############################################
# General esp status LED
#############################################
status_led:
pin:
number: GPIO2 #ESP32 OnBroad LED
inverted: false
#############################################
# Interval Automations
# https://esphome.io/guides/automations.html#interval-component
#############################################
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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} 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: ${upper_devicename} BME280 Temp
accuracy_decimals: 1
oversampling: 2x
pressure:
name: ${upper_devicename} BME280 Pressure
oversampling: 2x
humidity:
name: ${upper_devicename} BME280 Humidity
accuracy_decimals: 1
oversampling: 2x
address: 0x76
update_interval: ${update_time}
- platform: uptime
name: ${upper_devicename} Uptime
- platform: template
name: ${upper_devicename} LD1125H 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 (custom component)
# refer https://github.com/ssieb/esphome_components/tree/master/components/serial
#############################################
text_sensor:
- platform: serial
uart_id: LD1125H_UART_BUS
name: ${upper_devicename} 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: ${upper_devicename} LD1125H Occupancy Status
id: LD1125H_Occupancy
icon: "mdi:motion-sensor"
#############################################
# Binary Sensors
# https://esphome.io/components/binary_sensor/index.html
#############################################
binary_sensor:
- platform: status
name: ${upper_devicename} Status
- platform: template
name: ${upper_devicename} LD1125H Occupancy or Movement
id: LD1125H_MovOcc_Binary
device_class: occupancy
- platform: template
name: ${upper_devicename} LD1125H Movement
id: LD1125H_Mov_Binary
device_class: motion