This commit is contained in:
John Dillenburg
2024-11-24 15:47:04 -06:00
parent 560c3f2747
commit d1578f36e0
31 changed files with 3086 additions and 0 deletions

Submodule packages/.esphome/external_components/af6fb47d added at fc2ffe1409

Submodule packages/.esphome/external_components/d2e825de added at 836298f144

30
packages/beacon.yaml Normal file
View File

@@ -0,0 +1,30 @@
# This file is included as a package in all mmwave presence sensors
# Requires area variable to be set to the name of the room the sensor is in.
#
esphome:
comment: "Beacon"
# Adding external component to build:
external_components:
- source: github://formatBCE/ESP32_BLE_presense@main
# System time config - required for precise timestamps, used in integration:
time:
- platform: homeassistant
id: homeassistant_time
# Initializing it:
esp32_ble_presense:
area: "${area}"
time_id: homeassistant_time
# MQTT config - required for this component to work:
mqtt:
broker: 10.0.0.215
username: esp32_presence
password: findme
discovery_prefix: "homeassistant"
port: 1883
client_id: "${area}"
keepalive:
minutes: 10

200
packages/ld1115h.yaml Normal file
View File

@@ -0,0 +1,200 @@
esphome:
on_boot: #LD1115H Initial Setting
priority: -200
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th1st = "th1=" + str_sprintf("%.0f",id(LD1115H_TH1).state) +" \n";
return std::vector<uint8_t>(th1st.begin(), th1st.end());
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th2st = "th2=" + str_sprintf("%.0f",id(LD1115H_TH2).state) +" \n";
return std::vector<uint8_t>(th2st.begin(), th2st.end());
external_components:
- source:
type: git
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
components: [ serial ]
# Disable logging to UART
logger:
baud_rate: 0
uart:
id: LD1115H_UART_BUS
rx_pin: ${uart_rx_pin}
tx_pin: ${uart_tx_pin}
baud_rate: 115200
data_bits: 8
stop_bits: 1
parity: NONE
setup_priority: 200 #Set Priority To Prevent Boot Loop or Fail
globals:
- id: LD1115H_Last_Time
type: time_t
restore_value: no
initial_value: ::time(NULL)
- id: LD1115H_Last_Mov_Time
type: time_t
restore_value: no
initial_value: ::time(NULL)
- id: LD1115H_Clearence_Status
type: bool
restore_value: no
initial_value: "false"
interval:
- interval: 1s #Clearance Scan Time
setup_priority: -200
then:
lambda: |-
if ((::time(NULL)-id(LD1115H_Last_Time))>id(LD1115H_Clear_Time).state) {
if ((id(LD1115H_Clearence_Status) == false) || (id(LD1115H_Occupancy).state != "Clearance")) {
id(LD1115H_Occupancy).publish_state("Clearance");
id(LD1115H_Clearence_Status) = true;
}
if (id(LD1115H_MovOcc_Binary).state == true) {
id(LD1115H_MovOcc_Binary).publish_state(false);
}
if (id(LD1115H_Mov_Binary).state == true) {
id(LD1115H_Mov_Binary).publish_state(false);
}
}
number:
- platform: template
name: ${device_name} LD1115H TH1 #TH1 is Movement/Motion Sensitivity
id: LD1115H_TH1
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: "120" #Default TH1 Setting
min_value: 20
max_value: 1200
step: 10
set_action:
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th1st = "th1=" + str_sprintf("%.0f",x) +" \n";
return std::vector<uint8_t>(th1st.begin(), th1st.end());
- platform: template
name: ${device_name} LD1115H TH2 #TH2 is Occupancy/Presence Sensitivity
id: LD1115H_TH2
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: "250" #Default TH2 Setting
min_value: 50
max_value: 2500
step: 10
set_action:
then:
- uart.write:
id: LD1115H_UART_BUS
data: !lambda |-
std::string th2st = "th2=" + str_sprintf("%.0f",x) +" \n";
return std::vector<uint8_t>(th2st.begin(), th2st.end());
- platform: template
name: ${device_name} LD1115H Clearence Time
id: LD1115H_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" #LD1115H Mov/Occ > Clearence Time Here
min_value: 0.5
max_value: 20
step: 0.5
- platform: template
name: ${device_name} LD1115H Movement Time
id: LD1115H_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" #LD1115H Mov > Occ Time Here
min_value: 0.5
max_value: 10
step: 0.5
sensor:
- platform: template
name: ${device_name} LD1115H Spectral line
id: LD1115H_Spectral
icon: "mdi:radar"
unit_of_measurement: ""
accuracy_decimals: 0
- platform: template
name: ${device_name} LD1115H Signal Strength
id: LD1115H_Signal
icon: "mdi:signal-distance-variant"
unit_of_measurement: ""
accuracy_decimals: 0
filters: # Use Fliter To Debounce
- sliding_window_moving_average:
window_size: 8
send_every: 2
- heartbeat: 2.0s
text_sensor:
- platform: serial
uart_id: LD1115H_UART_BUS
name: ${device_name} LD1115H UART Text
id: LD1115H_UART_Text
icon: "mdi:format-text"
internal: True
on_value:
lambda: |-
if (id(LD1115H_UART_Text).state.substr(0,3) == "occ") {
id(LD1115H_Signal).publish_state(atof(id(LD1115H_UART_Text).state.substr(7).c_str()));
id(LD1115H_Spectral).publish_state(atof(id(LD1115H_UART_Text).state.substr(5,2).c_str()));
if ((::time(NULL)-id(LD1115H_Last_Mov_Time))>id(LD1115H_Mov_Time).state) {
id(LD1115H_Occupancy).publish_state("Occupancy");
if (id(LD1115H_MovOcc_Binary).state == false) {
id(LD1115H_MovOcc_Binary).publish_state(true);
}
if (id(LD1115H_Mov_Binary).state == true) {
id(LD1115H_Mov_Binary).publish_state(false);
}
}
if (id(LD1115H_MovOcc_Binary).state == false) {
id(LD1115H_MovOcc_Binary).publish_state(true);
}
id(LD1115H_Last_Time) = ::time(NULL);
if (id(LD1115H_Clearence_Status) == true) {
id(LD1115H_Clearence_Status) = false;
}
}
else if (id(LD1115H_UART_Text).state.substr(0,3) == "mov") {
id(LD1115H_Signal).publish_state(atof(id(LD1115H_UART_Text).state.substr(7).c_str()));
id(LD1115H_Spectral).publish_state(atof(id(LD1115H_UART_Text).state.substr(5,2).c_str()));
id(LD1115H_Occupancy).publish_state("Movement");
if (id(LD1115H_MovOcc_Binary).state == false) {
id(LD1115H_MovOcc_Binary).publish_state(true);
}
if (id(LD1115H_Mov_Binary).state == false) {
id(LD1115H_Mov_Binary).publish_state(true);
}
id(LD1115H_Last_Mov_Time) = ::time(NULL);
id(LD1115H_Last_Time) = ::time(NULL);
if (id(LD1115H_Clearence_Status) == true) {
id(LD1115H_Clearence_Status) = false;
}
}
- platform: template
name: ${device_name} LD1115H Occupancy Status
id: LD1115H_Occupancy
icon: "mdi:motion-sensor"
binary_sensor:
- platform: template
name: ${device_name} LD1115H Occupancy or Movement
id: LD1115H_MovOcc_Binary
device_class: occupancy
- platform: template
name: ${device_name} LD1115H Movement
id: LD1115H_Mov_Binary
device_class: motion

