mirror of
https://github.com/jdillenburg/esphome.git
synced 2026-01-08 22:40:39 -07:00
yaml
This commit is contained in:
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# Gitignore settings for ESPHome
|
||||
# This is an example and may include too much for your use-case.
|
||||
# You can modify this file to suit your needs.
|
||||
|
||||
# List of files to consider for check in
|
||||
!/garage-door-controller.yaml
|
||||
!/TFmini.h
|
||||
|
||||
# Default ignored files
|
||||
/.esphome/
|
||||
/secrets.yaml
|
||||
# Only check in files NOT ignored here
|
||||
/*.yaml
|
||||
|
||||
30
ADXL345.h
Normal file
30
ADXL345.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "esphome.h"
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_ADXL345_U.h>
|
||||
|
||||
class ADXL345Sensor : public PollingComponent {
|
||||
public:
|
||||
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
|
||||
Sensor *off_vertical = new Sensor();
|
||||
|
||||
ADXL345Sensor() : PollingComponent(100) { }
|
||||
|
||||
void setup() override {
|
||||
accel.begin();
|
||||
/* Set the range to whatever is appropriate for your project */
|
||||
// accel.setRange(ADXL345_RANGE_16_G);
|
||||
// accel.setRange(ADXL345_RANGE_8_G);
|
||||
// accel.setRange(ADXL345_RANGE_4_G);
|
||||
accel.setRange(ADXL345_RANGE_2_G);
|
||||
//
|
||||
}
|
||||
|
||||
void update() override {
|
||||
sensors_event_t event;
|
||||
accel.getEvent(&event);
|
||||
double pitch_amount = atan(event.acceleration.y / sqrt(pow(event.acceleration.x, 2) + pow(event.acceleration.z, 2))) * 180 / PI;
|
||||
double roll_amount = atan(-1 * event.acceleration.x / sqrt(pow(event.acceleration.y, 2) + pow(event.acceleration.z, 2))) * 180 / PI;
|
||||
off_vertical->publish_state(max(abs(pitch_amount), abs(roll_amount)));
|
||||
}
|
||||
};
|
||||
143
leapmmw_sensor.h
Normal file
143
leapmmw_sensor.h
Normal file
@@ -0,0 +1,143 @@
|
||||
#include "esphome.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
class leapmmw : public Component, public UARTDevice {
|
||||
public:
|
||||
leapmmw(UARTComponent *parent) : UARTDevice(parent) {}
|
||||
|
||||
void setup() override {
|
||||
//
|
||||
}
|
||||
|
||||
void publishNumber (std::string sensor, float resp) {
|
||||
auto get_numbers = App.get_numbers();
|
||||
for(int i = 0; i < get_numbers.size(); i++) {
|
||||
std::string name = get_numbers[i]->get_name();
|
||||
if(name.size() > 6 && name.find(sensor) !=std::string::npos) {
|
||||
get_numbers[i]->publish_state(resp);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void publishSwitch(std::string sensor, int state) {
|
||||
auto sens = App.get_switches();
|
||||
for(int i = 0; i < sens.size(); i++) {
|
||||
std::string name = sens[i]->get_name();
|
||||
if(name.size() > 2 && name.find(sensor) !=std::string::npos) {
|
||||
sens[i]->publish_state(state);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void getmmwConf(std::string mmwparam) {
|
||||
mmwparam = mmwparam + "\r";
|
||||
write_array(std::vector<unsigned char>(mmwparam.begin(), mmwparam.end()));
|
||||
}
|
||||
|
||||
int readline(int readch, char *buffer, int len)
|
||||
{
|
||||
static int pos = 0;
|
||||
int rpos;
|
||||
|
||||
if (readch > 0) {
|
||||
switch (readch) {
|
||||
case '\n': // Ignore new-lines
|
||||
break;
|
||||
case '\r': // Return on CR
|
||||
rpos = pos;
|
||||
pos = 0; // Reset position index ready for next time
|
||||
return rpos;
|
||||
default:
|
||||
if (pos < len-1) {
|
||||
buffer[pos++] = readch;
|
||||
buffer[pos] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No end of line has been found, so return -1.
|
||||
return -1;
|
||||
}
|
||||
std::string getline;
|
||||
|
||||
void loop() override {
|
||||
const int max_line_length = 40;
|
||||
static char buffer[max_line_length];
|
||||
|
||||
while (available()) {
|
||||
|
||||
if(readline(read(), buffer, max_line_length) >= 4) {
|
||||
std::string line = buffer;
|
||||
|
||||
// compare last line
|
||||
if (line.substr(0, 8) == "Response") {
|
||||
|
||||
// leapMMW:/>getSensitivity
|
||||
if (getline.substr(0, 24) == "leapMMW:/>getSensitivity" || getline.substr(0, 14) == "getSensitivity") {
|
||||
std::string getSensitivity = line.substr(9, 1);
|
||||
if (getSensitivity.empty()) {
|
||||
ESP_LOGD("custom", "Did not find a value for getSensitivity");
|
||||
} else {
|
||||
ESP_LOGD("custom", "The value of getSensitivity is: %f", parse_number<float>(getSensitivity).value());
|
||||
publishNumber("sensitivity", parse_number<float>(getSensitivity).value());
|
||||
}
|
||||
}
|
||||
|
||||
// leapMMW:/>getRange
|
||||
if (getline.substr(0, 18) == "leapMMW:/>getRange" || getline.substr(0, 8) == "getRange") {
|
||||
std::string getRange = line.substr(15, 4);
|
||||
if (getRange.empty()) {
|
||||
ESP_LOGD("custom", "Did not find a value for getRange");
|
||||
} else {
|
||||
ESP_LOGD("custom", "The value of getRange is: %f", parse_number<float>(getRange).value());
|
||||
publishNumber("distance", parse_number<float>(getRange).value());
|
||||
}
|
||||
}
|
||||
|
||||
// leapMMW:/>getLatency
|
||||
if (getline.substr(0, 20) == "leapMMW:/>getLatency" || getline.substr(0, 10) == "getLatency") {
|
||||
std::string getLatency = line.substr(15, 2);
|
||||
if (getLatency.empty()) {
|
||||
ESP_LOGD("custom", "Did not find a value for getLatency");
|
||||
} else {
|
||||
ESP_LOGD("custom", "The value of getLatency is: %f", parse_number<float>(getLatency).value());
|
||||
publishNumber("latency", parse_number<float>(getLatency).value());
|
||||
}
|
||||
}
|
||||
|
||||
// leapMMW:/>getLedMode
|
||||
if (getline.substr(0, 20) == "leapMMW:/>getLedMode" || getline.substr(0, 10) == "getLedMode") {
|
||||
std::string getLedMode = line.substr(11, 1);
|
||||
if (getLedMode.empty()) {
|
||||
ESP_LOGD("custom", "Did not find a value for getLedMode");
|
||||
} else {
|
||||
int led_state = parse_number<int>(getLedMode).value();
|
||||
ESP_LOGD("custom", "The value of getLedMode is: %i", led_state);
|
||||
int setled_state = -1;
|
||||
if (led_state == 1) {
|
||||
setled_state = 0;
|
||||
} else if (led_state == 0) {
|
||||
setled_state = 1;
|
||||
}
|
||||
publishSwitch("led", setled_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (line.substr(0, 4) == "Done") {
|
||||
// leapMMW:/>sensorStop
|
||||
if (getline.substr(0, 20) == "leapMMW:/>sensorStop") {
|
||||
ESP_LOGD("custom", "sensorStop completed successfully");
|
||||
publishSwitch("mmwave_sensor", 0);
|
||||
}
|
||||
|
||||
// leapMMW:/>sensorStart
|
||||
if (getline.substr(0, 21) == "leapMMW:/>sensorStart") {
|
||||
ESP_LOGD("custom", "sensorStart completed successfully");
|
||||
publishSwitch("mmwave_sensor", 1);
|
||||
}
|
||||
}
|
||||
getline = buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
1
packages/.esphome/external_components/af6fb47d
Submodule
1
packages/.esphome/external_components/af6fb47d
Submodule
Submodule packages/.esphome/external_components/af6fb47d added at fc2ffe1409
1
packages/.esphome/external_components/d2e825de
Submodule
1
packages/.esphome/external_components/d2e825de
Submodule
Submodule packages/.esphome/external_components/d2e825de added at 836298f144
30
packages/beacon.yaml
Normal file
30
packages/beacon.yaml
Normal 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
200
packages/ld1115h.yaml
Normal 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
304
packages/ld1125h.yaml
Normal 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
164
packages/sen0395.yaml
Normal 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
|
||||
46
trash/3d-printer-camera.yaml
Normal file
46
trash/3d-printer-camera.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
esphome:
|
||||
name: 3d-printer-camera
|
||||
friendly_name: 3d-printer-camera
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "+b+DVoSdU4U5jlaO2hMcfj1SpIvrJS0nTY2VRz4ZJ8I="
|
||||
|
||||
ota:
|
||||
password: "eda8ea0564c19dafc36915ef38f83911"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "3D-Printer-Camera"
|
||||
password: "mhZotMxOa70S"
|
||||
|
||||
captive_portal:
|
||||
|
||||
esp32_camera:
|
||||
external_clock:
|
||||
pin: GPIO21
|
||||
frequency: 20MHz
|
||||
i2c_pins:
|
||||
sda: GPIO26
|
||||
scl: GPIO27
|
||||
data_pins: [GPIO4, GPIO5, GPIO18, GPIO19, GPIO36, GPIO39, GPIO34, GPIO35]
|
||||
vsync_pin: GPIO25
|
||||
href_pin: GPIO23
|
||||
pixel_clock_pin: GPIO22
|
||||
|
||||
# Image settings
|
||||
name: Camera
|
||||
resolution: 1024x768
|
||||
61
trash/adxl345-test.yaml
Normal file
61
trash/adxl345-test.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
esphome:
|
||||
name: adxl345-test
|
||||
friendly_name: ADXL345 Test
|
||||
|
||||
includes:
|
||||
- ADXL345.h
|
||||
libraries:
|
||||
- "Wire"
|
||||
- "SPI"
|
||||
- "Adafruit BusIO"
|
||||
- "Adafruit Unified Sensor"
|
||||
- "Adafruit ADXL345"
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "/v0qaJ9WNLlO/ceNxMjQN/4L1kDpg4xF3GB+huSE9uU="
|
||||
|
||||
ota:
|
||||
password: "d29c9732c14ab553c7b61cf7518893b8"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Adxl345-Test Fallback Hotspot"
|
||||
password: "51tWtojf169e"
|
||||
|
||||
captive_portal:
|
||||
|
||||
i2c:
|
||||
sda: 21
|
||||
scl: 22
|
||||
scan: true
|
||||
|
||||
sensor:
|
||||
- platform: custom
|
||||
lambda: |-
|
||||
auto adxl345 = new ADXL345Sensor();
|
||||
App.register_component(adxl345);
|
||||
return {
|
||||
adxl345->off_vertical
|
||||
};
|
||||
sensors:
|
||||
- name: "Off Vertical"
|
||||
unit_of_measurement: percentage
|
||||
filters:
|
||||
- sliding_window_moving_average:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
- lambda: return 100 * x / 45.0;
|
||||
31
trash/basement-stairs-led-controller.yaml
Normal file
31
trash/basement-stairs-led-controller.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
esphome:
|
||||
name: basement-stairs-led-controller
|
||||
friendly_name: basement stairs led controller
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "1zN1Evl3kkRYTLWmSw+iLL6Gpufn/QJru2X17YroAns="
|
||||
|
||||
ota:
|
||||
password: "d980c05ac4810f46717c0d8ea10b3b2b"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Led-Controller"
|
||||
password: "tJdG3X0m0TcY"
|
||||
|
||||
captive_portal:
|
||||
|
||||
31
trash/basement-stairs-mini.yaml
Normal file
31
trash/basement-stairs-mini.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
esphome:
|
||||
name: basement-stairs-mini
|
||||
friendly_name: basement stairs mini
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "He3sclXVKUDGA2Cv7Q0OxiOwpaAQ0CDRL8IkvfT8Zsc="
|
||||
|
||||
ota:
|
||||
password: "8ded3b7c8f13033cbf018b5672b74b21"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Mini"
|
||||
password: "4HwDF0m7w9Zb"
|
||||
|
||||
captive_portal:
|
||||
|
||||
39
trash/basement-stairs-mmwave-c3.yaml
Normal file
39
trash/basement-stairs-mmwave-c3.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
substitutions:
|
||||
device_name: basement-stairs-mmwave-c3
|
||||
device_name_pretty: "basement stairs mmwave c3"
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${device_name_pretty}
|
||||
includes:
|
||||
- leapmmw_sensor.h
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG #You Can Use "INFO" Level
|
||||
baud_rate: 0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "m/VImzYhHfGuPU0NyGGiP/6tJlcv8JPy9pDXG2UtqiE="
|
||||
|
||||
ota:
|
||||
password: "ebfa17f36e2d90de09facad6650e8944"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Mmwave-C3"
|
||||
password: "uoD8kJDKcaXq"
|
||||
|
||||
captive_portal:
|
||||
|
||||
199
trash/basement-stairs-mmwave-sensor.yaml
Normal file
199
trash/basement-stairs-mmwave-sensor.yaml
Normal file
@@ -0,0 +1,199 @@
|
||||
substitutions:
|
||||
device_name: basement-stairs-mmwave-sensor
|
||||
device_name_pretty: "basement stairs mmwave sensor"
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${device_name_pretty}
|
||||
includes:
|
||||
- leapmmw_sensor.h
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG #You Can Use "INFO" Level
|
||||
baud_rate: 0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "gNh+IsnVWnhDp3rXf2hMHB7ZpAx6ScnZo1TCQxYibQg="
|
||||
|
||||
ota:
|
||||
password: "c56a9c1d07dc8f2eff30e19b961b405c"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Mmwave-Sensor"
|
||||
password: "zwj6vOqPQePO"
|
||||
|
||||
captive_portal:
|
||||
|
||||
uart:
|
||||
id: SEN095_UART_BUS
|
||||
rx_pin: GPIO16
|
||||
tx_pin: GPIO17
|
||||
baud_rate: 115200
|
||||
data_bits: 8
|
||||
stop_bits: 1
|
||||
parity: NONE
|
||||
|
||||
# Example configuration entry
|
||||
dfrobot_sen0395:
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
name: "${device_name_pretty}"
|
||||
id: mmwave_presence_detection
|
||||
device_class: motion
|
||||
pin:
|
||||
number: 27
|
||||
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: safe_mode
|
||||
name: use_safe_mode
|
||||
|
||||
- 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
|
||||
232
trash/basement-stairs-presence-sensor.yaml
Normal file
232
trash/basement-stairs-presence-sensor.yaml
Normal file
@@ -0,0 +1,232 @@
|
||||
# https://wiki.dfrobot.com/mmWave_Radar_Human_Presence_Detection_SKU_SEN0395
|
||||
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html
|
||||
substitutions:
|
||||
device_name: basement-stairs-presence-sensor
|
||||
device_name_pretty: "basement stairs presence sensor"
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${device_name_pretty}
|
||||
includes:
|
||||
- leapmmw_sensor.h
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "KxojXV7TOX//Kmk+sZZmq4jOXc1DgdJ0Va9SQE4hajk="
|
||||
|
||||
ota:
|
||||
password: "4ad514a273ab653495d4389be22df9e8"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Mmwave-Sensor"
|
||||
password: "zwj6vOqPQePO"
|
||||
|
||||
captive_portal:
|
||||
|
||||
uart:
|
||||
id: SEN095_UART_BUS
|
||||
rx_pin: GPIO0
|
||||
tx_pin: GPIO1
|
||||
baud_rate: 115200
|
||||
data_bits: 8
|
||||
stop_bits: 1
|
||||
parity: NONE
|
||||
|
||||
# Example configuration entry
|
||||
dfrobot_sen0395:
|
||||
|
||||
light:
|
||||
- platform: neopixelbus
|
||||
id: status_light
|
||||
type: GRB
|
||||
variant: WS2811
|
||||
pin: GPIO8
|
||||
num_leds: 1
|
||||
name: "Status Light"
|
||||
internal: True
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
name: "${device_name_pretty}"
|
||||
id: mmwave_presence_detection
|
||||
device_class: motion
|
||||
pin:
|
||||
number: 10
|
||||
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);
|
||||
}
|
||||
- light.turn_on:
|
||||
id: status_light
|
||||
brightness: 100%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
on_release:
|
||||
then:
|
||||
- light.turn_off: status_light
|
||||
|
||||
|
||||
sensor:
|
||||
- platform: custom
|
||||
lambda: |-
|
||||
auto s = new leapmmw(id(SEN095_UART_BUS));
|
||||
App.register_component(s);
|
||||
return {};
|
||||
sensors:
|
||||
- platform: ultrasonic
|
||||
trigger_pin: 4
|
||||
echo_pin: 5
|
||||
name: "Ultrasonic Sensor"
|
||||
update_interval: 100ms
|
||||
timeout: 4m
|
||||
pulse_time: 10us
|
||||
filters:
|
||||
- filter_out: nan
|
||||
- sliding_window_moving_average:
|
||||
window_size: 10
|
||||
send_every: 10
|
||||
|
||||
|
||||
switch:
|
||||
- platform: safe_mode
|
||||
name: use_safe_mode
|
||||
|
||||
- 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
|
||||
|
||||
31
trash/basement-stairs-upper-motion-sensor.yaml
Normal file
31
trash/basement-stairs-upper-motion-sensor.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
esphome:
|
||||
name: basement-stairs-upper-motion-sensor
|
||||
friendly_name: basement stairs upper motion sensor
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "JAlRbqj1ibnN5gMo3eXS/7jqSaaTbSy09APYSWNUb0c="
|
||||
|
||||
ota:
|
||||
password: "90e404650dd4953147f82e5e257be7b5"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Upper-Motion-Sensor"
|
||||
password: "higGVbGCXDPT"
|
||||
|
||||
captive_portal:
|
||||
|
||||
64
trash/basement-stairs.yaml
Normal file
64
trash/basement-stairs.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
esphome:
|
||||
name: "basement-stairs"
|
||||
friendly_name: basement stairs upper motion
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "J1Pl6cIH8ormuwRNFrCU49bVDtFAOE+4r4oboq8gJnM="
|
||||
|
||||
ota:
|
||||
password: "d735909e801bb482b0989c3befb43865"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Basement-Stairs-Upper-Motion"
|
||||
password: "sFbohjRvYyMn"
|
||||
|
||||
captive_portal:
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin: GPIO7
|
||||
name: "PIR Sensor"
|
||||
device_class: motion
|
||||
on_press:
|
||||
then:
|
||||
light.turn_on:
|
||||
id: status_light
|
||||
red: 10%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
on_release:
|
||||
then:
|
||||
light.turn_off: status_light
|
||||
|
||||
|
||||
light:
|
||||
- platform: neopixelbus
|
||||
id: status_light
|
||||
type: GRB
|
||||
variant: WS2811
|
||||
pin: GPIO8
|
||||
num_leds: 1
|
||||
name: "Status Light"
|
||||
internal: True
|
||||
|
||||
- platform: neopixelbus
|
||||
type: GRB
|
||||
variant: WS2811
|
||||
pin: GPIO9
|
||||
num_leds: 60
|
||||
name: "Stairs Right"
|
||||
231
trash/bed-controller.yaml
Normal file
231
trash/bed-controller.yaml
Normal file
@@ -0,0 +1,231 @@
|
||||
esphome:
|
||||
name: bed-controller
|
||||
friendly_name: Bed Controller
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "uyMwFllQp/7nzMdnRhAqybJymJ/IjqIl+yf1QtDEw/s="
|
||||
|
||||
ota:
|
||||
password: "db4d5c0eeda9ef797ebbfbaa2b397720"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Bed-Controller Fallback Hotspot"
|
||||
password: "vHlYMuWAHvnp"
|
||||
|
||||
captive_portal:
|
||||
|
||||
# Sync time with Home Assistant.
|
||||
time:
|
||||
- platform: homeassistant
|
||||
id: homeassistant_time
|
||||
|
||||
# Text sensors with general information.
|
||||
text_sensor:
|
||||
# Expose ESPHome version as sensor.
|
||||
- platform: version
|
||||
name: ESPHome Version
|
||||
# Expose WiFi information as sensors.
|
||||
- platform: wifi_info
|
||||
ip_address:
|
||||
name: IP
|
||||
ssid:
|
||||
name: SSID
|
||||
bssid:
|
||||
name: BSSID
|
||||
|
||||
switch:
|
||||
- platform: restart
|
||||
name: "Restart"
|
||||
|
||||
globals:
|
||||
- id: min_speed
|
||||
type: float
|
||||
restore_value: False
|
||||
initial_value: '10'
|
||||
- id: motor_speed
|
||||
type: float
|
||||
restore_value: False
|
||||
initial_value: id(min_speed)
|
||||
- id: num_speeds
|
||||
type: int
|
||||
restore_value: False
|
||||
initial_value: '4'
|
||||
|
||||
output:
|
||||
- platform: ledc
|
||||
pin: GPIO32
|
||||
id: motor_forward_pin
|
||||
- platform: ledc
|
||||
pin: GPIO33
|
||||
id: motor_reverse_pin
|
||||
- platform: ledc
|
||||
pin: GPIO25
|
||||
id: motor_enable
|
||||
|
||||
|
||||
fan:
|
||||
- platform: hbridge
|
||||
id: bed_motor
|
||||
name: "Bed Motor"
|
||||
pin_a: motor_forward_pin
|
||||
pin_b: motor_reverse_pin
|
||||
enable_pin: motor_enable
|
||||
# enable_pin: motor_enable
|
||||
decay_mode: slow
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
name: Lower limit (meters)
|
||||
id: bed_lower_limit
|
||||
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: "0.04" # Default bed_lower_limit Setting
|
||||
min_value: 0.0
|
||||
max_value: 2.0
|
||||
step: 0.01
|
||||
on_value:
|
||||
then:
|
||||
- script.execute: start_motor_if_needed
|
||||
- platform: template
|
||||
name: Upper limit (meters)
|
||||
id: bed_upper_limit
|
||||
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: "0.9" # Default bed_upper_limit Setting
|
||||
min_value: 0.0
|
||||
max_value: 2.0
|
||||
step: 0.01
|
||||
on_value:
|
||||
then:
|
||||
- script.execute: start_motor_if_needed
|
||||
- platform: template
|
||||
name: Accuracy
|
||||
id: accuracy
|
||||
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: "2.0" # Default accuracy Setting 2%
|
||||
min_value: 0.0
|
||||
max_value: 100.0
|
||||
step: 1.0
|
||||
on_value:
|
||||
then:
|
||||
- script.execute: start_motor_if_needed
|
||||
- platform: template
|
||||
name: Desired percentage
|
||||
id: bed_desired_position
|
||||
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: "0.0" # Default desired position Setting
|
||||
min_value: 0.0
|
||||
max_value: 100.0
|
||||
step: 1.0
|
||||
unit_of_measurement: percentage
|
||||
on_value:
|
||||
then:
|
||||
- script.execute: start_motor_if_needed
|
||||
|
||||
sensor:
|
||||
- platform: ultrasonic
|
||||
trigger_pin: GPIO27
|
||||
echo_pin: GPIO14
|
||||
name: "Bed Position"
|
||||
update_interval: 0.1s
|
||||
id: bed_position
|
||||
accuracy_decimals: 0
|
||||
unit_of_measurement: percentage
|
||||
filters:
|
||||
- filter_out: nan
|
||||
- sliding_window_moving_average:
|
||||
window_size: 10
|
||||
send_every: 10
|
||||
- lambda: return 100.0 * (x - id(bed_lower_limit).state) / ( id(bed_upper_limit).state - id(bed_lower_limit).state );
|
||||
on_value:
|
||||
then:
|
||||
- script.execute: start_motor_if_needed
|
||||
|
||||
script:
|
||||
- id: calc_motor_speed
|
||||
then:
|
||||
- lambda: |-
|
||||
float diff = abs(id(bed_desired_position).state - id(bed_position).state);
|
||||
float speed_size = 100.0 / id(num_speeds);
|
||||
if (diff > 20) {
|
||||
id(motor_speed) = 100.0;
|
||||
}
|
||||
else if (diff > 10 && id(num_speeds) > 1) {
|
||||
id(motor_speed) = speed_size * 2;
|
||||
}
|
||||
else {
|
||||
id(motor_speed) = speed_size;
|
||||
}
|
||||
- id: start_motor_if_needed
|
||||
then:
|
||||
- script.execute: calc_motor_speed
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(bed_position).state < -id(accuracy).state;'
|
||||
then:
|
||||
- logger.log: 'bed lower then lower limit!'
|
||||
- fan.turn_on:
|
||||
id: bed_motor
|
||||
direction: FORWARD
|
||||
speed:
|
||||
!lambda |-
|
||||
return id(motor_speed);
|
||||
else:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(bed_position).state > 100.0 + id(accuracy).state;'
|
||||
then:
|
||||
- logger.log: 'bed higher than high limit!'
|
||||
- fan.turn_on:
|
||||
id: bed_motor
|
||||
direction: REVERSE
|
||||
speed:
|
||||
!lambda |-
|
||||
return id(motor_speed);
|
||||
else:
|
||||
- if:
|
||||
condition:
|
||||
- lambda: 'return id(bed_position).state < id(bed_desired_position).state - id(accuracy).state;'
|
||||
then:
|
||||
- logger.log: 'bed lower than desired, moving up'
|
||||
- fan.turn_on:
|
||||
id: bed_motor
|
||||
direction: FORWARD
|
||||
speed:
|
||||
!lambda |-
|
||||
return id(motor_speed);
|
||||
else:
|
||||
- if:
|
||||
condition:
|
||||
- lambda: 'return id(bed_position).state > id(bed_desired_position).state + id(accuracy).state;'
|
||||
then:
|
||||
- logger.log: 'bed higher than desired, moving down'
|
||||
- fan.turn_on:
|
||||
id: bed_motor
|
||||
direction: REVERSE
|
||||
speed:
|
||||
!lambda |-
|
||||
return id(motor_speed);
|
||||
else:
|
||||
- fan.turn_off: bed_motor
|
||||
31
trash/corner-sump-pump-water-level-sensor.yaml
Normal file
31
trash/corner-sump-pump-water-level-sensor.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
esphome:
|
||||
name: corner-sump-pump-water-level-sensor
|
||||
friendly_name: corner-sump-pump-water-level-sensor
|
||||
|
||||
esp32:
|
||||
board: esp32-c3-devkitm-1
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "/h9vgMgrlzY8kYJAiUxFnk4uEopKs1NsacRHOG7jbKQ="
|
||||
|
||||
ota:
|
||||
password: "2420232558a55e485717e5a3410caac4"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Corner-Sump-Pump-Water-Level-Sensor"
|
||||
password: "dzFmWniE42y7"
|
||||
|
||||
captive_portal:
|
||||
|
||||
39
trash/corner-sump-water-level-sensor.yaml
Normal file
39
trash/corner-sump-water-level-sensor.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
esphome:
|
||||
name: corner-sump-water-level-sensor
|
||||
friendly_name: corner-sump-water-level-sensor
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "92TRSyzjZq5bbw8/wipmn7zWZWC2XPmxNEbJZv6+M30="
|
||||
|
||||
ota:
|
||||
password: "18cb2f0dd54a6bd7e56c3e5e79efe314"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Corner-Sump-Water-Level-Sensor"
|
||||
password: "UGeBCJnN3PX2"
|
||||
|
||||
captive_portal:
|
||||
|
||||
# https://learn.sparkfun.com/tutorials/esp32-thing-plus-hookup-guide/all
|
||||
# https://esphome.io/components/i2c.html#
|
||||
# https://learn.sparkfun.com/tutorials/qwiic-ultrasonic-distance-sensor-hc-sr04-hookup-guide/all
|
||||
i2c:
|
||||
sda: GPIO01
|
||||
scl: GPIO02
|
||||
scan: true
|
||||
id: bus_a
|
||||
50
trash/garage-camera.yaml
Normal file
50
trash/garage-camera.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
esphome:
|
||||
name: garage-camera
|
||||
friendly_name: Garage Camera
|
||||
comment: esp32dev
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "6o4U+71ZOTxfjpi1mTOG6ThajzFEWEyJPJdKk/0nUAg="
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: "ef8d191e2007e0fe89477dd296817f25"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Garage-Camera Fallback Hotspot"
|
||||
password: "VotNjbPdTfyf"
|
||||
|
||||
captive_portal:
|
||||
|
||||
esp32_camera:
|
||||
external_clock:
|
||||
pin: GPIO21
|
||||
frequency: 20MHz
|
||||
i2c_pins:
|
||||
sda: GPIO26
|
||||
scl: GPIO27
|
||||
data_pins: [GPIO4, GPIO5, GPIO18, GPIO19, GPIO36, GPIO39, GPIO34, GPIO35]
|
||||
vsync_pin: GPIO25
|
||||
href_pin: GPIO23
|
||||
pixel_clock_pin: GPIO22
|
||||
|
||||
# Image settings
|
||||
name: Camera
|
||||
resolution: 1024x768
|
||||
vertical_flip: false
|
||||
horizontal_mirror: false
|
||||
68
trash/garage-ha-master.yaml
Normal file
68
trash/garage-ha-master.yaml
Normal file
@@ -0,0 +1,68 @@
|
||||
esphome:
|
||||
name: garage-ha-master
|
||||
friendly_name: garage-ha-master
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "voq2rWJn8dFl/rtHRAqAnIipjcwWqdh/WAAn6BEle3Y="
|
||||
|
||||
ota:
|
||||
password: "84faa1ee621712bd8c06f8382b7c1fda"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Garage-Ha-Master"
|
||||
password: "0OyBvaAOSOcL"
|
||||
|
||||
captive_portal:
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||
components: [ serial ]
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
baud_rate: 0
|
||||
|
||||
uart:
|
||||
rx_pin: GPIO22
|
||||
tx_pin: GPIO23
|
||||
baud_rate: 9600
|
||||
data_bits: 8
|
||||
stop_bits: 2
|
||||
parity: NONE
|
||||
debug:
|
||||
direction: BOTH
|
||||
dummy_receiver: false
|
||||
after:
|
||||
delimiter: "\n"
|
||||
sequence:
|
||||
- lambda: UARTDebug::log_string(direction, bytes);
|
||||
|
||||
text_sensor:
|
||||
- platform: serial
|
||||
name: Received slave text
|
||||
id: slave_text
|
||||
|
||||
text:
|
||||
- platform: template
|
||||
mode: text
|
||||
name: Send to slave
|
||||
id: send_to_slave
|
||||
set_action:
|
||||
then:
|
||||
- uart.write: !lambda |-
|
||||
std::string sendme = x + "\n";
|
||||
return std::vector<uint8_t>(sendme.begin(), sendme.end());
|
||||
87
trash/garage-ha-slave.yaml
Normal file
87
trash/garage-ha-slave.yaml
Normal file
@@ -0,0 +1,87 @@
|
||||
packages:
|
||||
beacon: !include packages/beacon.yaml
|
||||
|
||||
esphome:
|
||||
name: garage-ha-slave
|
||||
friendly_name: garage-ha-slave
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
# do not log to serial
|
||||
baud_rate: 0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "SUI+2tAU4QM6jDKw4utdwmpFKyZrvoCD4IyJ8+OmwU4="
|
||||
# disable reboot because we disconnect to scan wifi
|
||||
reboot_timeout: 0s
|
||||
|
||||
ota:
|
||||
password: "d55d376ed4bcfee485afea8865120189"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Garage-Ha-Slave Fallback Hotspot"
|
||||
password: "g3K334QqPiX7"
|
||||
|
||||
captive_portal:
|
||||
|
||||
esp32_ble_tracker:
|
||||
scan_parameters:
|
||||
window: 120ms
|
||||
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||
components: [ serial ]
|
||||
|
||||
uart:
|
||||
rx_pin: GPIO22
|
||||
tx_pin: GPIO23
|
||||
baud_rate: 9600
|
||||
data_bits: 8
|
||||
stop_bits: 2
|
||||
parity: NONE
|
||||
# debug:
|
||||
# direction: BOTH
|
||||
# dummy_receiver: false
|
||||
# after:
|
||||
# delimiter: "\n"
|
||||
# sequence:
|
||||
# - lambda: UARTDebug::log_string(direction, bytes);
|
||||
|
||||
text_sensor:
|
||||
- platform: serial
|
||||
name: Received master text
|
||||
id: master_text
|
||||
- platform: wifi_info
|
||||
scan_results:
|
||||
name: ESP Latest Scan Results
|
||||
id: scan_results
|
||||
|
||||
text:
|
||||
- platform: template
|
||||
mode: text
|
||||
name: Send to master
|
||||
id: send_to_master
|
||||
set_action:
|
||||
then:
|
||||
- uart.write: !lambda |-
|
||||
std::string sendme = x + "\n";
|
||||
return std::vector<uint8_t>(sendme.begin(), sendme.end());
|
||||
|
||||
|
||||
|
||||
|
||||
70
trash/garage-master.yaml
Normal file
70
trash/garage-master.yaml
Normal file
@@ -0,0 +1,70 @@
|
||||
esphome:
|
||||
name: garage-master
|
||||
friendly_name: garage-master
|
||||
comment: esp32dev
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Disable logging
|
||||
logger:
|
||||
baud_rate: 0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "RoWkhYIHXIB92Q4zNPcweZvZgWSChT1A1oRmD2hRolk="
|
||||
|
||||
ota:
|
||||
password: "c279b490f4994e36755058ed0e40460b"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Garage-Master Fallback Hotspot"
|
||||
password: "a5ZRCKrJLKVt"
|
||||
|
||||
captive_portal:
|
||||
|
||||
uart:
|
||||
rx_pin: GPIO1
|
||||
tx_pin: GPIO3
|
||||
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);
|
||||
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||
components: [ serial ]
|
||||
|
||||
|
||||
# text_sensor:
|
||||
# - platform: serial
|
||||
# name: Slave text
|
||||
|
||||
text:
|
||||
- platform: template
|
||||
mode: text
|
||||
name: Send to slave
|
||||
id: send_to_slave
|
||||
set_action:
|
||||
then:
|
||||
- uart.write: !lambda |-
|
||||
std::string sendme = x + "\n";
|
||||
return std::vector<uint8_t>(sendme.begin(), sendme.end());
|
||||
69
trash/garage-master2.yaml
Normal file
69
trash/garage-master2.yaml
Normal file
@@ -0,0 +1,69 @@
|
||||
esphome:
|
||||
name: garage-control-master2
|
||||
friendly_name: garage-control-master2
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||
components: [ serial ]
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
baud_rate: 0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "ku0BYi9By5cFFEYDyETyZmszDR7Jphpz24uJzIbQTrg="
|
||||
|
||||
ota:
|
||||
password: "38913e884c1425dd1757bf7606abf233"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Garage-Master2 Fallback Hotspot"
|
||||
password: "fRCUAI46FNga"
|
||||
|
||||
captive_portal:
|
||||
|
||||
|
||||
uart:
|
||||
rx_pin: GPIO22
|
||||
tx_pin: GPIO23
|
||||
baud_rate: 9600
|
||||
data_bits: 8
|
||||
stop_bits: 1
|
||||
parity: NONE
|
||||
debug:
|
||||
direction: BOTH
|
||||
dummy_receiver: false
|
||||
after:
|
||||
delimiter: "\n"
|
||||
sequence:
|
||||
- lambda: UARTDebug::log_string(direction, bytes);
|
||||
|
||||
text_sensor:
|
||||
- platform: serial
|
||||
name: Received slave text
|
||||
id: slave_text
|
||||
|
||||
text:
|
||||
- platform: template
|
||||
mode: text
|
||||
name: Send to slave
|
||||
id: send_to_slave
|
||||
set_action:
|
||||
then:
|
||||
- uart.write: !lambda |-
|
||||
std::string sendme = x + "\n";
|
||||
return std::vector<uint8_t>(sendme.begin(), sendme.end());
|
||||
63
trash/garage-slave.yaml
Normal file
63
trash/garage-slave.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
esphome:
|
||||
name: garage-wifi-slave
|
||||
friendly_name: garage-wifi-slave
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Disable logging
|
||||
logger:
|
||||
baud_rate: 0
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "M64t2wRHjGVpPBAu6AxxRKY3WyZLdB3yK7jQOJyE5AU="
|
||||
|
||||
ota:
|
||||
password: "abf5c4123fd2db9bf4c5aef1237f4243"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Garage-Slave Fallback Hotspot"
|
||||
password: "f2XLmIgz8PaN"
|
||||
|
||||
captive_portal:
|
||||
|
||||
|
||||
uart:
|
||||
rx_pin: GPIO22
|
||||
tx_pin: GPIO23
|
||||
baud_rate: 9600
|
||||
data_bits: 8
|
||||
stop_bits: 1
|
||||
parity: NONE
|
||||
debug:
|
||||
direction: BOTH
|
||||
dummy_receiver: false
|
||||
after:
|
||||
delimiter: "\n"
|
||||
sequence:
|
||||
- lambda: UARTDebug::log_string(direction, bytes);
|
||||
|
||||
# text_sensor:
|
||||
# - platform: serial
|
||||
# id: master_text
|
||||
# name: Master text
|
||||
|
||||
text:
|
||||
- platform: template
|
||||
mode: text
|
||||
name: Send to master
|
||||
id: send_to_master
|
||||
set_action:
|
||||
then:
|
||||
- uart.write: !lambda |-
|
||||
std::string sendme = x + "\n";
|
||||
return std::vector<uint8_t>(sendme.begin(), sendme.end());
|
||||
48
trash/hires-camera.yaml
Normal file
48
trash/hires-camera.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
esphome:
|
||||
name: hires-camera
|
||||
friendly_name: HiRes Camera
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "6qCk7lS2wL6m4yWXWy/9vj1/sY2nS3PBHEQNnS3b4z8="
|
||||
|
||||
ota:
|
||||
password: "659656f65e27665316018491a0b247ba"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Hires-Camera Fallback Hotspot"
|
||||
password: "FMUtqFrZ3eUN"
|
||||
|
||||
captive_portal:
|
||||
|
||||
esp32_camera:
|
||||
external_clock:
|
||||
pin: GPIO21
|
||||
frequency: 20MHz
|
||||
i2c_pins:
|
||||
sda: GPIO26
|
||||
scl: GPIO27
|
||||
data_pins: [GPIO4, GPIO5, GPIO18, GPIO19, GPIO36, GPIO39, GPIO34, GPIO35]
|
||||
vsync_pin: GPIO25
|
||||
href_pin: GPIO23
|
||||
pixel_clock_pin: GPIO22
|
||||
|
||||
# Image settings
|
||||
name: Camera
|
||||
resolution: 1600x1200
|
||||
jpeg_quality: 20
|
||||
max_framerate: 20 fps
|
||||
338
trash/mmwave-detector1.yaml
Normal file
338
trash/mmwave-detector1.yaml
Normal file
@@ -0,0 +1,338 @@
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "xyD+0n3g/k38yhwyo8uE2uMZQM/Ik5ltCUKKC3tFCv8="
|
||||
|
||||
ota:
|
||||
password: "f0c5694107ac2f6a4beb6d18b0e39bb5"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
power_save_mode: LIGHT
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Mmwave-Detector1"
|
||||
password: "qDakHkuHkpRO"
|
||||
|
||||
substitutions:
|
||||
devicename: "mmwave-detector1" #Rename the device what you want.
|
||||
upper_devicename: ESP Radar #Rename the device what you want.
|
||||
esphome:
|
||||
name: $devicename
|
||||
friendly_name: $devicename
|
||||
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());
|
||||
esp32:
|
||||
board: nodemcu-32s
|
||||
framework:
|
||||
type: arduino
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||
components: [ serial ]
|
||||
logger:
|
||||
level: DEBUG #You Can Use "INFO" Level
|
||||
baud_rate: 0
|
||||
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
|
||||
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 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: 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: False #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
|
||||
|
||||
339
trash/mmwave-detector3.yaml
Normal file
339
trash/mmwave-detector3.yaml
Normal file
@@ -0,0 +1,339 @@
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "eBrxqMp+lU7nOEmQBcl5hZsexSr+NcdhF6xa/0HPbig="
|
||||
|
||||
ota:
|
||||
password: "7ca0ac054d39eec0e41ab0e28b7916ee"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Mmwave-Detector3"
|
||||
password: "xNAPBrJVQfuy"
|
||||
|
||||
captive_portal:
|
||||
substitutions:
|
||||
devicename: "mmwave-detector3" #Rename the device what you want.
|
||||
upper_devicename: ESP Radar #Rename the device what you want.
|
||||
esphome:
|
||||
name: $devicename
|
||||
friendly_name: $devicename
|
||||
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());
|
||||
esp32:
|
||||
board: nodemcu-32s
|
||||
framework:
|
||||
type: arduino
|
||||
external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/ssieb/custom_components #Thanks for @ssieb components.
|
||||
components: [ serial ]
|
||||
logger:
|
||||
level: DEBUG #You Can Use "INFO" Level
|
||||
baud_rate: 0
|
||||
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
|
||||
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 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: 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: False #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
|
||||
|
||||
32
trash/mmwave-georgias-room.yaml
Normal file
32
trash/mmwave-georgias-room.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
esphome:
|
||||
name: mmwave-georgias-room
|
||||
friendly_name: mmwave-georgias-room
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: arduino
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: "vV0VUgxpbVcQrDGzuFY11LcGK5VJqe74NJpIZ3h8JXk="
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: "d97940b1e0e73dec0830379228389185"
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Mmwave-Georgias-Room"
|
||||
password: "vzn4DYKUeR6m"
|
||||
|
||||
captive_portal:
|
||||
|
||||
Reference in New Issue
Block a user