-
-
Save EverythingSmartHome/4f8c9d8e94bffb44c7b7965f172b6470 to your computer and use it in GitHub Desktop.
esphome: | |
name: mmwave-occupancy | |
esp8266: | |
board: esp01_1m | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
ota: | |
password: "password" | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "mmWave-Occupancy" | |
password: "password" | |
substitutions: | |
device_name: mmwave-sensor | |
captive_portal: | |
web_server: | |
port: 80 | |
version: 2 | |
include_internal: true | |
http_request: | |
useragent: esphome/$device_name | |
timeout: 2s | |
switch: | |
- platform: safe_mode | |
internal: true | |
name: use_safe_mode | |
binary_sensor: | |
- platform: gpio | |
name: mmwave_in_bedroom | |
pin: | |
number: GPIO16 | |
mode: INPUT_PULLDOWN | |
uart: | |
id: uart_bus | |
tx_pin: GPIO4 | |
rx_pin: GPIO5 | |
baud_rate: 115200 | |
debug: | |
direction: BOTH | |
dummy_receiver: true | |
after: | |
delimiter: "\n" | |
sequence: | |
- lambda: UARTDebug::log_string(direction, bytes); | |
number: | |
- platform: template | |
name: distance | |
id: distance | |
min_value: 0 | |
max_value: 1350 | |
initial_value: 315 | |
optimistic: true | |
step: 15 | |
restore_value: true | |
unit_of_measurement: cm | |
set_action: | |
- uart.write: "sensorStop" | |
- delay: 1s | |
- uart.write: !lambda | |
int cm = (int)ceil(x / 15.0); | |
std::string cms = "detRangeCfg -1 0 " + to_string(cm); | |
return std::vector<unsigned char>(cms.begin(), cms.end()); | |
- delay: 1s | |
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89" | |
- delay: 1s | |
- uart.write: "sensorStart" | |
- platform: template | |
name: latency | |
id: latency | |
min_value: 0 | |
max_value: 65000 | |
initial_value: 12500 | |
optimistic: true | |
step: 25 | |
restore_value: true | |
unit_of_measurement: ms | |
set_action: | |
- uart.write: "sensorStop" | |
- delay: 1s | |
- uart.write: !lambda | |
int ms = (int)ceil(x / 25.0); | |
std::string mss = "outputLatency -1 0 " + to_string(ms); | |
return std::vector<unsigned char>(mss.begin(), mss.end()); | |
- delay: 1s | |
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89" | |
- delay: 1s | |
- uart.write: "sensorStart" | |
button: | |
- platform: restart | |
name: Restart $device_name | |
- platform: template | |
name: "factory_reset_sensor" | |
id: "factory_reset_sensor" | |
on_press: | |
- uart.write: "sensorStop" | |
- delay: 1s | |
- uart.write: "factoryReset 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89" | |
- delay: 3s | |
- uart.write: "sensorStart" |
why you didnt define an uar.write sensorStart? could you post your yaml platform template configuration? i am getting errors with mine.
Edit:
so this si how it should be coded? it doesnt seem to work.
- platform: template
name: "turn off mmwave led"
id: "turn_off_led"
on_press:
- uart.write: "sensorStop"
- delay: 1s
- uart.write: "setLedMode 1 1"
- delay: 1s
- uart.write: "setUartOutput 1 0"
- delay: 1s
- uart.write: "setUartOutput 2 1 1 2"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- uart.write: "sensorStart"
- delay: 6s # the sum of mmwave_sensor delays
Great work! Will you publish the V2, @EverythingSmartHome ?
Just came here searching and asking for this.
Will you publish the code for this V2?
Since I have the stuff home, I'll build one, if it works nicely you can expect a new client for a maybe 4 units.
Yes, I desperately wanted that and it took me some google searches and trying but I managed to do it inspired by https://community.home-assistant.io/t/mmwave-presence-detection-esphome-style/382778 and https://github.com/hjmcnew/esphome-hs2xx3a-custom-component/blob/main/packages/leapmmw_sensor.yml
as follows:
Add the following in your esphome device yml:
name: "turn_off_mmWave_led"
id: turn_off_led
on_press:
following 2 lines commented because I have no leapmmw_sensor It works fine without
- lambda: |-
leapmmw(id(uart_bus)).getmmwConf("getLedMode 1");
install
add "turn_off_mmWave_led" to your dashboard and click
If you like you can make a boolean helper and an automation that runs this if the boolean is turned of and th turn on script if you turn it on.