Merge branch 'screekworkshop:main' into durd-patch-1
This commit is contained in:
commit
402c6f57f6
|
|
@ -21,6 +21,11 @@ esphome:
|
||||||
then:
|
then:
|
||||||
lambda: |-
|
lambda: |-
|
||||||
id(cpu_speed) = ESP.getCpuFreqMHz();
|
id(cpu_speed) = ESP.getCpuFreqMHz();
|
||||||
|
- priority: 300
|
||||||
|
then:
|
||||||
|
# 写入版本号,未来使用公共变量!(23年7月17日_13时29分_)
|
||||||
|
lambda: |-
|
||||||
|
id(screek_version).publish_state("V24.7.4_beta");
|
||||||
- priority: -200
|
- priority: -200
|
||||||
then:
|
then:
|
||||||
- uart.write:
|
- uart.write:
|
||||||
|
|
@ -28,21 +33,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
|
||||||
|
|
@ -125,6 +143,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,8 +175,24 @@ text_sensor:
|
||||||
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
|
||||||
on_value:
|
on_value:
|
||||||
lambda: |-
|
lambda: |-
|
||||||
float distance = atof(id(LD1125F_UART_Text).state.substr(9).c_str());
|
std::string uart_text = id(LD1125F_UART_Text).state;
|
||||||
if (id(LD1125F_UART_Text).state.substr(0,3) == "occ" && distance > 0) {
|
|
||||||
|
if (uart_text == "null"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float distance = -1;
|
||||||
|
std::string uart_state = "";
|
||||||
|
if (uart_text.length() > 3){
|
||||||
|
uart_state = id(LD1125F_UART_Text).state.substr(0,3);
|
||||||
|
if (uart_text.length() >= 9) {
|
||||||
|
if (uart_state == "occ" || uart_state =="mov") {
|
||||||
|
distance = std::stof(uart_text.substr(9));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
@ -170,7 +211,7 @@ text_sensor:
|
||||||
id(LD1125F_Clearence_Status) = false;
|
id(LD1125F_Clearence_Status) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id(LD1125F_UART_Text).state.substr(0,3) == "mov" && distance > 0) {
|
else if (uart_state == "mov" && distance > 0) {
|
||||||
id(LD1125F_Distance).publish_state(distance);
|
id(LD1125F_Distance).publish_state(distance);
|
||||||
id(LD1125F_Occupancy).publish_state("Movement");
|
id(LD1125F_Occupancy).publish_state("Movement");
|
||||||
if (id(LD1125F_MovOcc_Binary).state == false) {
|
if (id(LD1125F_MovOcc_Binary).state == false) {
|
||||||
|
|
@ -190,7 +231,6 @@ text_sensor:
|
||||||
id: LD1125F_Occupancy
|
id: LD1125F_Occupancy
|
||||||
icon: "mdi:motion-sensor"
|
icon: "mdi:motion-sensor"
|
||||||
|
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: status
|
- platform: status
|
||||||
name: Online
|
name: Online
|
||||||
|
|
@ -247,16 +287,18 @@ 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
|
||||||
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"
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
id: bh1750_light
|
id: bh1750_light
|
||||||
update_interval: 1s
|
update_interval: 1s
|
||||||
|
filters:
|
||||||
|
- delta: 0.1
|
||||||
|
|
||||||
light:
|
light:
|
||||||
- platform: status_led
|
- platform: status_led
|
||||||
|
|
@ -308,6 +350,10 @@ 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){
|
||||||
|
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;
|
||||||
|
|
@ -339,6 +385,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
|
||||||
|
|
@ -357,6 +407,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
|
||||||
|
|
@ -375,6 +429,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
|
||||||
|
|
@ -394,6 +452,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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user