diff --git a/archive/.gitignore b/archive/.gitignore deleted file mode 100644 index d8b4157..0000000 --- a/archive/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# 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. -/.esphome/ -/secrets.yaml diff --git a/archive/HLK-LD1115H_supersensor.yaml b/archive/HLK-LD1115H_supersensor.yaml deleted file mode 100644 index 0411f4f..0000000 --- a/archive/HLK-LD1115H_supersensor.yaml +++ /dev/null @@ -1,393 +0,0 @@ ---- - -############################################################################### -# SuperSensor v1.0 ESPHome configuration -############################################################################### -# -# Copyright (C) 2023 Joshua M. Boniface -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################### - -substitutions: - # How long a PIR activation should be held for - pir_holdtime: "15s" - -esphome: - name: supersensor - name_add_mac_suffix: true - friendly_name: "Supersensor" - project: - name: joshuaboniface.supersensor - version: "0.1" - includes: - - veml7700.h - libraries: - - "Wire" - - "Adafruit Unified Sensor" - - "SPI" - - "Adafruit BusIO" - - "Adafruit VEML7700 Library" - on_boot: - - priority: 600 - then: - - light.turn_on: - id: output_led - effect: flash - red: 1 - green: 1 - blue: 1 - -dashboard_import: - package_import_url: github://joshuaboniface/supersensor/supersensor.yaml - import_full_config: false - -esp32: - board: esp32dev -# framework: -# type: esp-idf -# sdkconfig_options: -# CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" -# CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" -# CONFIG_ESP32_DATA_CACHE_64KB: "y" -# CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" -# CONFIG_ESP32S3_DATA_CACHE_64KB: "y" -# CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -script: - - id: pir_handler - then: - - lambda: |- - id(pir_motion).publish_state(true); - - while: - condition: - binary_sensor.is_on: pir_gpio - then: - - delay: ${pir_holdtime} - - lambda: |- - id(pir_motion).publish_state(false); - -# Enable logging only via web -logger: - level: DEBUG - baud_rate: 0 - -api: - encryption: - key: !secret api_encryption_key - on_client_disconnected: - - light.turn_on: - id: output_led - effect: flash - red: 1 - green: 1 - blue: 1 - - switch.turn_off: use_wake_word - on_client_connected: - - switch.turn_on: use_wake_word - - delay: 2s - - switch.turn_off: use_wake_word - - delay: 2s - - switch.turn_on: use_wake_word - - delay: 2s - - light.turn_off: - id: output_led - -ota: - password: !secret ota_password - safe_mode: false - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -uart: - id: LD1115H_UART_BUS - rx_pin: GPIO3 - tx_pin: GPIO1 - baud_rate: 115200 - setup_priority: 200 - -i2c: - sda: GPIO21 - scl: GPIO22 - scan: true - -i2s_audio: - i2s_lrclk_pin: GPIO25 - i2s_bclk_pin: GPIO26 - -microphone: - - platform: i2s_audio - id: mic - adc_type: external - i2s_din_pin: GPIO27 - pdm: false - -voice_assistant: - microphone: mic - use_wake_word: false - noise_suppression_level: 2 - auto_gain: 31dBFS - volume_multiplier: 4.0 - id: assist - on_error: - - light.turn_off: - id: output_led - transition_length: 1s - - logger.log: "Voice Assistant encountered an error; restarting it" - - switch.turn_off: use_wake_word - - delay: 1s - - switch.turn_on: use_wake_word - on_wake_word_detected: - - light.turn_off: - id: output_led - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_listening: - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_stt_end: - - light.turn_off: - id: output_led - transition_length: 1s - on_tts_start: - - light.turn_off: - id: output_led - transition_length: 1s - - if: - condition: - lambda: return x != "Sorry, I couldn't understand that"; - then: - - logger.log: "Command successful!" - - light.turn_on: - id: output_led - effect: hold - red: 0 - green: 1 - blue: 0 - else: - - logger.log: "Command failed!" - - light.turn_on: - id: output_led - effect: hold - red: 1 - green: 0 - blue: 0 - -light: - - platform: rgb - id: output_led - red: rgb_r - green: rgb_g - blue: rgb_b - default_transition_length: 0.15s - flash_transition_length: 0.15s - effects: - - strobe: - name: flash - colors: - - state: true - duration: 0.5s - - state: false - duration: 0.5s - - automation: - name: hold - sequence: - - delay: 5s - - light.turn_off: - id: output_led - transition_length: 1s - -output: - - platform: ledc - id: rgb_r - pin: GPIO14 - - platform: ledc - id: rgb_g - pin: GPIO12 - - platform: ledc - id: rgb_b - pin: GPIO13 - -button: - - platform: restart - name: "ESP32 Restart" - icon: mdi:power-cycle - entity_category: "diagnostic" - -switch: - - platform: template - name: "Enable Wake Word" - icon: mdi:account-voice - id: use_wake_word - optimistic: true - restore_mode: ALWAYS_OFF - entity_category: config - on_turn_on: - - lambda: id(assist).set_use_wake_word(true); - - if: - condition: - not: - - voice_assistant.is_running - then: - - voice_assistant.start_continuous - on_turn_off: - - voice_assistant.stop - - lambda: id(assist).set_use_wake_word(false); - -binary_sensor: - - platform: gpio - name: "PIR GPIO" - id: pir_gpio - pin: GPIO33 - internal: false - device_class: motion - on_press: - - script.stop: pir_handler - - script.execute: pir_handler - - - platform: template - name: "PIR Motion" - id: pir_motion - device_class: motion - - - platform: gpio - name: "LD1115H Presence" - id: ld11115h_gpio - pin: GPIO23 - internal: false - device_class: motion - -sensor: -# - platform: bme280 -# temperature: -# name: "BME280 Temperature" -# pressure: -# name: "BME280 Pressure" -# humidity: -# name: "BME280 Humidity" -# update_interval: 15s -# address: 0x76 - - - platform: bmp280 - temperature: - name: "BMP280 Temperature" - pressure: - name: "BMP280 Pressure" - update_interval: 5s - address: 0x76 - - - platform: custom - lambda: |- - auto veml7700 = new VEML7700CustomSensor(); - App.register_component(veml7700); - return {veml7700->lux_sensor}; - sensors: - - name: "VEML7700 Illumination" - unit_of_measurement: Lux - accuracy_decimals: 0 - - - platform: uptime - name: "ESP32 Uptime" - icon: mdi:clock-alert - update_interval: 5s - entity_category: "diagnostic" - - - platform: wifi_signal - name: "ESP32 WiFi RSSI" - icon: mdi:wifi-strength-2 - update_interval: 5s - entity_category: "diagnostic" - - - platform: internal_temperature - name: "ESP32 Temperature" - icon: mdi:thermometer - unit_of_measurement: °C - device_class: TEMPERATURE - update_interval: 5s - entity_category: "diagnostic" - - - platform: template - name: "ESP32 CPU Frequency" - icon: mdi:cpu-32-bit - accuracy_decimals: 1 - unit_of_measurement: MHz - update_interval: 5s - lambda: |- - return ets_get_cpu_frequency(); - entity_category: "diagnostic" - - - platform: template - name: "ESP32 Free Memory" - icon: mdi:memory - unit_of_measurement: 'kB' - state_class: measurement - update_interval: 5s - lambda: |- - return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; - entity_category: "diagnostic" - -number: - - platform: template - 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(th1st.begin(), th1st.end()); - - platform: template - 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(th2st.begin(), th2st.end()); diff --git a/archive/HLK-LD1125H_supersensor.yaml b/archive/HLK-LD1125H_supersensor.yaml deleted file mode 100644 index 4634e08..0000000 --- a/archive/HLK-LD1125H_supersensor.yaml +++ /dev/null @@ -1,651 +0,0 @@ ---- - -############################################################################### -# SuperSensor v1.0 ESPHome configuration -############################################################################### -# -# Copyright (C) 2023 Joshua M. Boniface -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################### - -# -# Compile-time Substitutions -# -substitutions: - ignored_radar_ranges: |- - { - { 2.20, 3.30 }, - { 2.20, 2.75 } - } - -# -# Core configuration -# -esphome: - name: supersensor - name_add_mac_suffix: true - on_boot: - - priority: 600 - then: - - light.turn_on: - id: output_led - effect: flash - red: 1 - green: 1 - blue: 1 - - - priority: 100 - then: - # Configure LD1125H via UART - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_mov_st = "mth1_mov=" + str_sprintf("%.0f",id(LD1125H_mth1_mov).state) + "\r\n"; - return std::vector(mth1_mov_st.begin(), mth1_mov_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_mov_st = "mth2_mov=" + str_sprintf("%.0f",id(LD1125H_mth2_mov).state) + "\r\n"; - return std::vector(mth2_mov_st.begin(), mth2_mov_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_mov_st = "mth3_mov=" + str_sprintf("%.0f",id(LD1125H_mth3_mov).state) + "\r\n"; - return std::vector(mth3_mov_st.begin(), mth3_mov_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_occ_st = "mth1_occ=" + str_sprintf("%.0f",id(LD1125H_mth1_occ).state) + "\r\n"; - return std::vector(mth1_occ_st.begin(), mth1_occ_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_occ_st = "mth2_occ=" + str_sprintf("%.0f",id(LD1125H_mth2_occ).state) + "\r\n"; - return std::vector(mth2_occ_st.begin(), mth2_occ_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_occ_st = "mth3_occ=" + str_sprintf("%.0f",id(LD1125H_mth3_occ).state) + "\r\n"; - return std::vector(mth3_occ_st.begin(), mth3_occ_st.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(rmaxst.begin(), rmaxst.end()); - - - priority: -500 - then: - - wait_until: api.connected - - delay: 3s - - switch.turn_on: use_wake_word - - delay: 2s - - switch.turn_off: use_wake_word - - delay: 2s - - switch.turn_on: use_wake_word - - light.turn_off: - id: output_led - -esp32: - board: esp32dev - framework: - type: esp-idf - sdkconfig_options: - CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32_DATA_CACHE_64KB: "y" - CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32S3_DATA_CACHE_64KB: "y" - CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -external_components: - - source: - type: git - url: https://github.com/ssieb/custom_components - components: [ serial ] - -logger: - level: VERBOSE - baud_rate: 115200 - -api: - encryption: - key: !secret api_encryption_key - -ota: - password: !secret ota_password - safe_mode: false - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -uart: - id: LD1125H_UART_BUS - rx_pin: GPIO18 - tx_pin: GPIO19 - setup_priority: 200 - baud_rate: 115200 - data_bits: 8 - stop_bits: 1 - parity: NONE - -i2c: - sda: GPIO21 - scl: GPIO22 - scan: true - -# -# Radar Globals -# -globals: - - id: LD1125H_Last_Update_Time - type: uint32_t - restore_value: no - initial_value: millis() - - 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_Clearance_Status - type: bool - restore_value: no - initial_value: "false" - - id: ignored_ranges - type: std::vector> - restore_value: no - initial_value: ${ignored_radar_ranges} - -# -# Voice Control -# -i2s_audio: - i2s_lrclk_pin: GPIO25 - i2s_bclk_pin: GPIO26 - -microphone: - - platform: i2s_audio - id: mic - adc_type: external - i2s_din_pin: GPIO27 - pdm: false - -voice_assistant: - microphone: mic - use_wake_word: false - noise_suppression_level: 2 - auto_gain: 31dBFS - volume_multiplier: 5.0 - id: assist - on_wake_word_detected: - - light.turn_off: - id: output_led - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_listening: - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_stt_end: - - light.turn_off: - id: output_led - transition_length: 1s - on_tts_start: - - if: - condition: - lambda: return x != "Sorry, I couldn't understand that"; - then: - - logger.log: "Command successful!" - - light.turn_on: - id: output_led - effect: hold - red: 0 - green: 1 - blue: 0 - else: - - logger.log: "Command failed!" - - light.turn_on: - id: output_led - effect: hold - red: 1 - green: 0 - blue: 0 - -# -# Voice Response LED -# -light: - - platform: rgb - id: output_led - red: rgb_r - green: rgb_g - blue: rgb_b - default_transition_length: 0.15s - flash_transition_length: 0.15s - effects: - - strobe: - name: flash - colors: - - state: true - duration: 0.5s - - state: false - duration: 0.5s - - automation: - name: hold - sequence: - - delay: 5s - - light.turn_off: - id: output_led - transition_length: 1s - -output: - - platform: ledc - id: rgb_r - pin: GPIO14 - - platform: ledc - id: rgb_g - pin: GPIO12 - - platform: ledc - id: rgb_b - pin: GPIO13 - -# -# Restart button -# -button: - - platform: restart - name: "ESP32 Restart" - icon: mdi:power-cycle - entity_category: "diagnostic" - -# -# Wake Word switch -# -switch: - - platform: template - name: "Voice Enable Wake Word" - icon: mdi:account-voice - id: use_wake_word - optimistic: true - restore_mode: ALWAYS_OFF - entity_category: config - on_turn_on: - - lambda: id(assist).set_use_wake_word(true); - - if: - condition: - not: - - voice_assistant.is_running - then: - - voice_assistant.start_continuous - on_turn_off: - - voice_assistant.stop - - lambda: id(assist).set_use_wake_word(false); - -# -# Motion Sensors -# -binary_sensor: - - platform: gpio - pin: GPIO33 - name: "PIR Motion" - device_class: motion - - - platform: template - name: "LD1125H Occupancy & Movement" - id: LD1125H_MovOcc_Binary - device_class: occupancy - - - platform: template - name: "LD1125H Motion" - id: LD1125H_Mov_Binary - device_class: motion - -# -# LD1125H Text Sensors -# -text_sensor: - - platform: serial - uart_id: LD1125H_UART_BUS - name: "LD1125H UART Text" - id: LD1125H_UART_Text - icon: mdi:format-text - internal: true - on_value: - then: - - lambda: |- - if ((millis() - id(LD1125H_Last_Update_Time)) < 1000) { - return; - } else { - id(LD1125H_Last_Update_Time) = millis(); - } - for (const auto& row : id(ignored_ranges)) { - if ( ( atof(id(LD1125H_UART_Text).state.substr(9).c_str()) > row[0] ) && ( atof(id(LD1125H_UART_Text).state.substr(9).c_str()) < row[1] ) ) { - break; - } else { - 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("Occupied"); - 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_Clearance_Status) == true) { - id(LD1125H_Clearance_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_Clearance_Status) == true) { - id(LD1125H_Clearance_Status) = false; - } - } - } - } - - - platform: template - name: "LD1125H Occupancy Status" - id: LD1125H_Occupancy - icon: "mdi:motion-sensor" - - -# -# Other Sensors -# -sensor: - # BME280 Temperature/Humidity/Pressure sensor - - platform: bme280 - temperature: - name: "BME280 Temperature" - humidity: - name: "BME280 Humidity" - pressure: - name: "BME280 Pressure" - update_interval: 15s - address: 0x76 - - # BMP280 Temperature/Pressure sensor (TEMPORARY) - - platform: bmp280 - temperature: - name: "BMP280 Temperature" - pressure: - name: "BMP280 Pressure" - update_interval: 15s - address: 0x76 - - # LD1125H Distance - - platform: template - name: LD1125H Detect Distance - id: LD1125H_Distance - icon: mdi:signal-distance-variant - unit_of_measurement: "m" - accuracy_decimals: 2 - - # Internal sensors - - platform: uptime - name: "ESP32 Uptime" - icon: mdi:clock-alert - update_interval: 15s - entity_category: "diagnostic" - - - platform: wifi_signal - name: "ESP32 WiFi RSSI" - icon: mdi:wifi-strength-2 - update_interval: 15s - entity_category: "diagnostic" - - - platform: internal_temperature - name: "ESP32 Temperature" - icon: mdi:thermometer - unit_of_measurement: °C - device_class: TEMPERATURE - update_interval: 15s - entity_category: "diagnostic" - - - platform: template - name: "ESP32 CPU Frequency" - icon: mdi:cpu-32-bit - accuracy_decimals: 1 - unit_of_measurement: MHz - update_interval: 15s - lambda: |- - return ets_get_cpu_frequency(); - entity_category: "diagnostic" - - - platform: template - name: "ESP32 Free Memory" - icon: mdi:memory - unit_of_measurement: 'kB' - state_class: measurement - update_interval: 15s - lambda: |- - return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; - entity_category: "diagnostic" - -# -# LD1125H tunables -# -number: - - platform: template - name: "LD1125H Mov 0m-2.8m" - id: LD1125H_mth1_mov - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "80" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_mov_st = "mth1_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth1_mov_st.begin(), mth1_mov_st.end()); - - - platform: template - name: "LD1125H Mov 2.8m-8m" - id: LD1125H_mth2_mov - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "50" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_mov_st = "mth2_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth2_mov_st.begin(), mth2_mov_st.end()); - - - platform: template - name: "LD1125H Mov 8m-∞m" - id: LD1125H_mth3_mov - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "80" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_mov_st = "mth3_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth3_mov_st.begin(), mth3_mov_st.end()); - - - platform: template - name: "LD1125H Occ 0m-2.8m" - id: LD1125H_mth1_occ - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "80" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_occ_st = "mth1_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth1_occ_st.begin(), mth1_occ_st.end()); - - - platform: template - name: "LD1125H Occ 2.8m-8m" - id: LD1125H_mth2_occ - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "50" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_occ_st = "mth2_occ=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth2_occ_st.begin(), mth2_occ_st.end()); - - - platform: template - name: "LD1125H Occ 8m-∞m" - id: LD1125H_mth3_occ - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "80" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_occ_st = "mth3_occ=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth3_occ_st.begin(), mth3_occ_st.end()); - - - platform: template - name: "LD1125H Max Dist (m)" - id: LD1125H_rmax - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "4" - min_value: 0.0 - max_value: 20 - step: 0.1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; - return std::vector(rmaxst.begin(), rmaxst.end()); - - - platform: template - name: "LD1125H Clear Time" - id: LD1125H_Clearance_Time - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "15" - min_value: 0 - max_value: 60 - step: 1 - - - platform: template - name: "LD1125H Detect Time" - id: LD1125H_Mov_Time - icon: mdi:cogs - entity_category: "config" - optimistic: true - restore_value: true - initial_value: "0.1" - min_value: 0.1 - max_value: 10 - step: 0.1 - -# -# Radar Clear Scan Time Interval -# -interval: - - interval: 1s - then: - lambda: |- - if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clearance_Time).state) { - if ((id(LD1125H_Clearance_Status) == false) || (id(LD1125H_Occupancy).state != "Clear")) { - id(LD1125H_Occupancy).publish_state("Clear"); - id(LD1125H_Clearance_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); - } - } diff --git a/archive/HLK-LD2410C_supersensor.yaml b/archive/HLK-LD2410C_supersensor.yaml deleted file mode 100644 index 17fb852..0000000 --- a/archive/HLK-LD2410C_supersensor.yaml +++ /dev/null @@ -1,480 +0,0 @@ ---- - -############################################################################### -# SuperSensor v1.0 ESPHome configuration -############################################################################### -# -# Copyright (C) 2023 Joshua M. Boniface -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################### - -substitutions: - # How long a PIR activation should be held for - pir_holdtime: "15s" - -esphome: - name: supersensor - name_add_mac_suffix: true - friendly_name: "Supersensor" - project: - name: joshuaboniface.supersensor - version: "0.1" -# includes: -# - veml7700.h -# libraries: -# - "Wire" -# - "Adafruit Unified Sensor" -# - "SPI" -# - "Adafruit BusIO" -# - "Adafruit VEML7700 Library" - on_boot: - - priority: 600 - then: - - light.turn_on: - id: output_led - effect: flash - red: 1 - green: 1 - blue: 1 - -dashboard_import: - package_import_url: github://joshuaboniface/supersensor/supersensor.yaml - import_full_config: false - -esp32: - board: esp32dev -# framework: -# type: esp-idf -# sdkconfig_options: -# CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" -# CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" -# CONFIG_ESP32_DATA_CACHE_64KB: "y" -# CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" -# CONFIG_ESP32S3_DATA_CACHE_64KB: "y" -# CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -script: - - id: pir_handler - then: - - lambda: |- - id(pir_motion).publish_state(true); - - while: - condition: - binary_sensor.is_on: pir_gpio - then: - - delay: ${pir_holdtime} - - lambda: |- - id(pir_motion).publish_state(false); - -# Enable logging only via web -logger: - level: DEBUG - baud_rate: 115200 - -api: - encryption: - key: !secret api_encryption_key - on_client_disconnected: - - light.turn_on: - id: output_led - effect: flash - red: 1 - green: 1 - blue: 1 - - switch.turn_off: use_wake_word - on_client_connected: - - switch.turn_on: use_wake_word - - delay: 2s - - switch.turn_off: use_wake_word - - delay: 2s - - switch.turn_on: use_wake_word - - delay: 2s - - light.turn_off: - id: output_led - -ota: - password: !secret ota_password - safe_mode: false - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -uart: - id: ld2410_uart - rx_pin: GPIO18 - tx_pin: GPIO19 - baud_rate: 256000 - data_bits: 8 - stop_bits: 1 - parity: NONE - -i2c: - sda: GPIO16 - scl: GPIO17 - scan: true - -i2s_audio: - i2s_lrclk_pin: GPIO27 - i2s_bclk_pin: GPIO26 - -microphone: - - platform: i2s_audio - id: mic - adc_type: external - i2s_din_pin: GPIO14 - pdm: false - -voice_assistant: - microphone: mic - use_wake_word: false - noise_suppression_level: 2 - auto_gain: 31dBFS - volume_multiplier: 4.0 - id: assist - on_error: - - light.turn_off: - id: output_led - transition_length: 1s - - logger.log: "Voice Assistant encountered an error; restarting it" - - switch.turn_off: use_wake_word - - delay: 1s - - switch.turn_on: use_wake_word - on_wake_word_detected: - - light.turn_off: - id: output_led - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_listening: - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_stt_end: - - light.turn_off: - id: output_led - transition_length: 1s - on_tts_start: - - light.turn_off: - id: output_led - transition_length: 1s - - if: - condition: - lambda: return x != "Sorry, I couldn't understand that"; - then: - - logger.log: "Command successful!" - - light.turn_on: - id: output_led - effect: hold - red: 0 - green: 1 - blue: 0 - else: - - logger.log: "Command failed!" - - light.turn_on: - id: output_led - effect: hold - red: 1 - green: 0 - blue: 0 - -light: - - platform: rgb - id: output_led - red: rgb_r - green: rgb_g - blue: rgb_b - default_transition_length: 0.15s - flash_transition_length: 0.15s - effects: - - strobe: - name: flash - colors: - - state: true - duration: 0.5s - - state: false - duration: 0.5s - - automation: - name: hold - sequence: - - delay: 5s - - light.turn_off: - id: output_led - transition_length: 1s - -output: - - platform: ledc - id: rgb_r - pin: GPIO32 - - platform: ledc - id: rgb_g - pin: GPIO33 - - platform: ledc - id: rgb_b - pin: GPIO25 - -ld2410: - id: ld2410_radar - uart_id: ld2410_uart - # max_move_distance : 6m - # max_still_distance: 0.75m - # g0_move_threshold: 10 - # g0_still_threshold: 20 - # g1_move_threshold: 10 - # g1_still_threshold: 20 - # g2_move_threshold: 20 - # g2_still_threshold: 21 - # g3_move_threshold: 30 - # g3_still_threshold: 31 - # g4_move_threshold: 40 - # g4_still_threshold: 41 - # g5_move_threshold: 50 - # g5_still_threshold: 51 - # g6_move_threshold: 60 - # g6_still_threshold: 61 - # g7_move_threshold: 70 - # g7_still_threshold: 71 - # g8_move_threshold: 80 - # g8_still_threshold: 81 - -binary_sensor: - - platform: gpio - name: "PIR GPIO" - id: pir_gpio - pin: GPIO13 - internal: false - device_class: motion - on_press: - - script.stop: pir_handler - - script.execute: pir_handler - - - platform: template - name: "PIR Motion" - id: pir_motion - device_class: motion - - - platform: ld2410 - ld2410_id: ld2410_radar - has_target: - name: "LD2410C Presence" - has_moving_target: - name: "LD2410C Moving Target" - has_still_target: - name: "LD2410C Still Target" - -sensor: -# - platform: bme280 -# temperature: -# name: "BME280 Temperature" -# pressure: -# name: "BME280 Pressure" -# humidity: -# name: "BME280 Humidity" -# update_interval: 15s -# address: 0x76 - - - platform: bmp280 - temperature: - name: "BMP280 Temperature" - pressure: - name: "BMP280 Pressure" - update_interval: 5s - address: 0x76 - -# - platform: custom -# lambda: |- -# auto veml7700 = new VEML7700CustomSensor(); -# App.register_component(veml7700); -# return {veml7700->lux_sensor}; -# sensors: -# - name: "VEML7700 Illumination" -# unit_of_measurement: Lux -# accuracy_decimals: 0 - - - platform: ld2410 - ld2410_id: ld2410_radar - moving_distance: - name: "LD2410C Moving Distance" - id: moving_distance - still_distance: - name: "LD2410C Still Distance" - id: still_distance - moving_energy: - name: "LD2410C Move Energy" - still_energy: - name: "LD2410C Still Energy" - detection_distance: - name: "LD2410C Presence Distance" - - - platform: uptime - name: "ESP32 Uptime" - icon: mdi:clock-alert - update_interval: 5s - entity_category: diagnostic - - - platform: wifi_signal - name: "ESP32 WiFi RSSI" - icon: mdi:wifi-strength-2 - update_interval: 5s - entity_category: diagnostic - - - platform: internal_temperature - name: "ESP32 Temperature" - icon: mdi:thermometer - unit_of_measurement: °C - device_class: TEMPERATURE - update_interval: 5s - entity_category: diagnostic - - - platform: template - name: "ESP32 CPU Frequency" - icon: mdi:cpu-32-bit - accuracy_decimals: 1 - unit_of_measurement: MHz - update_interval: 5s - lambda: |- - return ets_get_cpu_frequency(); - entity_category: diagnostic - - - platform: template - name: "ESP32 Free Memory" - icon: mdi:memory - unit_of_measurement: 'kB' - state_class: measurement - update_interval: 5s - lambda: |- - return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; - entity_category: diagnostic - -text_sensor: - - platform: ld2410 - version: - name: "LD2410C Firmware Version" - mac_address: - name: "LD2410C MAC Address" - -button: - - platform: ld2410 - restart: - name: "LD2410C Restart" - factory_reset: - name: "LD2410C Factory Reset" - - - platform: restart - name: "ESP32 Restart" - icon: mdi:power-cycle - entity_category: diagnostic - -switch: - - platform: template - name: "Enable Wake Word" - icon: mdi:account-voice - id: use_wake_word - optimistic: true - restore_mode: ALWAYS_OFF - entity_category: config - on_turn_on: - - lambda: id(assist).set_use_wake_word(true); - - if: - condition: - not: - - voice_assistant.is_running - then: - - voice_assistant.start_continuous - on_turn_off: - - voice_assistant.stop - - lambda: id(assist).set_use_wake_word(false); - - - platform: ld2410 - engineering_mode: - name: "LD2410C Engineering Mode" - bluetooth: - name: "LD2410C Bluetooth" - -number: - - platform: ld2410 - timeout: - name: "LD2410C Timeout" - light_threshold: - name: "LD2410C Light Threshold" - max_move_distance_gate: - name: "LD2410C Max Move Distance Gate" - max_still_distance_gate: - name: "LD2410C Max Still Distance Gate" - g0: - move_threshold: - name: "LD2410C Gate0 Move Threshold" - still_threshold: - name: "LD2410C Gate0 Still Threshold" - g1: - move_threshold: - name: "LD2410C Gate1 Move Threshold" - still_threshold: - name: "LD2410C Gate1 Still Threshold" - g2: - move_threshold: - name: "LD2410C Gate2 Move Threshold" - still_threshold: - name: "LD2410C Gate2 Still Threshold" - g3: - move_threshold: - name: "LD2410C Gate3 Move Threshold" - still_threshold: - name: "LD2410C Gate3 Still Threshold" - g4: - move_threshold: - name: "LD2410C Gate4 Move Threshold" - still_threshold: - name: "LD2410C Gate4 Still Threshold" - g5: - move_threshold: - name: "LD2410C Gate5 Move Threshold" - still_threshold: - name: "LD2410C Gate5 Still Threshold" - g6: - move_threshold: - name: "LD2410C Gate6 Move Threshold" - still_threshold: - name: "LD2410C Gate6 Still Threshold" - g7: - move_threshold: - name: "LD2410C Gate7 Move Threshold" - still_threshold: - name: "LD2410C Gate7 Still Threshold" - g8: - move_threshold: - name: "LD2410C Gate8 Move Threshold" - still_threshold: - name: "LD2410C Gate8 Still Threshold" - -select: - - platform: ld2410 - distance_resolution: - name: "LD2410C Distance Resolution" diff --git a/archive/LD1125.yaml b/archive/LD1125.yaml deleted file mode 100644 index a7fd745..0000000 --- a/archive/LD1125.yaml +++ /dev/null @@ -1,365 +0,0 @@ -substitutions: - devicename: "supersensor" #Rename the device what you want. - upper_devicename: ESP Radar #Rename the device what you want. - entity_name_prefix: "" - ignored_radar_ranges: |- - { - {2.20,3.30}, - {2.20,2.75} - } - -esp32: - board: esp32dev - framework: - type: esp-idf - sdkconfig_options: - CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32_DATA_CACHE_64KB: "y" - CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32S3_DATA_CACHE_64KB: "y" - CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -api: - encryption: - key: !secret api_encryption_key - -ota: - password: !secret ota_password - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -logger: - level: DEBUG - baud_rate: 115200 - logs: - text_sensor: INFO - -esphome: - name: supersensor - name_add_mac_suffix: false - on_boot: - priority: 200 - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_mov_st = "mth1_mov=" + str_sprintf("%.0f",id(LD1125H_mth1_mov).state) +"\r\n"; - return std::vector(mth1_mov_st.begin(), mth1_mov_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_mov_st = "mth2_mov=" + str_sprintf("%.0f",id(LD1125H_mth2_mov).state) +"\r\n"; - return std::vector(mth2_mov_st.begin(), mth2_mov_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_mov_st = "mth3_mov=" + str_sprintf("%.0f",id(LD1125H_mth3_mov).state) +"\r\n"; - return std::vector(mth3_mov_st.begin(), mth3_mov_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_occ_st = "mth1_occ=" + str_sprintf("%.0f",id(LD1125H_mth1_occ).state) +"\r\n"; - return std::vector(mth1_occ_st.begin(), mth1_occ_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_occ_st = "mth2_occ=" + str_sprintf("%.0f",id(LD1125H_mth2_occ).state) +"\r\n"; - return std::vector(mth2_occ_st.begin(), mth2_occ_st.end()); - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_occ_st = "mth3_occ=" + str_sprintf("%.0f",id(LD1125H_mth3_occ).state) +"\r\n"; - return std::vector(mth3_occ_st.begin(), mth3_occ_st.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(rmaxst.begin(), rmaxst.end()); - -external_components: - - source: - type: git - url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. - components: [ serial ] - -uart: - id: LD1125H_UART_BUS - rx_pin: GPIO16 - tx_pin: GPIO17 - 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); -status_led: - pin: - number: GPIO2 - inverted: false -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_Clearance_Status - type: bool - restore_value: no - initial_value: "false" - - id: ignored_ranges - type: std::vector> - restore_value: no - initial_value: ${ignored_radar_ranges} -interval: - - interval: 1s #Clearance Scan Time - setup_priority: 200 - then: - lambda: |- - if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clearance_Time).state) { - if ((id(LD1125H_Clearance_Status) == false) || (id(LD1125H_Occupancy).state != "Clear")) { - id(LD1125H_Occupancy).publish_state("Clear"); - id(LD1125H_Clearance_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: ${entity_name_prefix} 0-2.8m Movement Minimum Signal - id: LD1125H_mth1_mov - icon: "mdi:cogs" - optimistic: true - restore_value: true - initial_value: "80" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_mov_st = "mth1_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth1_mov_st.begin(), mth1_mov_st.end()); - - platform: template - name: ${entity_name_prefix} 2.8m-8m Movement Minimum Signal - 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: "50" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_mov_st = "mth2_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth2_mov_st.begin(), mth2_mov_st.end()); - - platform: template - name: ${entity_name_prefix} 8m-∞ Movement Minimum Signal - 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: "20" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_mov_st = "mth3_mov=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth3_mov_st.begin(), mth3_mov_st.end()); - - platform: template - name: ${entity_name_prefix} 0-2.8m Occupancy Minimum Signal - id: LD1125H_mth1_occ - icon: "mdi:cogs" - optimistic: true - restore_value: true - initial_value: "60" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth1_occ_st = "mth1_occ=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth1_occ_st.begin(), mth1_occ_st.end()); - - platform: template - name: ${entity_name_prefix} 2.8m-8m Occupancy Minimum Signal - 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: "55" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth2_occ_st = "mth2_occ=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth2_occ_st.begin(), mth2_occ_st.end()); - - platform: template - name: ${entity_name_prefix} 8m-∞ Occupancy Minimum Signal - 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: "20" - min_value: 0 - max_value: 1500 - step: 1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string mth3_occ_st = "mth3_occ=" + str_sprintf("%.0f",x) +"\r\n"; - return std::vector(mth3_occ_st.begin(), mth3_occ_st.end()); - - platform: template - name: ${entity_name_prefix} Max Detection Distance (m) #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.0 - max_value: 60 - step: 0.1 - set_action: - then: - - uart.write: - id: LD1125H_UART_BUS - data: !lambda |- - std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; - return std::vector(rmaxst.begin(), rmaxst.end()); - - platform: template - name: ${entity_name_prefix} Seconds to Clear Mov/Occ - id: LD1125H_Clearance_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: "20" #LD1125H Mov/Occ > Clearance Time Here - min_value: 0 - max_value: 60 - step: 1 - - platform: template - name: ${entity_name_prefix} Seconds to Detection - 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.1 - max_value: 10 - step: 0.1 -sensor: - - platform: template - name: ${entity_name_prefix} Objects Distance - id: LD1125H_Distance - icon: "mdi:signal-distance-variant" - unit_of_measurement: "m" - accuracy_decimals: 2 - filters: # Use Filter To Debounce - - sliding_window_moving_average: - window_size: 200 - send_every: 10 - - heartbeat: 0.2s -text_sensor: - - platform: serial - uart_id: LD1125H_UART_BUS - name: ${entity_name_prefix} UART Text - id: LD1125H_UART_Text - icon: "mdi:format-text" - internal: True - on_value: - lambda: |- - for (const auto& row : id(ignored_ranges)) { - if ( ( atof(id(LD1125H_UART_Text).state.substr(9).c_str()) > row[0] ) && ( atof(id(LD1125H_UART_Text).state.substr(9).c_str()) < row[1] ) ) { - break; - } else { - 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("Occupied"); - 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_Clearance_Status) == true) { - id(LD1125H_Clearance_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_Clearance_Status) == true) { - id(LD1125H_Clearance_Status) = false; - } - } - } - } - - platform: template - name: ${entity_name_prefix} Occupancy Status - id: LD1125H_Occupancy - icon: "mdi:motion-sensor" -binary_sensor: - - platform: template - name: ${entity_name_prefix} Occupancy or Movement - id: LD1125H_MovOcc_Binary - device_class: occupancy - - platform: template - name: ${entity_name_prefix} Motion - id: LD1125H_Mov_Binary - device_class: motion diff --git a/archive/ledtest.yaml b/archive/ledtest.yaml deleted file mode 100644 index 07a8880..0000000 --- a/archive/ledtest.yaml +++ /dev/null @@ -1,103 +0,0 @@ - -esphome: - name: supersensor - name_add_mac_suffix: true - friendly_name: "Supersensor" - project: - name: joshuaboniface.supersensor - version: "0.1" - -logger: - level: DEBUG - baud_rate: 115200 - -esp32: - board: esp32dev - framework: - type: esp-idf - sdkconfig_options: - CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32_DATA_CACHE_64KB: "y" - CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32S3_DATA_CACHE_64KB: "y" - CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -script: - - id: ledtest - then: - - light.turn_on: - id: output_led - effect: flash_white - - delay: 5s - - light.turn_off: - id: output_led - - delay: 5s - - light.turn_on: - id: output_led - red: 1 - green: 0 - blue: 0 - - delay: 5s - - light.turn_on: - id: output_led - red: 0 - green: 1 - blue: 0 - - delay: 5s - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - -interval: - - interval: 30s - then: - - script.stop: ledtest - - light.turn_off: output_led - - script.execute: ledtest - -light: - - platform: rgb - id: output_led - red: rgb_r - green: rgb_g - blue: rgb_b - default_transition_length: 0.15s - flash_transition_length: 0.15s - effects: - - strobe: - name: flash_white - colors: - - state: true - brightness: 50% - red: 40% - green: 50% - blue: 45% - duration: 0.5s - - state: false - duration: 0.5s - - automation: - name: hold - sequence: - - delay: 5s - - light.turn_off: - id: output_led - transition_length: 1s - -output: - - platform: ledc - id: rgb_r - pin: GPIO32 - max_power: 100% - - platform: ledc - id: rgb_g - pin: GPIO33 - max_power: 100% - - platform: ledc - id: rgb_b - pin: GPIO25 - max_power: 100% diff --git a/archive/pirtester.yaml b/archive/pirtester.yaml deleted file mode 100644 index 5ad54a2..0000000 --- a/archive/pirtester.yaml +++ /dev/null @@ -1,99 +0,0 @@ ---- - -############################################################################### -# SuperSensor v1.0 ESPHome configuration -############################################################################### -# -# Copyright (C) 2023 Joshua M. Boniface -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################### - -esphome: - name: pirtester - friendly_name: "PIRTester" - -esp32: - board: esp32dev - framework: - type: esp-idf - sdkconfig_options: - CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32_DATA_CACHE_64KB: "y" - CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32S3_DATA_CACHE_64KB: "y" - CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -# Enable logging only via web -logger: - level: DEBUG - baud_rate: 115200 - -api: - encryption: - key: !secret api_encryption_key - -ota: - password: !secret ota_password - safe_mode: false - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -binary_sensor: - - platform: gpio - pin: GPIO32 - name: "PIR 32" - device_class: motion - - platform: gpio - pin: GPIO33 - name: "PIR 33" - device_class: motion - - platform: gpio - pin: GPIO25 - name: "PIR 25" - device_class: motion - - platform: gpio - pin: GPIO26 - name: "PIR 26" - device_class: motion - - platform: gpio - pin: GPIO27 - name: "PIR 27" - device_class: motion - - platform: gpio - pin: GPIO14 - name: "PIR 14" - device_class: motion - - platform: gpio - pin: GPIO12 - name: "PIR 12" - device_class: motion - - platform: gpio - pin: GPIO13 - name: "PIR 13" - device_class: motion diff --git a/archive/supersensor_bme680bsec.yaml b/archive/supersensor_bme680bsec.yaml deleted file mode 100644 index 91715f3..0000000 --- a/archive/supersensor_bme680bsec.yaml +++ /dev/null @@ -1,866 +0,0 @@ ---- - -############################################################################### -# SuperSensor v1.0 ESPHome configuration -############################################################################### -# -# Copyright (C) 2023 Joshua M. Boniface -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################### - -esphome: - name: supersensor - name_add_mac_suffix: true - friendly_name: "Supersensor" - project: - name: joshuaboniface.supersensor - version: "0.1" - on_boot: - - priority: 600 - then: - - lambda: |- - id(supersensor_occupancy).publish_state(false); - id(pir_presence).publish_state(false); - id(light_presence).publish_state(false); - - light.turn_on: - id: output_led - effect: flash_white - -dashboard_import: - package_import_url: github://joshuaboniface/supersensor/supersensor.yaml - import_full_config: false - -esp32: - board: esp32dev - -globals: - - id: pir_hold_time - type: int - restore_value: yes - initial_value: "15" - - - id: light_presence_threshold - type: int - restore_value: yes - initial_value: "30" - - - id: occupancy_detect_mode - type: int - restore_value: yes - initial_value: "0" - - - id: occupancy_clear_mode - type: int - restore_value: yes - initial_value: "0" - -script: - - id: pir_handler - then: - - lambda: |- - id(pir_presence).publish_state(true); - - while: - condition: - binary_sensor.is_on: pir_gpio - then: - - delay: !lambda 'return(id(pir_hold_time) * 1000);' - - lambda: |- - id(pir_presence).publish_state(false); - - - id: light_handler - then: - - lambda: |- - if (id(tsl2591_lux).state >= id(light_presence_threshold)) { - id(light_presence).publish_state(true); - } else { - id(light_presence).publish_state(false); - } - - - id: occupancy_detect_handler - then: - - lambda: |- - ESP_LOGD("occupancy_detect_handler", "Occupancy detect handler triggered"); - - // Get the current values of our presence sensors - bool pir = id(pir_presence).state; - bool radar = id(radar_presence).state; - bool light = id(light_presence).state; - - // Determine if PIR counts (2nd bit of presence_type) - int pir_counts = (id(occupancy_detect_mode) & ( 1 << 2 )) >> 2; - - // Determine if Radar counts (1st bit of presence_type) - int radar_counts = (id(occupancy_detect_mode) & ( 1 << 1 )) >> 1; - - // Determine if Light counts (0th bit of presence_type) - int light_counts = (id(occupancy_detect_mode) & ( 1 << 0 )) >> 0; - - // Determine our results - if (pir_counts & radar_counts & light_counts) { - // Logical AND of pir & radar & light - ESP_LOGD("occupancy_detect_handler", "PIR & Radar & Light: %i", pir & radar & light); - id(supersensor_occupancy).publish_state(pir & radar & light); - } else if (pir_counts & radar_counts) { - // Logical AND of pir & radar - ESP_LOGD("occupancy_detect_handler", "PIR & Radar: %i", pir & radar); - id(supersensor_occupancy).publish_state(pir & radar); - } else if (pir_counts & light_counts) { - // Logical AND of pir & light - ESP_LOGD("occupancy_detect_handler", "PIR & Light: %i", pir & light); - id(supersensor_occupancy).publish_state(pir & light); - } else if (radar_counts & light_counts) { - // Logical AND of radar & light - ESP_LOGD("occupancy_detect_handler", "Radar & Light: %i", radar & light); - id(supersensor_occupancy).publish_state(radar & light); - } else if (pir_counts) { - // Only pir - ESP_LOGD("occupancy_detect_handler", "PIR: %i", pir); - id(supersensor_occupancy).publish_state(pir); - } else if (radar_counts) { - // Only radar - ESP_LOGD("occupancy_detect_handler", "Radar: %i", radar); - id(supersensor_occupancy).publish_state(radar); - } else if (light_counts) { - // Only light - ESP_LOGD("occupancy_detect_handler", "Light: %i", light); - id(supersensor_occupancy).publish_state(light); - } else { - ESP_LOGD("occupancy_detect_handler", "None"); - id(supersensor_occupancy).publish_state(false); - } - - - id: occupancy_clear_handler - then: - - lambda: |- - ESP_LOGD("occupancy_clear_handler", "Occupancy clear handler triggered"); - - // Get the current values of our presence sensors - bool pir = id(pir_presence).state; - bool radar = id(radar_presence).state; - bool light = id(light_presence).state; - - // Determine if PIR counts (2nd bit of presence_type) - int pir_counts = (id(occupancy_clear_mode) & ( 1 << 2 )) >> 2; - - // Determine if Radar counts (1st bit of presence_type) - int radar_counts = (id(occupancy_clear_mode) & ( 1 << 1 )) >> 1; - - // Determine if Light counts (0th bit of presence_type) - int light_counts = (id(occupancy_clear_mode) & ( 1 << 0 )) >> 0; - - // Determine our results - if (pir_counts & radar_counts & light_counts) { - // Logical AND of pir & radar & light - ESP_LOGD("occupancy_clear_handler", "PIR & Radar & Light: %i", pir & radar & light); - id(supersensor_occupancy).publish_state(pir & radar & light); - } else if (pir_counts & radar_counts) { - // Logical AND of pir & radar - ESP_LOGD("occupancy_clear_handler", "PIR & Radar: %i", pir & radar); - id(supersensor_occupancy).publish_state(pir & radar); - } else if (pir_counts & light_counts) { - // Logical AND of pir & light - ESP_LOGD("occupancy_clear_handler", "PIR & Light: %i", pir & light); - id(supersensor_occupancy).publish_state(pir & light); - } else if (radar_counts & light_counts) { - // Logical AND of radar & light - ESP_LOGD("occupancy_clear_handler", "Radar & Light: %i", radar & light); - id(supersensor_occupancy).publish_state(radar & light); - } else if (pir_counts) { - // Only pir - ESP_LOGD("occupancy_clear_handler", "PIR: %i", pir); - id(supersensor_occupancy).publish_state(pir); - } else if (radar_counts) { - // Only radar - ESP_LOGD("occupancy_clear_handler", "Radar: %i", radar); - id(supersensor_occupancy).publish_state(radar); - } else if (light_counts) { - // Only light - ESP_LOGD("occupancy_clear_handler", "Light: %i", light); - id(supersensor_occupancy).publish_state(light); - } else { - ESP_LOGD("occupancy_clear_handler", "None"); - id(supersensor_occupancy).publish_state(false); - } - -logger: - level: DEBUG - baud_rate: 115200 - -api: - encryption: - key: !secret api_encryption_key - on_client_disconnected: - - light.turn_on: - id: output_led - effect: flash_white - - switch.turn_off: use_wake_word - on_client_connected: - # This absolute absurdity is required to prevent - # "no wake word detected" failure loops. - - switch.turn_on: use_wake_word - - delay: 2s - - switch.turn_off: use_wake_word - - delay: 2s - - switch.turn_on: use_wake_word - - delay: 2s - - light.turn_off: - id: output_led - -ota: - password: !secret ota_password - safe_mode: false - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -uart: - id: ld2410_uart - rx_pin: GPIO19 - tx_pin: GPIO18 - baud_rate: 256000 - data_bits: 8 - stop_bits: 1 - parity: NONE - -i2c: - sda: GPIO16 - scl: GPIO17 - scan: true - -i2s_audio: - i2s_lrclk_pin: GPIO26 - i2s_bclk_pin: GPIO27 - -microphone: - - platform: i2s_audio - id: mic - adc_type: external - i2s_din_pin: GPIO14 - pdm: false - -voice_assistant: - microphone: mic - use_wake_word: false - noise_suppression_level: 2 - auto_gain: 31dBFS - volume_multiplier: 4.0 - id: assist - on_error: - - light.turn_off: - id: output_led - transition_length: 1s - - logger.log: "Voice Assistant encountered an error; restarting it" - - switch.turn_off: use_wake_word - - delay: 1s - - switch.turn_on: use_wake_word - on_wake_word_detected: - - light.turn_off: - id: output_led - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_listening: - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_stt_end: - - light.turn_off: - id: output_led - transition_length: 1s - on_tts_start: - - light.turn_off: - id: output_led - transition_length: 1s - - if: - condition: - lambda: return x != "Sorry, I couldn't understand that"; - then: - - logger.log: "Command successful!" - - light.turn_on: - id: output_led - effect: hold - red: 0 - green: 1 - blue: 0 - else: - - logger.log: "Command failed!" - - light.turn_on: - id: output_led - effect: hold - red: 1 - green: 0 - blue: 0 - -light: - - platform: rgb - id: output_led - red: rgb_r - green: rgb_g - blue: rgb_b - default_transition_length: 0.15s - flash_transition_length: 0.15s - effects: - - strobe: - name: flash_white - colors: - - state: true - brightness: 50% - red: 100% - green: 100% - blue: 100% - duration: 0.5s - - state: false - duration: 0.5s - - automation: - name: hold - sequence: - - delay: 5s - - light.turn_off: - id: output_led - transition_length: 1s - -output: - - platform: ledc - id: rgb_r - pin: GPIO32 - - platform: ledc - id: rgb_g - pin: GPIO33 - - platform: ledc - id: rgb_b - pin: GPIO25 - -bme680_bsec: - address: 0x77 - id: bme680_sensor - sample_rate: lp - state_save_interval: 1h - iaq_mode: static - -ld2410: - id: ld2410_radar - uart_id: ld2410_uart - # These default values are captured here for - # posterity. They are configured below. - # max_move_distance : 6m - # max_still_distance: 0.75m - # g0_move_threshold: 10 - # g0_still_threshold: 20 - # g1_move_threshold: 10 - # g1_still_threshold: 20 - # g2_move_threshold: 20 - # g2_still_threshold: 21 - # g3_move_threshold: 30 - # g3_still_threshold: 31 - # g4_move_threshold: 40 - # g4_still_threshold: 41 - # g5_move_threshold: 50 - # g5_still_threshold: 51 - # g6_move_threshold: 60 - # g6_still_threshold: 61 - # g7_move_threshold: 70 - # g7_still_threshold: 71 - # g8_move_threshold: 80 - # g8_still_threshold: 81 - -binary_sensor: - - platform: template - name: "SuperSensor Occupancy" - id: supersensor_occupancy - device_class: occupancy - - - platform: gpio - name: "PIR GPIO" - id: pir_gpio - pin: GPIO13 - internal: false - device_class: motion - on_press: - - script.stop: pir_handler - - script.execute: pir_handler - - - platform: template - name: "PIR Presence" - id: pir_presence - device_class: motion - on_press: - - script.execute: occupancy_detect_handler - on_release: - - script.execute: occupancy_clear_handler - - - platform: template - name: "Light Presence" - id: light_presence - device_class: motion - on_press: - - script.execute: occupancy_detect_handler - on_release: - - script.execute: occupancy_clear_handler - - - platform: ld2410 - ld2410_id: ld2410_radar - has_target: - name: "LD2410C Presence" - id: radar_presence - device_class: motion - on_press: - - script.execute: occupancy_detect_handler - on_release: - - script.execute: occupancy_clear_handler - has_moving_target: - name: "LD2410C Moving Target" - has_still_target: - name: "LD2410C Still Target" - -sensor: - - platform: bme680_bsec - bme680_bsec_id: bme680_sensor - temperature: - name: "BME680 Temperature" - id: bme680_temperature - pressure: - name: "BME680 Pressure" - id: bme680_pressure - humidity: - name: "BME680 Relative Humidity" - id: bme680_humidity - iaq: - name: "BME680 IAQ" - id: bme680_iaq - co2_equivalent: - name: "BME680 CO2 Equivalent" - breath_voc_equivalent: - name: "BME680 Breath VOC Equivalent" - gas_resistance: - name: "BME680 Gas Resistance" - id: bme680_gas_resistance - internal: yes - - - platform: absolute_humidity - name: "BME680 Absolute Humidity" - temperature: bme680_temperature - humidity: bme680_humidity - - - platform: tsl2591 - address: 0x29 - update_interval: 1s - integration_time: 200ms - power_save_mode: no - gain: auto - device_factor: 53 - glass_attenuation_factor: 7.7 - visible: - name: "TSL2591 Raw Visible" - infrared: - name: "TSL2591 Raw Infrared" - full_spectrum: - name: "TSL2591 Raw Full Spectrum" - calculated_lux: - id: tsl2591_lux - name: "TSL2591 Illumination" - unit_of_measurement: Lux - on_value: - - script.execute: light_handler - actual_gain: - id: "actual_gain" - name: "TSL2591 Gain" - - - platform: ld2410 - ld2410_id: ld2410_radar - moving_distance: - name: "LD2410C Moving Distance" - id: moving_distance - icon: mdi:signal-distance-variant - still_distance: - name: "LD2410C Still Distance" - id: still_distance - icon: mdi:signal-distance-variant - moving_energy: - name: "LD2410C Move Energy" - icon: mdi:flash - still_energy: - name: "LD2410C Still Energy" - icon: mdi:flash - detection_distance: - name: "LD2410C Presence Distance" - icon: mdi:signal-distance-variant - - - platform: uptime - name: "ESP32 Uptime" - icon: mdi:clock-alert - update_interval: 5s - entity_category: diagnostic - - - platform: wifi_signal - name: "WiFi RSSI" - icon: mdi:wifi-strength-2 - update_interval: 5s - entity_category: diagnostic - - - platform: internal_temperature - name: "ESP32 Temperature" - icon: mdi:thermometer - unit_of_measurement: °C - device_class: TEMPERATURE - update_interval: 5s - entity_category: diagnostic - - - platform: template - name: "ESP32 CPU Frequency" - icon: mdi:cpu-32-bit - accuracy_decimals: 1 - unit_of_measurement: MHz - update_interval: 5s - lambda: |- - return ets_get_cpu_frequency(); - entity_category: diagnostic - - - platform: template - name: "ESP32 Free Memory" - icon: mdi:memory - unit_of_measurement: 'kB' - state_class: measurement - update_interval: 5s - lambda: |- - return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; - entity_category: diagnostic - -text_sensor: - - platform: bme680_bsec - bme680_bsec_id: bme680_sensor - iaq_accuracy: - name: "BME680 IAQ Accuracy" - - - platform: template - name: "BME680 IAQ Classification" - icon: "mdi:air-filter" - update_interval: 15s - lambda: |- - int iaq = int(id(bme680_iaq).state); - if (iaq <= 50) { - return {"Excellent (" + to_string(iaq) + ")"}; - } - else if (iaq <= 100) { - return {"Good (" + to_string(iaq) + ")"}; - } - else if (iaq <= 150) { - return {"Fair (" + to_string(iaq) + ")"}; - } - else if (iaq <= 200) { - return {"Moderate (" + to_string(iaq) + ")"}; - } - else if (iaq <= 250) { - return {"Bad (" + to_string(iaq) + ")"}; - } - else if (iaq <= 350) { - return {"Very Bad (" + to_string(iaq) + ")"}; - } - else if (iaq <= 500) { - return {"Terrible (" + to_string(iaq) + ")"}; - } - else { - return {"Unknown (" + to_string(iaq) + ")"}; - } - - - platform: wifi_info - ip_address: - name: "WiFi IP Address" - ssid: - name: "WiFi SSID" - bssid: - name: "WiFi BSSID" - mac_address: - name: "WiFi MAC Address" - - - platform: ld2410 - version: - name: "LD2410C Firmware Version" - mac_address: - name: "LD2410C MAC Address" - -button: - - platform: ld2410 - restart: - name: "LD2410C Restart" - icon: mdi:power-cycle - entity_category: diagnostic - factory_reset: - name: "LD2410C Factory Reset" - entity_category: diagnostic - - - platform: restart - name: "ESP32 Restart" - icon: mdi:power-cycle - entity_category: diagnostic - -switch: - - platform: template - name: "Enable Wake Word" - icon: mdi:account-voice - id: use_wake_word - optimistic: true - restore_mode: ALWAYS_OFF - entity_category: config - on_turn_on: - - lambda: id(assist).set_use_wake_word(true); - - if: - condition: - not: - - voice_assistant.is_running - then: - - voice_assistant.start_continuous - on_turn_off: - - voice_assistant.stop - - lambda: id(assist).set_use_wake_word(false); - - - platform: ld2410 - engineering_mode: - name: "LD2410C Engineering Mode" - entity_category: diagnostic - bluetooth: - name: "LD2410C Bluetooth" - entity_category: diagnostic - -number: - # PIR Hold Time: - # The number of seconds after motion detection for the PIR sensor to remain held on - - platform: template - name: "PIR Hold Time" - id: pir_hold_time_setter - min_value: 0 - max_value: 60 - step: 5 - lambda: |- - return id(pir_hold_time); - set_action: - then: - - globals.set: - id: pir_hold_time - value: !lambda 'return int(x);' - - # Light Presence Threshold - # The minimum Lux value to consider presence based on the ambient light level - - platform: template - name: "Light Presence Threshold" - id: light_presence_threshold_setter - min_value: 0 - max_value: 200 - step: 5 - lambda: |- - return id(light_presence_threshold); - set_action: - then: - - globals.set: - id: light_presence_threshold - value: !lambda 'return int(x);' - - - platform: ld2410 - timeout: - name: "LD2410C Timeout" - light_threshold: - name: "LD2410C Light Threshold" - max_move_distance_gate: - name: "LD2410C Max Move Distance Gate" - max_still_distance_gate: - name: "LD2410C Max Still Distance Gate" - g0: - move_threshold: - name: "LD2410C Gate0 Move Threshold" - still_threshold: - name: "LD2410C Gate0 Still Threshold" - g1: - move_threshold: - name: "LD2410C Gate1 Move Threshold" - still_threshold: - name: "LD2410C Gate1 Still Threshold" - g2: - move_threshold: - name: "LD2410C Gate2 Move Threshold" - still_threshold: - name: "LD2410C Gate2 Still Threshold" - g3: - move_threshold: - name: "LD2410C Gate3 Move Threshold" - still_threshold: - name: "LD2410C Gate3 Still Threshold" - g4: - move_threshold: - name: "LD2410C Gate4 Move Threshold" - still_threshold: - name: "LD2410C Gate4 Still Threshold" - g5: - move_threshold: - name: "LD2410C Gate5 Move Threshold" - still_threshold: - name: "LD2410C Gate5 Still Threshold" - g6: - move_threshold: - name: "LD2410C Gate6 Move Threshold" - still_threshold: - name: "LD2410C Gate6 Still Threshold" - g7: - move_threshold: - name: "LD2410C Gate7 Move Threshold" - still_threshold: - name: "LD2410C Gate7 Still Threshold" - g8: - move_threshold: - name: "LD2410C Gate8 Move Threshold" - still_threshold: - name: "LD2410C Gate8 Still Threshold" - -select: - - # Occupancy Detect Mode: - # This selector defines the detection mode for the integrated occupancy sensor. Depending on the - # selected option, only the given sensor(s) will be used to judge when occupancy begins (i.e. - # when the given sensor(s) detect, occupancy detects). - # * PIR + Radar + Light: - # All 3 sensors reporting detection simultaneously will begin occupancy - # * PIR + Radar - # Both PIR and Radar sensors reporting detection simultaneously will begin occupancy - # * PIR + Light - # Both PIR and Light sensors reporting detection simultaneously will begin occupancy - # * Radar + Light - # Both Radar and Light sensors reporting detection simultaneously will begin occupancy - # * PIR Only - # PIR sensor reporting detection will begin occupancy - # * Radar Only - # Radar sensor reporting detection will begin occupancy - # * Light Only - # Light sensor reporting detection will begin occupancy - # * None - # No sensors will begin occupancy and the integrated occupancy functionality is disabled - # Values are reported as integers using bitwise logic: - # Bit 2: PIR - # Bit 1: Radar - # Bit 0: Light - - platform: template - name: "Occupancy Detect Mode" - id: occupancy_detect_mode_setter - options: - - "PIR + Radar + Light" # 111 = 7 - - "PIR + Radar" # 110 = 6 - - "PIR + Light" # 101 = 5 - - "Radar + Light" # 011 = 3 - - "PIR Only" # 100 = 4 - - "Radar Only" # 010 = 2 - - "Light Only" # 001 = 1 - - "None" # 000 = 0 - initial_option: "None" - optimistic: yes - restore_value: yes - set_action: - - globals.set: - id: occupancy_detect_mode - value: !lambda |- - ESP_LOGD("occupancy_detect_mode_setter", x.c_str()); - if (x == "PIR + Radar + Light") { - return 7; - } else if (x == "PIR + Radar") { - return 6; - } else if (x == "PIR + Light") { - return 5; - } else if (x == "Radar + Light") { - return 3; - } else if (x == "PIR Only") { - return 4; - } else if (x == "Radar Only") { - return 2; - } else if (x == "Light Only") { - return 1; - } else { - return 0; - } - - # Occupancy Clear Mode: - # This selector defines the clear mode for the integrated occupancy sensor. Depending on the - # selected option, only the given sensor(s) will be used to judge when occupancy ends (i.e. - # when the given sensor(s) clear, occupancy clears). - # * PIR + Radar + Light: - # Any of the 3 sensors clearing will end occupancy - # * PIR + Radar: - # Either of the PIR or Radar sensors clearing will end occupancy - # * PIR + Light: - # Either of the PIR or Light sensors clearing will end occupancy - # * Radar + Light: - # Either of the Radar or Light sensors clearing will end occupancy - # * PIR Only - # PIR sensor clearing will end occupancy - # * Radar Only - # Radar sensor clearing will end occupancy - # * Light Only - # Light sensor clearing will end occupancy - # * None - # No sensors will end occupancy; state will persist indefinitely once triggered - # Values are reported as integers using bitwise logic: - # Bit 0: PIR - # Bit 1: Radar - # Bit 2: Light - - platform: template - name: "Occupancy Clear Mode" - id: occupancy_clear_mode_setter - options: - - "PIR + Radar + Light" # 111 = 7 - - "PIR + Radar" # 110 = 6 - - "PIR + Light" # 101 = 5 - - "Radar + Light" # 011 = 3 - - "PIR Only" # 100 = 4 - - "Radar Only" # 010 = 2 - - "Light Only" # 001 = 1 - - "None" # 000 = 0 - initial_option: "None" - optimistic: yes - restore_value: yes - set_action: - - globals.set: - id: occupancy_clear_mode - value: !lambda |- - ESP_LOGD("occupancy_detect_mode_setter", x.c_str()); - if (x == "PIR + Radar + Light") { - return 7; - } else if (x == "PIR + Radar") { - return 6; - } else if (x == "PIR + Light") { - return 5; - } else if (x == "Radar + Light") { - return 3; - } else if (x == "PIR Only") { - return 4; - } else if (x == "Radar Only") { - return 2; - } else if (x == "Light Only") { - return 1; - } else { - return 0; - } - - - platform: ld2410 - distance_resolution: - name: "LD2410C Distance Resolution" diff --git a/archive/supersensor_bme680stock.yaml b/archive/supersensor_bme680stock.yaml deleted file mode 100644 index bde7693..0000000 --- a/archive/supersensor_bme680stock.yaml +++ /dev/null @@ -1,861 +0,0 @@ ---- - -############################################################################### -# SuperSensor v1.0 ESPHome configuration -############################################################################### -# -# Copyright (C) 2023 Joshua M. Boniface -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################### - -esphome: - name: supersensor - name_add_mac_suffix: true - friendly_name: "Supersensor" - project: - name: joshuaboniface.supersensor - version: "0.1" - on_boot: - - priority: 600 - then: - - lambda: |- - id(supersensor_occupancy).publish_state(false); - id(pir_presence).publish_state(false); - id(light_presence).publish_state(false); - - light.turn_on: - id: output_led - effect: flash_white - -dashboard_import: - package_import_url: github://joshuaboniface/supersensor/supersensor.yaml - import_full_config: false - -esp32: - board: esp32dev - framework: - type: esp-idf - sdkconfig_options: - CONFIG_ESP32_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32_DATA_CACHE_64KB: "y" - CONFIG_ESP32_DATA_CACHE_LINE_64B: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" - CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ: "240" - CONFIG_ESP32S3_DATA_CACHE_64KB: "y" - CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" - -globals: - - id: pir_hold_time - type: int - restore_value: yes - initial_value: "15" - - - id: light_presence_threshold - type: int - restore_value: yes - initial_value: "30" - - - id: occupancy_detect_mode - type: int - restore_value: yes - initial_value: "0" - - - id: occupancy_clear_mode - type: int - restore_value: yes - initial_value: "0" - -script: - - id: pir_handler - then: - - lambda: |- - id(pir_presence).publish_state(true); - - while: - condition: - binary_sensor.is_on: pir_gpio - then: - - delay: !lambda 'return(id(pir_hold_time) * 1000);' - - lambda: |- - id(pir_presence).publish_state(false); - - - id: light_handler - then: - - lambda: |- - if (id(tsl2591_lux).state >= id(light_presence_threshold)) { - id(light_presence).publish_state(true); - } else { - id(light_presence).publish_state(false); - } - - - id: occupancy_detect_handler - then: - - lambda: |- - ESP_LOGD("occupancy_detect_handler", "Occupancy detect handler triggered"); - - // Get the current values of our presence sensors - bool pir = id(pir_presence).state; - bool radar = id(radar_presence).state; - bool light = id(light_presence).state; - - // Determine if PIR counts (2nd bit of presence_type) - int pir_counts = (id(occupancy_detect_mode) & ( 1 << 2 )) >> 2; - - // Determine if Radar counts (1st bit of presence_type) - int radar_counts = (id(occupancy_detect_mode) & ( 1 << 1 )) >> 1; - - // Determine if Light counts (0th bit of presence_type) - int light_counts = (id(occupancy_detect_mode) & ( 1 << 0 )) >> 0; - - // Determine our results - if (pir_counts & radar_counts & light_counts) { - // Logical AND of pir & radar & light - ESP_LOGD("occupancy_detect_handler", "PIR & Radar & Light: %i", pir & radar & light); - id(supersensor_occupancy).publish_state(pir & radar & light); - } else if (pir_counts & radar_counts) { - // Logical AND of pir & radar - ESP_LOGD("occupancy_detect_handler", "PIR & Radar: %i", pir & radar); - id(supersensor_occupancy).publish_state(pir & radar); - } else if (pir_counts & light_counts) { - // Logical AND of pir & light - ESP_LOGD("occupancy_detect_handler", "PIR & Light: %i", pir & light); - id(supersensor_occupancy).publish_state(pir & light); - } else if (radar_counts & light_counts) { - // Logical AND of radar & light - ESP_LOGD("occupancy_detect_handler", "Radar & Light: %i", radar & light); - id(supersensor_occupancy).publish_state(radar & light); - } else if (pir_counts) { - // Only pir - ESP_LOGD("occupancy_detect_handler", "PIR: %i", pir); - id(supersensor_occupancy).publish_state(pir); - } else if (radar_counts) { - // Only radar - ESP_LOGD("occupancy_detect_handler", "Radar: %i", radar); - id(supersensor_occupancy).publish_state(radar); - } else if (light_counts) { - // Only light - ESP_LOGD("occupancy_detect_handler", "Light: %i", light); - id(supersensor_occupancy).publish_state(light); - } else { - ESP_LOGD("occupancy_detect_handler", "None"); - id(supersensor_occupancy).publish_state(false); - } - - - id: occupancy_clear_handler - then: - - lambda: |- - ESP_LOGD("occupancy_clear_handler", "Occupancy clear handler triggered"); - - // Get the current values of our presence sensors - bool pir = id(pir_presence).state; - bool radar = id(radar_presence).state; - bool light = id(light_presence).state; - - // Determine if PIR counts (2nd bit of presence_type) - int pir_counts = (id(occupancy_clear_mode) & ( 1 << 2 )) >> 2; - - // Determine if Radar counts (1st bit of presence_type) - int radar_counts = (id(occupancy_clear_mode) & ( 1 << 1 )) >> 1; - - // Determine if Light counts (0th bit of presence_type) - int light_counts = (id(occupancy_clear_mode) & ( 1 << 0 )) >> 0; - - // Determine our results - if (pir_counts & radar_counts & light_counts) { - // Logical AND of pir & radar & light - ESP_LOGD("occupancy_clear_handler", "PIR & Radar & Light: %i", pir & radar & light); - id(supersensor_occupancy).publish_state(pir & radar & light); - } else if (pir_counts & radar_counts) { - // Logical AND of pir & radar - ESP_LOGD("occupancy_clear_handler", "PIR & Radar: %i", pir & radar); - id(supersensor_occupancy).publish_state(pir & radar); - } else if (pir_counts & light_counts) { - // Logical AND of pir & light - ESP_LOGD("occupancy_clear_handler", "PIR & Light: %i", pir & light); - id(supersensor_occupancy).publish_state(pir & light); - } else if (radar_counts & light_counts) { - // Logical AND of radar & light - ESP_LOGD("occupancy_clear_handler", "Radar & Light: %i", radar & light); - id(supersensor_occupancy).publish_state(radar & light); - } else if (pir_counts) { - // Only pir - ESP_LOGD("occupancy_clear_handler", "PIR: %i", pir); - id(supersensor_occupancy).publish_state(pir); - } else if (radar_counts) { - // Only radar - ESP_LOGD("occupancy_clear_handler", "Radar: %i", radar); - id(supersensor_occupancy).publish_state(radar); - } else if (light_counts) { - // Only light - ESP_LOGD("occupancy_clear_handler", "Light: %i", light); - id(supersensor_occupancy).publish_state(light); - } else { - ESP_LOGD("occupancy_clear_handler", "None"); - id(supersensor_occupancy).publish_state(false); - } - -logger: - level: DEBUG - baud_rate: 115200 - -api: - encryption: - key: !secret api_encryption_key - on_client_disconnected: - - light.turn_on: - id: output_led - effect: flash_white - - switch.turn_off: use_wake_word - on_client_connected: - # This absolute absurdity is required to prevent - # "no wake word detected" failure loops. - - switch.turn_on: use_wake_word - - delay: 2s - - switch.turn_off: use_wake_word - - delay: 2s - - switch.turn_on: use_wake_word - - delay: 2s - - light.turn_off: - id: output_led - -ota: - password: !secret ota_password - safe_mode: false - -web_server: - port: 80 - auth: - username: !secret web_auth_username - password: !secret web_auth_password - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - domain: !secret wifi_domain - power_save_mode: LIGHT - reboot_timeout: 5min - -uart: - id: ld2410_uart - rx_pin: GPIO19 - tx_pin: GPIO18 - baud_rate: 256000 - data_bits: 8 - stop_bits: 1 - parity: NONE - -i2c: - sda: GPIO16 - scl: GPIO17 - scan: true - -i2s_audio: - i2s_lrclk_pin: GPIO26 - i2s_bclk_pin: GPIO27 - -microphone: - - platform: i2s_audio - id: mic - adc_type: external - i2s_din_pin: GPIO14 - pdm: false - -voice_assistant: - microphone: mic - use_wake_word: false - noise_suppression_level: 2 - auto_gain: 31dBFS - volume_multiplier: 4.0 - id: assist - on_error: - - light.turn_off: - id: output_led - transition_length: 1s - - logger.log: "Voice Assistant encountered an error; restarting it" - - switch.turn_off: use_wake_word - - delay: 1s - - switch.turn_on: use_wake_word - on_wake_word_detected: - - light.turn_off: - id: output_led - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_listening: - - light.turn_on: - id: output_led - red: 0 - green: 0 - blue: 1 - on_stt_end: - - light.turn_off: - id: output_led - transition_length: 1s - on_tts_start: - - light.turn_off: - id: output_led - transition_length: 1s - - if: - condition: - lambda: return x != "Sorry, I couldn't understand that"; - then: - - logger.log: "Command successful!" - - light.turn_on: - id: output_led - effect: hold - red: 0 - green: 1 - blue: 0 - else: - - logger.log: "Command failed!" - - light.turn_on: - id: output_led - effect: hold - red: 1 - green: 0 - blue: 0 - -light: - - platform: rgb - id: output_led - red: rgb_r - green: rgb_g - blue: rgb_b - default_transition_length: 0.15s - flash_transition_length: 0.15s - effects: - - strobe: - name: flash_white - colors: - - state: true - brightness: 50% - red: 100% - green: 100% - blue: 100% - duration: 0.5s - - state: false - duration: 0.5s - - automation: - name: hold - sequence: - - delay: 5s - - light.turn_off: - id: output_led - transition_length: 1s - -output: - - platform: ledc - id: rgb_r - pin: GPIO32 - - platform: ledc - id: rgb_g - pin: GPIO33 - - platform: ledc - id: rgb_b - pin: GPIO25 - -ld2410: - id: ld2410_radar - uart_id: ld2410_uart - # These default values are captured here for - # posterity. They are configured below. - # max_move_distance : 6m - # max_still_distance: 0.75m - # g0_move_threshold: 10 - # g0_still_threshold: 20 - # g1_move_threshold: 10 - # g1_still_threshold: 20 - # g2_move_threshold: 20 - # g2_still_threshold: 21 - # g3_move_threshold: 30 - # g3_still_threshold: 31 - # g4_move_threshold: 40 - # g4_still_threshold: 41 - # g5_move_threshold: 50 - # g5_still_threshold: 51 - # g6_move_threshold: 60 - # g6_still_threshold: 61 - # g7_move_threshold: 70 - # g7_still_threshold: 71 - # g8_move_threshold: 80 - # g8_still_threshold: 81 - -binary_sensor: - - platform: template - name: "SuperSensor Occupancy" - id: supersensor_occupancy - device_class: occupancy - - - platform: gpio - name: "PIR GPIO" - id: pir_gpio - pin: GPIO13 - internal: false - device_class: motion - on_press: - - script.stop: pir_handler - - script.execute: pir_handler - - - platform: template - name: "PIR Presence" - id: pir_presence - device_class: motion - on_press: - - script.execute: occupancy_detect_handler - on_release: - - script.execute: occupancy_clear_handler - - - platform: template - name: "Light Presence" - id: light_presence - device_class: motion - on_press: - - script.execute: occupancy_detect_handler - on_release: - - script.execute: occupancy_clear_handler - - - platform: ld2410 - ld2410_id: ld2410_radar - has_target: - name: "LD2410C Presence" - id: radar_presence - device_class: motion - on_press: - - script.execute: occupancy_detect_handler - on_release: - - script.execute: occupancy_clear_handler - has_moving_target: - name: "LD2410C Moving Target" - has_still_target: - name: "LD2410C Still Target" - -sensor: - - platform: bme680 - temperature: - name: "BME680 Temperature" - id: bme680_temperature - pressure: - name: "BME680 Pressure" - id: bme680_pressure - humidity: - name: "BME680 Relative Humidity" - id: bme680_humidity - gas_resistance: - name: "BME680 Gas Resistance" - id: bme680_gas_resistance - address: 0x77 - update_interval: 5s - - - platform: absolute_humidity - name: "BME680 Absolute Humidity" - temperature: bme680_temperature - humidity: bme680_humidity - - - platform: template - name: "BME680 Indoor Air Quality" - id: bme680_iaq - icon: "mdi:gauge" - # caulculation: comp_gas = log(R_gas[ohm]) + 0.04 log(Ohm)/%rh * hum[%rh] - lambda: |- - return float(log(id(bme680_gas_resistance).state) + 0.04 * id(bme680_humidity).state); - - - platform: tsl2591 - address: 0x29 - update_interval: 1s - integration_time: 200ms - power_save_mode: no - gain: auto - device_factor: 53 - glass_attenuation_factor: 7.7 - visible: - name: "TSL2591 Raw Visible" - infrared: - name: "TSL2591 Raw Infrared" - full_spectrum: - name: "TSL2591 Raw Full Spectrum" - calculated_lux: - id: tsl2591_lux - name: "TSL2591 Illumination" - unit_of_measurement: Lux - on_value: - - script.execute: light_handler - actual_gain: - id: "actual_gain" - name: "TSL2591 Gain" - - - platform: ld2410 - ld2410_id: ld2410_radar - moving_distance: - name: "LD2410C Moving Distance" - id: moving_distance - still_distance: - name: "LD2410C Still Distance" - id: still_distance - moving_energy: - name: "LD2410C Move Energy" - still_energy: - name: "LD2410C Still Energy" - detection_distance: - name: "LD2410C Presence Distance" - - - platform: uptime - name: "ESP32 Uptime" - icon: mdi:clock-alert - update_interval: 5s - entity_category: diagnostic - - - platform: wifi_signal - name: "WiFi RSSI" - icon: mdi:wifi-strength-2 - update_interval: 5s - entity_category: diagnostic - - - platform: internal_temperature - name: "ESP32 Temperature" - icon: mdi:thermometer - unit_of_measurement: °C - device_class: TEMPERATURE - update_interval: 5s - entity_category: diagnostic - - - platform: template - name: "ESP32 CPU Frequency" - icon: mdi:cpu-32-bit - accuracy_decimals: 1 - unit_of_measurement: MHz - update_interval: 5s - lambda: |- - return ets_get_cpu_frequency(); - entity_category: diagnostic - - - platform: template - name: "ESP32 Free Memory" - icon: mdi:memory - unit_of_measurement: 'kB' - state_class: measurement - update_interval: 5s - lambda: |- - return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; - entity_category: diagnostic - -text_sensor: - - platform: template - name: "BME680 IAQ Classification" - icon: "mdi:air-filter" - update_interval: 15s - lambda: |- - int iaq = int(id(bme680_iaq).state); - if (iaq <= 50) { - return {"Excellent (" + to_string(iaq) + ")"}; - } - else if (iaq <= 100) { - return {"Good (" + to_string(iaq) + ")"}; - } - else if (iaq <= 150) { - return {"Fair (" + to_string(iaq) + ")"}; - } - else if (iaq <= 200) { - return {"Moderate (" + to_string(iaq) + ")"}; - } - else if (iaq <= 250) { - return {"Bad (" + to_string(iaq) + ")"}; - } - else if (iaq <= 350) { - return {"Very Bad (" + to_string(iaq) + ")"}; - } - else if (iaq <= 500) { - return {"Terrible (" + to_string(iaq) + ")"}; - } - else { - return {"Unknown (" + to_string(iaq) + ")"}; - } - - - platform: wifi_info - ip_address: - name: "WiFi IP Address" - ssid: - name: "WiFi SSID" - bssid: - name: "WiFi BSSID" - mac_address: - name: "WiFi MAC Address" - - - platform: ld2410 - version: - name: "LD2410C Firmware Version" - mac_address: - name: "LD2410C MAC Address" - -button: - - platform: ld2410 - restart: - name: "LD2410C Restart" - icon: mdi:power-cycle - entity_category: diagnostic - factory_reset: - name: "LD2410C Factory Reset" - entity_category: diagnostic - - - platform: restart - name: "ESP32 Restart" - icon: mdi:power-cycle - entity_category: diagnostic - -switch: - - platform: template - name: "Enable Wake Word" - icon: mdi:account-voice - id: use_wake_word - optimistic: true - restore_mode: ALWAYS_OFF - entity_category: config - on_turn_on: - - lambda: id(assist).set_use_wake_word(true); - - if: - condition: - not: - - voice_assistant.is_running - then: - - voice_assistant.start_continuous - on_turn_off: - - voice_assistant.stop - - lambda: id(assist).set_use_wake_word(false); - - - platform: ld2410 - engineering_mode: - name: "LD2410C Engineering Mode" - entity_category: diagnostic - bluetooth: - name: "LD2410C Bluetooth" - entity_category: diagnostic - -number: - # PIR Hold Time: - # The number of seconds after motion detection for the PIR sensor to remain held on - - platform: template - name: "PIR Hold Time" - id: pir_hold_time_setter - min_value: 0 - max_value: 60 - step: 5 - lambda: |- - return id(pir_hold_time); - set_action: - then: - - globals.set: - id: pir_hold_time - value: !lambda 'return int(x);' - - # Light Presence Threshold - # The minimum Lux value to consider presence based on the ambient light level - - platform: template - name: "Light Presence Threshold" - id: light_presence_threshold_setter - min_value: 0 - max_value: 200 - step: 5 - lambda: |- - return id(light_presence_threshold); - set_action: - then: - - globals.set: - id: light_presence_threshold - value: !lambda 'return int(x);' - - - platform: ld2410 - timeout: - name: "LD2410C Timeout" - light_threshold: - name: "LD2410C Light Threshold" - max_move_distance_gate: - name: "LD2410C Max Move Distance Gate" - max_still_distance_gate: - name: "LD2410C Max Still Distance Gate" - g0: - move_threshold: - name: "LD2410C Gate0 Move Threshold" - still_threshold: - name: "LD2410C Gate0 Still Threshold" - g1: - move_threshold: - name: "LD2410C Gate1 Move Threshold" - still_threshold: - name: "LD2410C Gate1 Still Threshold" - g2: - move_threshold: - name: "LD2410C Gate2 Move Threshold" - still_threshold: - name: "LD2410C Gate2 Still Threshold" - g3: - move_threshold: - name: "LD2410C Gate3 Move Threshold" - still_threshold: - name: "LD2410C Gate3 Still Threshold" - g4: - move_threshold: - name: "LD2410C Gate4 Move Threshold" - still_threshold: - name: "LD2410C Gate4 Still Threshold" - g5: - move_threshold: - name: "LD2410C Gate5 Move Threshold" - still_threshold: - name: "LD2410C Gate5 Still Threshold" - g6: - move_threshold: - name: "LD2410C Gate6 Move Threshold" - still_threshold: - name: "LD2410C Gate6 Still Threshold" - g7: - move_threshold: - name: "LD2410C Gate7 Move Threshold" - still_threshold: - name: "LD2410C Gate7 Still Threshold" - g8: - move_threshold: - name: "LD2410C Gate8 Move Threshold" - still_threshold: - name: "LD2410C Gate8 Still Threshold" - -select: - - # Occupancy Detect Mode: - # This selector defines the detection mode for the integrated occupancy sensor. Depending on the - # selected option, only the given sensor(s) will be used to judge when occupancy begins (i.e. - # when the given sensor(s) detect, occupancy detects). - # * PIR + Radar + Light: - # All 3 sensors reporting detection simultaneously will begin occupancy - # * PIR + Radar - # Both PIR and Radar sensors reporting detection simultaneously will begin occupancy - # * PIR + Light - # Both PIR and Light sensors reporting detection simultaneously will begin occupancy - # * Radar + Light - # Both Radar and Light sensors reporting detection simultaneously will begin occupancy - # * PIR Only - # PIR sensor reporting detection will begin occupancy - # * Radar Only - # Radar sensor reporting detection will begin occupancy - # * Light Only - # Light sensor reporting detection will begin occupancy - # * None - # No sensors will begin occupancy and the integrated occupancy functionality is disabled - # Values are reported as integers using bitwise logic: - # Bit 2: PIR - # Bit 1: Radar - # Bit 0: Light - - platform: template - name: "Occupancy Detect Mode" - id: occupancy_detect_mode_setter - options: - - "PIR + Radar + Light" # 111 = 7 - - "PIR + Radar" # 110 = 6 - - "PIR + Light" # 101 = 5 - - "Radar + Light" # 011 = 3 - - "PIR Only" # 100 = 4 - - "Radar Only" # 010 = 2 - - "Light Only" # 001 = 1 - - "None" # 000 = 0 - initial_option: "None" - optimistic: yes - restore_value: yes - set_action: - - globals.set: - id: occupancy_detect_mode - value: !lambda |- - ESP_LOGD("occupancy_detect_mode_setter", x.c_str()); - if (x == "PIR + Radar + Light") { - return 7; - } else if (x == "PIR + Radar") { - return 6; - } else if (x == "PIR + Light") { - return 5; - } else if (x == "Radar + Light") { - return 3; - } else if (x == "PIR Only") { - return 4; - } else if (x == "Radar Only") { - return 2; - } else if (x == "Light Only") { - return 1; - } else { - return 0; - } - - # Occupancy Clear Mode: - # This selector defines the clear mode for the integrated occupancy sensor. Depending on the - # selected option, only the given sensor(s) will be used to judge when occupancy ends (i.e. - # when the given sensor(s) clear, occupancy clears). - # * PIR + Radar + Light: - # Any of the 3 sensors clearing will end occupancy - # * PIR + Radar: - # Either of the PIR or Radar sensors clearing will end occupancy - # * PIR + Light: - # Either of the PIR or Light sensors clearing will end occupancy - # * Radar + Light: - # Either of the Radar or Light sensors clearing will end occupancy - # * PIR Only - # PIR sensor clearing will end occupancy - # * Radar Only - # Radar sensor clearing will end occupancy - # * Light Only - # Light sensor clearing will end occupancy - # * None - # No sensors will end occupancy; state will persist indefinitely once triggered - # Values are reported as integers using bitwise logic: - # Bit 0: PIR - # Bit 1: Radar - # Bit 2: Light - - platform: template - name: "Occupancy Clear Mode" - id: occupancy_clear_mode_setter - options: - - "PIR + Radar + Light" # 111 = 7 - - "PIR + Radar" # 110 = 6 - - "PIR + Light" # 101 = 5 - - "Radar + Light" # 011 = 3 - - "PIR Only" # 100 = 4 - - "Radar Only" # 010 = 2 - - "Light Only" # 001 = 1 - - "None" # 000 = 0 - initial_option: "None" - optimistic: yes - restore_value: yes - set_action: - - globals.set: - id: occupancy_clear_mode - value: !lambda |- - ESP_LOGD("occupancy_detect_mode_setter", x.c_str()); - if (x == "PIR + Radar + Light") { - return 7; - } else if (x == "PIR + Radar") { - return 6; - } else if (x == "PIR + Light") { - return 5; - } else if (x == "Radar + Light") { - return 3; - } else if (x == "PIR Only") { - return 4; - } else if (x == "Radar Only") { - return 2; - } else if (x == "Light Only") { - return 1; - } else { - return 0; - } - - - platform: ld2410 - distance_resolution: - name: "LD2410C Distance Resolution"