304
packages/ld1125h.yaml Normal file
View File

@@ -0,0 +1,304 @@
esphome:
on_boot: #LD1125H Initial Setting
priority: -200
then:
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th1stm = "mth1_mov=" + str_sprintf("%.0f",id(LD1125H_mth1_mov).state) +"\r\n";
return std::vector<uint8_t>(th1stm.begin(), th1stm.end());
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th2stm = "mth2_mov=" + str_sprintf("%.0f",id(LD1125H_mth2_mov).state) +"\r\n";
return std::vector<uint8_t>(th2stm.begin(), th2stm.end());
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th3stm = "mth3_mov=" + str_sprintf("%.0f",id(LD1125H_mth3_mov).state) +"\r\n";
return std::vector<uint8_t>(th3stm.begin(), th3stm.end());
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th1sto = "mth1_occ=" + str_sprintf("%.0f",id(LD1125H_mth1_occ).state) +"\r\n";
return std::vector<uint8_t>(th1sto.begin(), th1sto.end());
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th2sto = "mth2_occ=" + str_sprintf("%.0f",id(LD1125H_mth2_occ).state) +"\r\n";
return std::vector<uint8_t>(th2sto.begin(), th2sto.end());
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th3sto = "mth3_occ=" + str_sprintf("%.0f",id(LD1125H_mth3_occ).state) +"\r\n";
return std::vector<uint8_t>(th3sto.begin(), th3sto.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());
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string getallst = "get_all\r\n";
return std::vector<uint8_t>(getallst.begin(), getallst.end());
external_components:
- source:
type: git
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
components: [ serial ]
logger:
level: INFO #You Can Use "INFO" Level
baud_rate: 0
uart:
id: LD1125H_UART_BUS
rx_pin: ${uart_rx_pin}
tx_pin: ${uart_tx_pin}
baud_rate: 115200
data_bits: 8
stop_bits: 1
parity: NONE
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"
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 mov #mth1 mov is 0~2.8m motion detection threshold.
id: LD1125H_mth1_mov
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.0" #Default mth1_mov 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_mov=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th1st.begin(), th1st.end());
- platform: template
name: ${upper_devicename} LD1125H mth2 mov #mth2 mov is 2.8~8m motion detection threshold.
id: LD1125H_mth2_mov
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: "15" #Default mth2_mov Setting
min_value: 5
max_value: 300
step: 5
set_action:
then:
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th2st = "mth2_mov=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th2st.begin(), th2st.end());
- platform: template
name: ${upper_devicename} LD1125H mth3 mov #mth3 mov is above 8m motion detection threshold.
id: LD1125H_mth3_mov
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: "6" #Default mth3_mov Setting
min_value: 5
max_value: 200
step: 5
set_action:
then:
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th3st = "mth3_mov=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th3st.begin(), th3st.end());
- platform: template
name: ${upper_devicename} LD1125H mth1 occ #mth1 occ is 0~2.8m detection threshold.
id: LD1125H_mth1_occ
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.0" #Default mth1_mov 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_occ=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th1st.begin(), th1st.end());
- platform: template
name: ${upper_devicename} LD1125H mth2 occ #mth2 occ is 2.8~8m detection threshold.
id: LD1125H_mth2_occ
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: "15" #Default mth2_mov Setting
min_value: 5
max_value: 300
step: 5
set_action:
then:
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th2st = "mth2_occ=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th2st.begin(), th2st.end());
- platform: template
name: ${upper_devicename} LD1125H mth3 occ #mth3 occ is above 8m detection threshold.
id: LD1125H_mth3_occ
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: "6" #Default mth3_mov Setting
min_value: 5
max_value: 200
step: 5
set_action:
then:
- uart.write:
id: LD1125H_UART_BUS
data: !lambda |-
std::string th3st = "mth3_occ=" + 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.2
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: 60
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: 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: 10
- heartbeat: 2.0s
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: 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

