substitutions: # fixed offset for the enclosure warming up (not shown in HA), always added before the user offset temp_fixed_offset: "-3.5" esphome: name: presence-sensor name_add_mac_suffix: true friendly_name: Presence Sensor esp32: board: m5stack-atom cpu_frequency: 80MHZ framework: type: esp-idf logger: level: INFO api: encryption: key: !secret api_key ota: - platform: esphome # encrypted with the api key above encryption: wifi: ap: ssid: "Sensor-Setup" captive_portal: improv_serial: i2c: sda: GPIO26 scl: GPIO32 scan: true uart: id: ld_uart rx_pin: GPIO22 # to the radar pin labelled RX tx_pin: GPIO19 # to the radar pin labelled TX baud_rate: 256000 parity: NONE stop_bits: 1 ld2410: uart_id: ld_uart sensor: - platform: sht3xd address: 0x44 temperature: name: "Temperature" filters: - lambda: return x + ${temp_fixed_offset} + id(temp_offset).state; humidity: name: "Humidity" id: humidity on_value: - script.execute: update_led update_interval: 10s - platform: qmp6988 temperature: name: "Temperature (QMP)" disabled_by_default: true filters: - lambda: return x + ${temp_fixed_offset} + id(temp_offset).state; pressure: name: "Pressure" update_interval: 60s - platform: wifi_signal name: "WiFi Signal" update_interval: 60s - platform: ld2410 moving_distance: name: "Moving Distance" still_distance: name: "Still Distance" moving_energy: name: "Move Energy" still_energy: name: "Still Energy" detection_distance: name: "Detection Distance" g0: {move_energy: {name: g0 move energy}, still_energy: {name: g0 still energy}} g1: {move_energy: {name: g1 move energy}, still_energy: {name: g1 still energy}} g2: {move_energy: {name: g2 move energy}, still_energy: {name: g2 still energy}} g3: {move_energy: {name: g3 move energy}, still_energy: {name: g3 still energy}} g4: {move_energy: {name: g4 move energy}, still_energy: {name: g4 still energy}} g5: {move_energy: {name: g5 move energy}, still_energy: {name: g5 still energy}} g6: {move_energy: {name: g6 move energy}, still_energy: {name: g6 still energy}} g7: {move_energy: {name: g7 move energy}, still_energy: {name: g7 still energy}} g8: {move_energy: {name: g8 move energy}, still_energy: {name: g8 still energy}} binary_sensor: - platform: ld2410 has_target: name: "Presence" has_moving_target: name: "Moving Target" id: moving on_state: - script.execute: update_led has_still_target: name: "Still Target" id: still on_state: - script.execute: update_led switch: - platform: template id: led_auto name: "LED Indicator" icon: mdi:led-on optimistic: true restore_mode: RESTORE_DEFAULT_ON turn_on_action: - script.execute: update_led turn_off_action: - light.turn_off: status_led - platform: ld2410 engineering_mode: name: "Engineering Mode" bluetooth: name: "Radar Bluetooth" number: - platform: template id: temp_offset name: "Temperature Offset" icon: mdi:thermometer-plus unit_of_measurement: "°C" min_value: -5 max_value: 5 step: 0.1 initial_value: 0 optimistic: true restore_value: true entity_category: config - platform: template id: led_brightness name: "LED Indicator Brightness" icon: mdi:brightness-6 unit_of_measurement: "%" min_value: 1 max_value: 100 step: 1 initial_value: 10 optimistic: true restore_value: true entity_category: config on_value: - script.execute: update_led - platform: template id: led_humidity_threshold name: "LED Humidity Threshold" icon: mdi:water-percent unit_of_measurement: "%" min_value: 40 max_value: 100 step: 1 initial_value: 70 optimistic: true restore_value: true entity_category: config on_value: - script.execute: update_led - platform: ld2410 timeout: name: "Timeout" max_move_distance_gate: name: "Max Move Distance Gate" max_still_distance_gate: name: "Max Still Distance Gate" g0: {move_threshold: {name: g0 move threshold}, still_threshold: {name: g0 still threshold}} g1: {move_threshold: {name: g1 move threshold}, still_threshold: {name: g1 still threshold}} g2: {move_threshold: {name: g2 move threshold}, still_threshold: {name: g2 still threshold}} g3: {move_threshold: {name: g3 move threshold}, still_threshold: {name: g3 still threshold}} g4: {move_threshold: {name: g4 move threshold}, still_threshold: {name: g4 still threshold}} g5: {move_threshold: {name: g5 move threshold}, still_threshold: {name: g5 still threshold}} g6: {move_threshold: {name: g6 move threshold}, still_threshold: {name: g6 still threshold}} g7: {move_threshold: {name: g7 move threshold}, still_threshold: {name: g7 still threshold}} g8: {move_threshold: {name: g8 move threshold}, still_threshold: {name: g8 still threshold}} select: - platform: ld2410 distance_resolution: name: "Distance Resolution" button: - platform: ld2410 restart: name: "Restart Radar" query_params: name: "Query Radar Parameters" - platform: restart name: "Restart" light: - platform: esp32_rmt_led_strip channel_colors: GRB pin: GPIO27 num_leds: 1 chipset: SK6812 name: "LED" id: status_led default_transition_length: 300ms # Indicator: orange = humidity >= threshold, blue = moving target, # green = still target, off = nobody there. Turning "LED Indicator" off # leaves the LED for manual control from HA. script: - id: update_led mode: restart then: - if: condition: switch.is_on: led_auto then: - lambda: |- auto call = id(status_led).make_call(); float h = id(humidity).state; bool humid = !std::isnan(h) && h >= id(led_humidity_threshold).state; bool moving_now = id(moving).state; bool still_now = id(still).state; if (humid) { call.set_rgb(1.0, 0.45, 0.0); } else if (moving_now) { call.set_rgb(0.0, 0.0, 1.0); } else if (still_now) { call.set_rgb(0.0, 1.0, 0.0); } if (humid || moving_now || still_now) { call.set_state(true); call.set_brightness(id(led_brightness).state / 100.0f); } else { call.set_state(false); } call.perform();