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

@ -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:
@ -116,6 +115,8 @@ globals:
improv_serial: improv_serial:
logger: logger:
logs:
bh1750.sensor: INFO
debug: debug:
update_interval: 30s update_interval: 30s
@ -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;
@ -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"
@ -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

@ -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
@ -98,8 +115,6 @@ globals:
improv_serial: improv_serial:
logger: logger:
logs:
bh1750.sensor: INFO
debug: debug:
update_interval: 30s update_interval: 30s
@ -127,6 +142,13 @@ 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,30 +172,11 @@ 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 (uart_text == "null"){
if (id(LD1125F_Distance).state != 0) {
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;
} }
@ -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"
@ -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
#- heartbeat: 0.2s
# - sliding_window_moving_average: # - sliding_window_moving_average:
# window_size: 8 # window_size: 8
# send_every: 2 # send_every: 2
- delta: 0% # - heartbeat: 0.2s
- 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