weather station esphome and others
This commit is contained in:
@@ -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
|
@@ -1,381 +0,0 @@
|
||||
# https://digiblur.com/2023/05/24/esphome-mmwave-presence-how-to-guide/
|
||||
|
||||
substitutions:
|
||||
name: "esphome-web-7776ec"
|
||||
friendly_name: "esp-mmwave-office"
|
||||
upper_devicename: "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());
|
||||
|
||||
|
||||
|
||||
|
||||
i2c:
|
||||
sda: GPIO19
|
||||
scl: GPIO21
|
||||
scan: True
|
||||
|
||||
|
||||
#############################################
|
||||
# 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
|
||||
|
||||
#############################################
|
||||
# MQTT Monitoring
|
||||
#############################################
|
||||
mqtt:
|
||||
broker: !secret mqtt_server
|
||||
topic_prefix: esphome/esp-mmwave-office
|
||||
username: !secret mqtt_username
|
||||
password: !secret mqtt_password
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
#esp32:
|
||||
# board: esp32dev
|
||||
# framework:
|
||||
# type: arduino
|
||||
esp32:
|
||||
board: esp32dev
|
||||
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
|
Reference in New Issue
Block a user