164
packages/sen0395.yaml Normal file
View File

@@ -0,0 +1,164 @@
esphome:
includes:
- leapmmw_sensor.h
# Disable uart logging
logger:
baud_rate: 0
level: DEBUG
uart:
id: SEN095_UART_BUS
rx_pin: ${uart_rx_pin}
tx_pin: ${uart_tx_pin}
baud_rate: 115200
data_bits: 8
stop_bits: 1
parity: NONE
dfrobot_sen0395:
binary_sensor:
- platform: gpio
name: "${device_name_pretty}"
id: mmwave_presence_detection
device_class: motion
pin:
number: ${presence_pin}
mode: INPUT_PULLDOWN
# when motion is detected, the radar sensor is on so publish radar state to HA
on_press:
then:
lambda: !lambda |-
if (!id(mmwave_sensor).state) {
id(mmwave_sensor).publish_state(true);
}
sensor:
- platform: custom
lambda: |-
auto s = new leapmmw(id(SEN095_UART_BUS));
App.register_component(s);
return {};
sensors:
switch:
- platform: template
name: "${device_name_pretty} mmwave_sensor"
id: mmwave_sensor # do not change
entity_category: config
optimistic: true
turn_on_action:
- uart.write: "setUartOutput 1 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 4s
- uart.write: "sensorStart"
turn_off_action:
- uart.write: "sensorStop"
- delay: 2s
- platform: template
name: "${device_name_pretty} led"
id: led # do not change
entity_category: config
optimistic: true
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 2s
- uart.write: "setLedMode 1 0"
- delay: 3s
- lambda: |-
leapmmw(id(SEN095_UART_BUS)).getmmwConf("getLedMode 1");
- delay: 2s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 2s
- uart.write: "setLedMode 1 1"
- delay: 3s
- lambda: |-
leapmmw(id(SEN095_UART_BUS)).getmmwConf("getLedMode 1");
- delay: 2s
- switch.turn_on: mmwave_sensor
number:
- platform: template
name: "${device_name_pretty} distance"
id: distance # do not change
entity_category: config
min_value: 0.15
max_value: 9.45
step: 0.15
unit_of_measurement: M
mode: box
lambda: |-
leapmmw(id(SEN095_UART_BUS)).getmmwConf("getRange");
return {};
set_action:
- switch.turn_off: mmwave_sensor
- delay: 2s
- uart.write: !lambda
std::string range = "setRange 0 " + str_sprintf("%.2f", x);
return std::vector<unsigned char>(range.begin(), range.end());
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: "${device_name_pretty} latency"
id: latency # do not change
entity_category: config
min_value: 1
max_value: 600
lambda: |-
leapmmw(id(SEN095_UART_BUS)).getmmwConf("getLatency");
return {};
step: 1
unit_of_measurement: s
mode: box
set_action:
- switch.turn_off: mmwave_sensor
- delay: 2s
- uart.write: !lambda
std::string setL = "setLatency 0.1 " + str_sprintf("%.0f", x);
return std::vector<unsigned char>(setL.begin(), setL.end());
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: "${device_name_pretty} sensitivity"
id: sensitivity # do not change
entity_category: config
min_value: 0
max_value: 9
lambda: |-
leapmmw(id(SEN095_UART_BUS)).getmmwConf("getSensitivity");
return {};
step: 1
set_action:
- switch.turn_off: mmwave_sensor
- delay: 2s
- uart.write: !lambda
std::string mss = "setSensitivity " + to_string((int)x);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 3s
- switch.turn_on: mmwave_sensor
button:
- platform: restart
name: Restart_ESP_${device_name}
entity_category: diagnostic
on_press:
- uart.write:
id: SEN095_UART_BUS
data: "resetSystem 0"
- platform: template
name: factory_reset_mmwMCU_${device_name}
id: factory_reset_mmwMCU
entity_category: diagnostic
on_press:
- switch.turn_off: mmwave_sensor
- delay: 2s
- uart.write: "resetCfg"
- delay: 3s