mirror of
https://github.com/jdillenburg/esphome.git
synced 2026-03-19 04:39:18 -06:00
yaml
This commit is contained in:
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
|
||||
|
||||
Reference in New Issue
Block a user