Introduced @durd 's patch to beta firmware, bumping the original beta firmware to STABLE.

This commit is contained in:
sen 2024-08-08 08:03:02 +08:00
parent 34b12bb3fd
commit 3780f499c9
2 changed files with 116 additions and 66 deletions

View File

@ -1,6 +1,6 @@
# screek f2 yaml code # screek f2 yaml code
# main ld1125h code from: https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome # main ld1125h code from: https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome
# #
substitutions: substitutions:
devicename: "" devicename: ""
upper_devicename: "" upper_devicename: ""
@ -13,7 +13,7 @@ esphome:
platformio_options: platformio_options:
board_build.flash_mode: dio board_build.flash_mode: dio
# board_build.f_cpu: 80000000L # board_build.f_cpu: 80000000L
project: project:
name: Screek.Human_Presence_Sensor name: Screek.Human_Presence_Sensor
version: F2 version: F2
on_boot: on_boot:
@ -23,9 +23,8 @@ esphome:
id(cpu_speed) = ESP.getCpuFreqMHz(); id(cpu_speed) = ESP.getCpuFreqMHz();
- priority: 300 - priority: 300
then: then:
# 写入版本号,未来使用公共变量!(23年7月17日_13时29分_)
lambda: |- lambda: |-
id(screek_version).publish_state("V24.7.4_beta"); id(screek_version).publish_state("Beta_V240708_1");
- priority: -200 - priority: -200
then: then:
- uart.write: - uart.write:
@ -75,7 +74,7 @@ external_components:
type: git type: git
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
components: [ serial ] components: [ serial ]
esp32: esp32:
board: lolin_c3_mini board: lolin_c3_mini
framework: framework:
@ -114,8 +113,10 @@ globals:
initial_value: "false" initial_value: "false"
improv_serial: improv_serial:
logger: logger:
logs:
bh1750.sensor: INFO
debug: debug:
update_interval: 30s update_interval: 30s
@ -141,7 +142,7 @@ captive_portal:
web_server: web_server:
port: 80 port: 80
text_sensor: text_sensor:
- platform: template - platform: template
name: "SCREEK Version" name: "SCREEK Version"
@ -173,6 +174,13 @@ text_sensor:
icon: "mdi:format-text" icon: "mdi:format-text"
entity_category: "diagnostic" entity_category: "diagnostic"
internal: False #If Don't Want to See UART Receive Data, Set To True internal: False #If Don't Want to See UART Receive Data, Set To True
filters:
- lambda: |-
static std::string last;
if (x == last)
return {};
last = x;
return x;
on_value: on_value:
lambda: |- lambda: |-
std::string uart_text = id(LD1125F_UART_Text).state; std::string uart_text = id(LD1125F_UART_Text).state;
@ -183,10 +191,10 @@ text_sensor:
float distance = -1; float distance = -1;
std::string uart_state = ""; std::string uart_state = "";
if (uart_text.length() > 3){ if (uart_text.length() > 3) {
uart_state = id(LD1125F_UART_Text).state.substr(0,3); uart_state = id(LD1125F_UART_Text).state.substr(0,3);
if (uart_text.length() >= 9) { if (uart_text.length() >= 9) {
if (uart_state == "occ" || uart_state =="mov") { if (uart_state == "occ" || uart_state == "mov") {
distance = std::stof(uart_text.substr(9)); distance = std::stof(uart_text.substr(9));
} }
} }
@ -194,7 +202,7 @@ text_sensor:
if (uart_state == "occ" && distance > 0) { if (uart_state == "occ" && distance > 0) {
id(LD1125F_Distance).publish_state(distance); id(LD1125F_Distance).publish_state(distance);
if ((time(NULL)-id(LD1125F_Last_Mov_Time))>id(LD1125F_Mov_Time).state) { if ((time(NULL)-id(LD1125F_Last_Mov_Time)) >= id(LD1125F_Mov_Time).state) {
id(LD1125F_Occupancy).publish_state("Occupancy"); id(LD1125F_Occupancy).publish_state("Occupancy");
if (id(LD1125F_MovOcc_Binary).state == false) { if (id(LD1125F_MovOcc_Binary).state == false) {
id(LD1125F_MovOcc_Binary).publish_state(true); id(LD1125F_MovOcc_Binary).publish_state(true);
@ -239,10 +247,12 @@ binary_sensor:
name: ${upper_devicename} Occupancy or Movement name: ${upper_devicename} Occupancy or Movement
id: LD1125F_MovOcc_Binary id: LD1125F_MovOcc_Binary
device_class: occupancy device_class: occupancy
publish_initial_state: True
- platform: template - platform: template
name: ${upper_devicename} Movement name: ${upper_devicename} Movement
id: LD1125F_Mov_Binary id: LD1125F_Mov_Binary
device_class: motion device_class: motion
publish_initial_state: True
sensor: sensor:
- platform: template - platform: template
@ -259,7 +269,7 @@ sensor:
id: sys_esp_temperature id: sys_esp_temperature
name: ESP Temperature name: ESP Temperature
lambda: return temperatureRead(); lambda: return temperatureRead();
unit_of_measurement: °C unit_of_measurement: "°C"
device_class: TEMPERATURE device_class: TEMPERATURE
update_interval: 45s update_interval: 45s
entity_category: "diagnostic" entity_category: "diagnostic"
@ -267,7 +277,7 @@ sensor:
name: ESP Uptime name: ESP Uptime
id: sys_uptime id: sys_uptime
update_interval: 60s update_interval: 60s
- platform: wifi_signal - platform: wifi_signal
name: RSSI name: RSSI
id: wifi_signal_db id: wifi_signal_db
update_interval: 60s update_interval: 60s
@ -289,8 +299,8 @@ sensor:
accuracy_decimals: 2 accuracy_decimals: 2
# filters: # Use Fliter To Debounce # filters: # Use Fliter To Debounce
# - sliding_window_moving_average: # - sliding_window_moving_average:
# window_size: 8 # window_size: 8
# send_every: 2 # send_every: 2
# - heartbeat: 0.2s # - heartbeat: 0.2s
- platform: bh1750 - platform: bh1750
name: "Illuminance" name: "Illuminance"
@ -350,7 +360,6 @@ interval:
then: then:
lambda: |- lambda: |-
if ((time(NULL)-id(LD1125F_Last_Time))>id(LD1125F_Clear_Time).state) { if ((time(NULL)-id(LD1125F_Last_Time))>id(LD1125F_Clear_Time).state) {
// 清理距离。
if (id(LD1125F_Distance).state != 0){ if (id(LD1125F_Distance).state != 0){
id(LD1125F_Distance).publish_state(0); id(LD1125F_Distance).publish_state(0);
} }
@ -501,4 +510,3 @@ number:
min_value: 0.5 min_value: 0.5
max_value: 10 max_value: 10
step: 0.5 step: 0.5

View File

@ -1,6 +1,6 @@
# screek f2 yaml code # screek f2 yaml code
# main ld1125h code from: https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome # main ld1125h code from: https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome
# #
substitutions: substitutions:
devicename: "" devicename: ""
upper_devicename: "" upper_devicename: ""
@ -13,7 +13,7 @@ esphome:
platformio_options: platformio_options:
board_build.flash_mode: dio board_build.flash_mode: dio
# board_build.f_cpu: 80000000L # board_build.f_cpu: 80000000L
project: project:
name: Screek.Human_Presence_Sensor name: Screek.Human_Presence_Sensor
version: F2 version: F2
on_boot: on_boot:
@ -21,6 +21,10 @@ esphome:
then: then:
lambda: |- lambda: |-
id(cpu_speed) = ESP.getCpuFreqMHz(); id(cpu_speed) = ESP.getCpuFreqMHz();
- priority: 300
then:
lambda: |-
id(screek_version).publish_state("V240708_1");
- priority: -200 - priority: -200
then: then:
- uart.write: - uart.write:
@ -28,21 +32,34 @@ esphome:
data: !lambda |- data: !lambda |-
std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125F_mth1).state) +"\r\n"; std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125F_mth1).state) +"\r\n";
return std::vector<uint8_t>(th1st.begin(), th1st.end()); return std::vector<uint8_t>(th1st.begin(), th1st.end());
- delay: 100ms
- uart.write: - uart.write:
id: LD1125F_UART_BUS id: LD1125F_UART_BUS
data: !lambda |- data: !lambda |-
std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125F_mth2).state) +"\r\n"; std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125F_mth2).state) +"\r\n";
return std::vector<uint8_t>(th2st.begin(), th2st.end()); return std::vector<uint8_t>(th2st.begin(), th2st.end());
- delay: 100ms
- uart.write: - uart.write:
id: LD1125F_UART_BUS id: LD1125F_UART_BUS
data: !lambda |- data: !lambda |-
std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125F_mth3).state) +"\r\n"; std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125F_mth3).state) +"\r\n";
return std::vector<uint8_t>(th3st.begin(), th3st.end()); return std::vector<uint8_t>(th3st.begin(), th3st.end());
- delay: 100ms
- uart.write: - uart.write:
id: LD1125F_UART_BUS id: LD1125F_UART_BUS
data: !lambda |- data: !lambda |-
std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125F_rmax).state) +"\r\n"; std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125F_rmax).state) +"\r\n";
return std::vector<uint8_t>(rmaxst.begin(), rmaxst.end()); return std::vector<uint8_t>(rmaxst.begin(), rmaxst.end());
- delay: 100ms
- uart.write:
id: LD1125F_UART_BUS
data: !lambda |-
std::string utonsst = "utons=" + str_sprintf("%.1f",id(LD1125F_utons).state) +"\r\n";
return std::vector<uint8_t>(utonsst.begin(), utonsst.end());
safe_mode:
disabled: true
preferences: preferences:
flash_write_interval: 5s flash_write_interval: 5s
@ -57,7 +74,7 @@ external_components:
type: git type: git
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
components: [ serial ] components: [ serial ]
esp32: esp32:
board: lolin_c3_mini board: lolin_c3_mini
framework: framework:
@ -96,10 +113,8 @@ globals:
initial_value: "false" initial_value: "false"
improv_serial: improv_serial:
logger: logger:
logs:
bh1750.sensor: INFO
debug: debug:
update_interval: 30s update_interval: 30s
@ -125,8 +140,15 @@ captive_portal:
web_server: web_server:
port: 80 port: 80
text_sensor: text_sensor:
- platform: template
name: "SCREEK Version"
id: screek_version
icon: mdi:information-outline
entity_category: "diagnostic"
update_interval: never
- platform: debug - platform: debug
reset_reason: reset_reason:
name: "ESP Reset Reason" name: "ESP Reset Reason"
@ -150,39 +172,20 @@ text_sensor:
icon: "mdi:format-text" icon: "mdi:format-text"
entity_category: "diagnostic" entity_category: "diagnostic"
internal: False #If Don't Want to See UART Receive Data, Set To True internal: False #If Don't Want to See UART Receive Data, Set To True
filters:
- lambda: |-
static std::string last;
if (x == last)
return {};
last = x;
return x;
on_value: on_value:
lambda: |- lambda: |-
std::string uart_text = id(LD1125F_UART_Text).state; std::string uart_text = id(LD1125F_UART_Text).state;
if (uart_text == "null") {
if (id(LD1125F_Distance).state != 0) { if (uart_text == "null"){
id(LD1125F_Distance).publish_state(0);
}
if ((id(LD1125F_Clearence_Status) = false) || (id(LD1125F_Occupancy).state != "Clearance")) {
id(LD1125F_Occupancy).publish_state("Clearance");
id(LD1125F_Clearence_Status) = true;
}
if (id(LD1125F_MovOcc_Binary).state == true) {
id(LD1125F_MovOcc_Binary).publish_state(false);
}
if (id(LD1125F_Mov_Binary).state == true) {
id(LD1125F_Mov_Binary).publish_state(false);
}
return; return;
} }
float distance = -1; float distance = -1;
std::string uart_state = ""; std::string uart_state = "";
if (uart_text.length() > 3) { if (uart_text.length() > 3){
uart_state = id(LD1125F_UART_Text).state.substr(0,3); uart_state = id(LD1125F_UART_Text).state.substr(0,3);
if (uart_text.length() >= 9) { if (uart_text.length() >= 9) {
if (uart_state == "occ" || uart_state == "mov") { if (uart_state == "occ" || uart_state =="mov") {
distance = std::stof(uart_text.substr(9)); distance = std::stof(uart_text.substr(9));
} }
} }
@ -190,7 +193,7 @@ text_sensor:
if (uart_state == "occ" && distance > 0) { if (uart_state == "occ" && distance > 0) {
id(LD1125F_Distance).publish_state(distance); id(LD1125F_Distance).publish_state(distance);
if ((time(NULL)-id(LD1125F_Last_Mov_Time)) >= id(LD1125F_Mov_Time).state) { if ((time(NULL)-id(LD1125F_Last_Mov_Time))>id(LD1125F_Mov_Time).state) {
id(LD1125F_Occupancy).publish_state("Occupancy"); id(LD1125F_Occupancy).publish_state("Occupancy");
if (id(LD1125F_MovOcc_Binary).state == false) { if (id(LD1125F_MovOcc_Binary).state == false) {
id(LD1125F_MovOcc_Binary).publish_state(true); id(LD1125F_MovOcc_Binary).publish_state(true);
@ -235,12 +238,10 @@ binary_sensor:
name: ${upper_devicename} Occupancy or Movement name: ${upper_devicename} Occupancy or Movement
id: LD1125F_MovOcc_Binary id: LD1125F_MovOcc_Binary
device_class: occupancy device_class: occupancy
publish_initial_state: True
- platform: template - platform: template
name: ${upper_devicename} Movement name: ${upper_devicename} Movement
id: LD1125F_Mov_Binary id: LD1125F_Mov_Binary
device_class: motion device_class: motion
publish_initial_state: True
sensor: sensor:
- platform: template - platform: template
@ -257,7 +258,7 @@ sensor:
id: sys_esp_temperature id: sys_esp_temperature
name: ESP Temperature name: ESP Temperature
lambda: return temperatureRead(); lambda: return temperatureRead();
unit_of_measurement: "°C" unit_of_measurement: °C
device_class: TEMPERATURE device_class: TEMPERATURE
update_interval: 45s update_interval: 45s
entity_category: "diagnostic" entity_category: "diagnostic"
@ -265,7 +266,7 @@ sensor:
name: ESP Uptime name: ESP Uptime
id: sys_uptime id: sys_uptime
update_interval: 60s update_interval: 60s
- platform: wifi_signal - platform: wifi_signal
name: RSSI name: RSSI
id: wifi_signal_db id: wifi_signal_db
update_interval: 60s update_interval: 60s
@ -285,13 +286,11 @@ sensor:
icon: "mdi:signal-distance-variant" icon: "mdi:signal-distance-variant"
unit_of_measurement: "m" unit_of_measurement: "m"
accuracy_decimals: 2 accuracy_decimals: 2
update_interval: 0.2s # filters: # Use Fliter To Debounce
filters: # Use Fliter To Debounce # - sliding_window_moving_average:
#- heartbeat: 0.2s # window_size: 8
#- sliding_window_moving_average: # send_every: 2
# window_size: 8 # - heartbeat: 0.2s
# send_every: 2
- delta: 0%
- platform: bh1750 - platform: bh1750
name: "Illuminance" name: "Illuminance"
accuracy_decimals: 1 accuracy_decimals: 1
@ -349,7 +348,10 @@ interval:
setup_priority: -200 setup_priority: -200
then: then:
lambda: |- lambda: |-
if ((time(NULL)-id(LD1125F_Last_Time)) >= id(LD1125F_Clear_Time).state) { if ((time(NULL)-id(LD1125F_Last_Time))>id(LD1125F_Clear_Time).state) {
if (id(LD1125F_Distance).state != 0){
id(LD1125F_Distance).publish_state(0);
}
if ((id(LD1125F_Clearence_Status) == false) || (id(LD1125F_Occupancy).state != "Clearance")) { if ((id(LD1125F_Clearence_Status) == false) || (id(LD1125F_Occupancy).state != "Clearance")) {
id(LD1125F_Occupancy).publish_state("Clearance"); id(LD1125F_Occupancy).publish_state("Clearance");
id(LD1125F_Clearence_Status) = true; id(LD1125F_Clearence_Status) = true;
@ -370,7 +372,7 @@ number:
optimistic: true optimistic: true
entity_category: config entity_category: config
restore_value: true #If you don't want to store the setting at ESP, set it to false. restore_value: true #If you don't want to store the setting at ESP, set it to false.
initial_value: 60 #Default mth1 Setting initial_value: "60.0" #Default mth1 Setting
min_value: 10.0 min_value: 10.0
max_value: 600.0 max_value: 600.0
step: 5.0 step: 5.0
@ -381,6 +383,10 @@ number:
data: !lambda |- data: !lambda |-
std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th1st.begin(), th1st.end()); return std::vector<uint8_t>(th1st.begin(), th1st.end());
- delay: 100ms
- uart.write: # save
id: LD1125F_UART_BUS
data: "save\r\n"
- platform: template - platform: template
name: ${upper_devicename} mth2 #mth2 is 2.8~8m Sensitivity. name: ${upper_devicename} mth2 #mth2 is 2.8~8m Sensitivity.
id: LD1125F_mth2 id: LD1125F_mth2
@ -388,7 +394,7 @@ number:
optimistic: true optimistic: true
entity_category: config entity_category: config
restore_value: true #If you don't want to store the setting at ESP, set it to false. restore_value: true #If you don't want to store the setting at ESP, set it to false.
initial_value: 30 #Default mth2 Setting initial_value: "30" #Default mth2 Setting
min_value: 5 min_value: 5
max_value: 300 max_value: 300
step: 5 step: 5
@ -399,6 +405,10 @@ number:
data: !lambda |- data: !lambda |-
std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th2st.begin(), th2st.end()); return std::vector<uint8_t>(th2st.begin(), th2st.end());
- delay: 100ms
- uart.write: # save
id: LD1125F_UART_BUS
data: "save\r\n"
- platform: template - platform: template
name: ${upper_devicename} mth3 #mth3 is above 8m Sensitivity. name: ${upper_devicename} mth3 #mth3 is above 8m Sensitivity.
id: LD1125F_mth3 id: LD1125F_mth3
@ -406,7 +416,7 @@ number:
entity_category: config entity_category: config
optimistic: true optimistic: true
restore_value: true #If you don't want to store the setting at ESP, set it to false. restore_value: true #If you don't want to store the setting at ESP, set it to false.
initial_value: 20 #Default mth3 Setting initial_value: "20" #Default mth3 Setting
min_value: 5 min_value: 5
max_value: 200 max_value: 200
step: 5 step: 5
@ -417,6 +427,10 @@ number:
data: !lambda |- data: !lambda |-
std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n";
return std::vector<uint8_t>(th3st.begin(), th3st.end()); return std::vector<uint8_t>(th3st.begin(), th3st.end());
- delay: 100ms
- uart.write: # save
id: LD1125F_UART_BUS
data: "save\r\n"
- platform: template - platform: template
name: ${upper_devicename} Max Distance #rmax is max detection distance. name: ${upper_devicename} Max Distance #rmax is max detection distance.
id: LD1125F_rmax id: LD1125F_rmax
@ -425,7 +439,7 @@ number:
optimistic: true optimistic: true
unit_of_measurement: m unit_of_measurement: m
restore_value: true #If you don't want to store the setting at ESP, set it to false. restore_value: true #If you don't want to store the setting at ESP, set it to false.
initial_value: 8 #Default rmax Setting initial_value: "8" #Default rmax Setting
min_value: 0.4 min_value: 0.4
max_value: 12 max_value: 12
step: 0.2 step: 0.2
@ -436,6 +450,33 @@ number:
data: !lambda |- data: !lambda |-
std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n";
return std::vector<uint8_t>(rmaxst.begin(), rmaxst.end()); return std::vector<uint8_t>(rmaxst.begin(), rmaxst.end());
- delay: 100ms
- uart.write: # save
id: LD1125F_UART_BUS
data: "save\r\n"
- platform: template
name: ${upper_devicename} LD1125F Refresh Rate
id: LD1125F_utons
icon: "mdi:refresh"
entity_category: config
optimistic: true
unit_of_measurement: ms
restore_value: true
initial_value: "100"
min_value: 100
max_value: 5000
step: 50
set_action:
then:
- uart.write:
id: LD1125F_UART_BUS
data: !lambda |-
std::string utonsst = "utons=" + std::to_string(x) + "\r\n";
return std::vector<uint8_t>(utonsst.begin(), utonsst.end());
- delay: 100ms
- uart.write: # save
id: LD1125F_UART_BUS
data: "save\r\n"
- platform: template - platform: template
name: ${upper_devicename} Clearence Time name: ${upper_devicename} Clearence Time
id: LD1125F_Clear_Time id: LD1125F_Clear_Time
@ -443,7 +484,7 @@ number:
optimistic: true optimistic: true
entity_category: config entity_category: config
restore_value: true #If you don't want to store the setting at ESP, set it to false. restore_value: true #If you don't want to store the setting at ESP, set it to false.
initial_value: 5 #LD1125F Mov/Occ > Clearence Time Here initial_value: "5" #LD1125F Mov/Occ > Clearence Time Here
min_value: 0.5 min_value: 0.5
max_value: 20 max_value: 20
step: 0.5 step: 0.5
@ -454,7 +495,8 @@ number:
optimistic: true optimistic: true
entity_category: config entity_category: config
restore_value: true #If you don't want to store the setting at ESP, set it to false. restore_value: true #If you don't want to store the setting at ESP, set it to false.
initial_value: 1 #LD1125F Mov > Occ Time Here initial_value: "1" #LD1125F Mov > Occ Time Here
min_value: 0.5 min_value: 0.5
max_value: 10 max_value: 10
step: 0.5 step: 0.5