From 48a468088a706a20711feabf1f395bdda960db10 Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Wed, 16 Jul 2025 17:07:57 +0100 Subject: [PATCH] add initial sensor configuration files --- server/ha-sensors/blank-template.yaml | 112 +++++++++++++ server/ha-sensors/living-room-sensor.yaml | 183 ++++++++++++++++++++++ server/ha-sensors/office-sensor.yaml | 144 +++++++++++++++++ 3 files changed, 439 insertions(+) create mode 100644 server/ha-sensors/blank-template.yaml create mode 100644 server/ha-sensors/living-room-sensor.yaml create mode 100644 server/ha-sensors/office-sensor.yaml diff --git a/server/ha-sensors/blank-template.yaml b/server/ha-sensors/blank-template.yaml new file mode 100644 index 00000000..eb94d956 --- /dev/null +++ b/server/ha-sensors/blank-template.yaml @@ -0,0 +1,112 @@ +esphome: + name: name + friendly_name: Name + + # Boot sequence - start with WiFi connecting effect + on_boot: + - priority: 600 + then: + - logger.log: "Device booting, starting WiFi connection" + - light.turn_on: + id: status_led + effect: "wifi_connecting" + +esp32: + board: esp32-s3-devkitc-1 + framework: + type: esp-idf + sdkconfig_options: + CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" + CONFIG_ESP32S3_DATA_CACHE_64KB: "y" + CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" + CONFIG_AUDIO_BOARD_CUSTOM: "y" + +psram: + mode: octal + speed: 80MHz + +# Enable logging +logger: + +# Enable Home Assistant API +api: + encryption: + key: "ZGLTCJYjvXIJA0LIP8o/k9Vp+Tia9AhHgXZ/WHCQ1gQ=" + + # API connection event handlers + on_client_connected: + - logger.log: "Home Assistant API connected" + - light.turn_off: status_led + + on_client_disconnected: + - logger.log: "Home Assistant API disconnected" + - light.turn_on: + id: status_led + effect: "ha_connecting" + +# Allow Over-The-Air updates +ota: + - platform: esphome + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # WiFi connection event handlers + on_connect: + - logger.log: "WiFi connected, attempting Home Assistant connection" + - light.turn_on: + id: status_led + effect: "ha_connecting" + + on_disconnect: + - logger.log: "WiFi disconnected" + - light.turn_on: + id: status_led + effect: "wifi_connecting" + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Living-Room-Sensor Hotspot" + password: !secret ota_password + +# Status LED configuration +light: + - platform: esp32_rmt_led_strip + id: status_led + name: "Status LED" + pin: GPIO48 + num_leds: 1 + chipset: ws2812 + rgb_order: GRB + effects: + # Yellow blinking during WiFi connection + - strobe: + name: "wifi_connecting" + colors: + - state: true + brightness: 80% + red: 100% + green: 100% + blue: 0% + duration: 500ms + - state: false + duration: 500ms + # Orange blinking during Home Assistant connection + - strobe: + name: "ha_connecting" + colors: + - state: true + brightness: 80% + red: 100% + green: 65% + blue: 0% + duration: 300ms + - state: false + duration: 300ms + +button: + - platform: restart + name: "Restart Sensor" + id: restart_button diff --git a/server/ha-sensors/living-room-sensor.yaml b/server/ha-sensors/living-room-sensor.yaml new file mode 100644 index 00000000..b07670c9 --- /dev/null +++ b/server/ha-sensors/living-room-sensor.yaml @@ -0,0 +1,183 @@ +esphome: + name: esphome-web-e28960 + friendly_name: Living Room Sensor + min_version: 2025.5.0 + name_add_mac_suffix: false + + # Boot sequence - start with WiFi connecting effect + on_boot: + - priority: 600 + then: + - logger.log: "Device booting, starting WiFi connection" + - light.turn_on: + id: status_led + effect: "wifi_connecting" + +esp32: + board: esp32-s3-devkitc-1 + framework: + type: esp-idf + sdkconfig_options: + CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" + CONFIG_ESP32S3_DATA_CACHE_64KB: "y" + CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" + CONFIG_AUDIO_BOARD_CUSTOM: "y" + +psram: + mode: octal + speed: 80MHz + +# Enable logging +logger: + +# UART configuration for LD2420 mmWave sensor +uart: + tx_pin: GPIO17 + rx_pin: GPIO16 + baud_rate: 115200 + parity: NONE + stop_bits: 1 + +# Enable Home Assistant API +api: + encryption: + key: "ZGLTCJYjvXIJA0LIP8o/k9Vp+Tia9AhHgXZ/WHCQ1gQ=" + + # API connection event handlers + on_client_connected: + - logger.log: "Home Assistant API connected" + - light.turn_off: status_led + + on_client_disconnected: + - logger.log: "Home Assistant API disconnected" + - light.turn_on: + id: status_led + effect: "ha_connecting" + +# Allow Over-The-Air updates +ota: + - platform: esphome + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # WiFi connection event handlers + on_connect: + - logger.log: "WiFi connected, attempting Home Assistant connection" + - light.turn_on: + id: status_led + effect: "ha_connecting" + + on_disconnect: + - logger.log: "WiFi disconnected" + - light.turn_on: + id: status_led + effect: "wifi_connecting" + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Living-Room-Sensor Hotspot" + password: !secret ota_password + +# Status LED configuration +light: + - platform: esp32_rmt_led_strip + id: status_led + name: "Status LED" + pin: GPIO48 + num_leds: 1 + chipset: ws2812 + rgb_order: GRB + effects: + # Yellow blinking during WiFi connection + - strobe: + name: "wifi_connecting" + colors: + - state: true + brightness: 80% + red: 100% + green: 100% + blue: 0% + duration: 500ms + - state: false + duration: 500ms + # Orange blinking during Home Assistant connection + - strobe: + name: "ha_connecting" + colors: + - state: true + brightness: 80% + red: 100% + green: 65% + blue: 0% + duration: 300ms + - state: false + duration: 300ms + +button: + - platform: restart + name: "Restart Sensor" + id: restart_button + + - platform: ld2420 + apply_config: + name: Apply Config + factory_reset: + name: Factory Reset + restart_module: + name: Restart Module + revert_config: + name: Undo Edits + +# DHT-22 Temperature and Humidity Sensor +sensor: + - platform: dht + pin: GPIO4 + model: DHT22 + temperature: + name: "Living Room Temperature" + id: living_room_temperature + humidity: + name: "Living Room Humidity" + id: living_room_humidity + update_interval: 60s + + - platform: ld2420 + moving_distance: + name: Moving Distance + +# LD2420 Presence Sensor +ld2420: + +text_sensor: + - platform: ld2420 + fw_version: + name: LD2420 Firmware + +binary_sensor: + - platform: ld2420 + has_target: + name: Presence + +select: + - platform: ld2420 + operating_mode: + name: Operating Mode + +number: + - platform: ld2420 + presence_timeout: + name: Detection Presence Timeout + min_gate_distance: + name: Detection Gate Minimum + max_gate_distance: + name: Detection Gate Maximum + # See "Number" section below for detail + gate_select: + name: Select Gate to Set + still_threshold: + name: Set Still Threshold Value + move_threshold: + name: Set Move Threshold Value diff --git a/server/ha-sensors/office-sensor.yaml b/server/ha-sensors/office-sensor.yaml new file mode 100644 index 00000000..3489e8cf --- /dev/null +++ b/server/ha-sensors/office-sensor.yaml @@ -0,0 +1,144 @@ +esphome: + name: office-sensor + friendly_name: Office Sensor + + # Boot sequence - start with WiFi connecting effect + on_boot: + - priority: 600 + then: + - logger.log: "Device booting, starting WiFi connection" + - light.turn_on: + id: status_led + effect: "wifi_connecting" + +esp32: + board: esp32-s3-devkitc-1 + framework: + type: esp-idf + sdkconfig_options: + CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y" + CONFIG_ESP32S3_DATA_CACHE_64KB: "y" + CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y" + CONFIG_AUDIO_BOARD_CUSTOM: "y" + +psram: + mode: octal + speed: 80MHz + +# Enable logging +logger: + +# I2C configuration for sensors +i2c: + sda: GPIO4 + scl: GPIO5 + scan: true + id: scd40_bus + +# Enable Home Assistant API +api: + encryption: + key: "ZGLTCJYjvXIJA0LIP8o/k9Vp+Tia9AhHgXZ/WHCQ1gQ=" + + # API connection event handlers + on_client_connected: + - logger.log: "Home Assistant API connected" + - light.turn_off: status_led + + on_client_disconnected: + - logger.log: "Home Assistant API disconnected" + - light.turn_on: + id: status_led + effect: "ha_connecting" + + actions: + - action: calibrate_co2_value + variables: + co2_ppm: int + then: + - scd4x.perform_forced_calibration: + value: !lambda "return co2_ppm;" + id: scd40_sensor + - action: factory_reset_co2_sensor + then: + - scd4x.factory_reset: scd40_sensor + +# Allow Over-The-Air updates +ota: + - platform: esphome + password: !secret ota_password + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # WiFi connection event handlers + on_connect: + - logger.log: "WiFi connected, attempting Home Assistant connection" + - light.turn_on: + id: status_led + effect: "ha_connecting" + + on_disconnect: + - logger.log: "WiFi disconnected" + - light.turn_on: + id: status_led + effect: "wifi_connecting" + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Living-Room-Sensor Hotspot" + password: !secret ota_password + +# Status LED configuration +light: + - platform: esp32_rmt_led_strip + id: status_led + name: "Status LED" + pin: GPIO48 + num_leds: 1 + chipset: ws2812 + rgb_order: GRB + effects: + # Yellow blinking during WiFi connection + - strobe: + name: "wifi_connecting" + colors: + - state: true + brightness: 80% + red: 100% + green: 100% + blue: 0% + duration: 500ms + - state: false + duration: 500ms + # Orange blinking during Home Assistant connection + - strobe: + name: "ha_connecting" + colors: + - state: true + brightness: 80% + red: 100% + green: 65% + blue: 0% + duration: 300ms + - state: false + duration: 300ms + +# SCD40 CO2, Temperature, and Humidity Sensor +sensor: + - platform: scd4x + id: scd40_sensor + co2: + name: "Office CO2" + temperature: + name: "Office Temperature" + humidity: + name: "Office Humidity" + measurement_mode: low_power_periodic + update_interval: 30s + +button: + - platform: restart + name: "Restart Sensor" + id: restart_button