From cb1929a1c0d317d116c09bbcfd8b02839058e966 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Sun, 22 Oct 2023 17:02:49 +0200 Subject: [PATCH 01/29] adding voice assistant --- docs/sensors.md | 4 +- esphome/esphome.yaml | 1 + esphome/packages/sensors/voice_assistant.yaml | 119 ++++++++++++++++++ 3 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 esphome/packages/sensors/voice_assistant.yaml diff --git a/docs/sensors.md b/docs/sensors.md index 41ab043..04ff0a0 100644 --- a/docs/sensors.md +++ b/docs/sensors.md @@ -90,9 +90,7 @@ for their high quality digital audio. | INMP441 | [Amazon DE³](https://amzn.to/40y8twJ), [AliExpress](https://de.aliexpress.com/wholesale?catId=0&initiative_id=SB_20221127114658&SearchText=inmp441&spm=a2g0o.tm800107193.1000002.0&dida=y) | ### Compatibility - -> **WARNING**: Not supported yet! -> This sensor is fully compatible with any other sensor or module. +> **AIOsense v2.1.0**: This sensor is fully compatible with any other sensor or module besides the buzzer. Please disconnect the buzzer first.
diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index 6369571..becec06 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -42,6 +42,7 @@ packages: # --- select your sensors --- - esphome/packages/sensors/bh1750.yaml # - esphome/packages/sensors/buzzer.yaml # AIOsense >= 2.1.x only + # - esphome/packages/sensors/voice_assistant.yaml # ESP32-C3 only (for now) # - esphome/packages/sensors/bme280.yaml # enable for bme280 - esphome/packages/sensors/bme680.yaml # disable for bme280 # - esphome/packages/sensors/bme680_bsec.yaml # does not work yet diff --git a/esphome/packages/sensors/voice_assistant.yaml b/esphome/packages/sensors/voice_assistant.yaml new file mode 100644 index 0000000..b6d02e3 --- /dev/null +++ b/esphome/packages/sensors/voice_assistant.yaml @@ -0,0 +1,119 @@ +# WIP, C3-mini only (for now) + +i2s_audio: + id: i2s_in + i2s_lrclk_pin: A5 # WS + i2s_bclk_pin: A1 # SCK + +microphone: + - platform: i2s_audio + id: mic_i2s + channel: left + adc_type: external + i2s_din_pin: A0 # SD + i2s_audio_id: i2s_in + pdm: false + +voice_assistant: + id: va + microphone: mic_i2s + noise_suppression_level: 2 + auto_gain: 31dBFS + volume_multiplier: 2.0 + on_listening: + - light.turn_on: + id: led + blue: 100% + red: 0% + green: 0% + brightness: 100% + effect: pulse + on_tts_start: + - light.turn_on: + id: led + blue: 0% + red: 0% + green: 100% + brightness: 100% + effect: pulse + on_end: + - delay: 100ms + - script.execute: reset_led + on_error: + - light.turn_on: + id: led + blue: 0% + red: 100% + green: 0% + brightness: 100% + effect: none + - delay: 1s + - script.execute: reset_led + - script.wait: reset_led + - lambda: |- + if (code == "wake-provider-missing" || code == "wake-engine-missing") { + id(use_wake_word).turn_off(); + } + +script: + - id: reset_led + then: + - if: + condition: + - switch.is_on: use_wake_word + - switch.is_on: listen_light + then: + - light.turn_on: + id: led + blue: 100% + red: 100% + green: 0% + brightness: 100% + effect: none + else: + - light.turn_off: led + +switch: + - platform: template + name: "VA Use Wake Word" + id: use_wake_word + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - lambda: id(va).set_use_wake_word(true); + - if: + condition: + not: + - voice_assistant.is_running + then: + - voice_assistant.start_continuous + - script.execute: reset_led + on_turn_off: + - voice_assistant.stop + - lambda: id(va).set_use_wake_word(false); + - script.execute: reset_led + + - platform: template + name: "VA Listen Light" + id: listen_light + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - script.execute: reset_led + on_turn_off: + - script.execute: reset_led + +esphome: + min_version: 2023.10.0 + on_boot: + - priority: -100 + then: + - wait_until: api.connected + - delay: 1s + - if: + condition: + switch.is_on: use_wake_word + then: + - voice_assistant.start_continuous: From 9cf81be096646e526f247e072dbdc3bd1f249bf5 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Sun, 22 Oct 2023 17:05:05 +0200 Subject: [PATCH 02/29] BSEC Quickfix (#122) --- esphome/esphome.yaml | 14 +- esphome/packages/sensors/bme280.yaml | 8 +- esphome/packages/sensors/bme680.yaml | 8 +- esphome/packages/sensors/bme680_bsec.yaml | 62 -------- esphome/packages/sensors/bme68x_bsec.yaml | 177 ++++++++++++++++++++++ 5 files changed, 192 insertions(+), 77 deletions(-) delete mode 100644 esphome/packages/sensors/bme680_bsec.yaml create mode 100644 esphome/packages/sensors/bme68x_bsec.yaml diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index becec06..abc439d 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -5,16 +5,16 @@ substitutions: # bh1750_update_interval: 5s - # bmex80_address: "0x76" # for some modules you have to change it to 0x77 - # bmex80_update_interval: 30s + # bme_address: "0x76" # for some modules you have to change it to 0x77 + # bme_update_interval: 30s + # co2_offset: "0" # bsec only # humidity_offset: "0" + # iaq_offset: "0" # bsec only # illuminance_offset: "0" # pressure_offset: "0" # temperature_offset: "0" - - # bme680_bsec_sample_rate: lp # lp -> 3s, ulp ->5min - # bme680_bsec_temperature_offset: "0" + # voc_offset: "0" # bsec only # LD2410(c) does not work? Please notice: # https://aiosense.readthedocs.io/en/latest/debugging/#ld2410c-does-not-work @@ -44,8 +44,8 @@ packages: # - esphome/packages/sensors/buzzer.yaml # AIOsense >= 2.1.x only # - esphome/packages/sensors/voice_assistant.yaml # ESP32-C3 only (for now) # - esphome/packages/sensors/bme280.yaml # enable for bme280 - - esphome/packages/sensors/bme680.yaml # disable for bme280 - # - esphome/packages/sensors/bme680_bsec.yaml # does not work yet + # - esphome/packages/sensors/bme680.yaml # disable for bme280 + - esphome/packages/sensors/bme68x_bsec.yaml - esphome/packages/sensors/occupancy.yaml # only if pir & mmWave are on - esphome/packages/sensors/pir.yaml - esphome/packages/sensors/rgb_led.yaml # esp32-c3-mini only diff --git a/esphome/packages/sensors/bme280.yaml b/esphome/packages/sensors/bme280.yaml index 3b1642e..ca78993 100644 --- a/esphome/packages/sensors/bme280.yaml +++ b/esphome/packages/sensors/bme280.yaml @@ -1,8 +1,8 @@ # https://esphome.io/cookbook/bme280_environment.html substitutions: - bmex80_address: "0x76" - bmex80_update_interval: 30s + bme_address: "0x76" + bme_update_interval: 30s humidity_offset: "0" pressure_offset: "0" temperature_offset: "0" @@ -62,8 +62,8 @@ number: sensor: - platform: bme280 id: bme280_sensor - address: "${bmex80_address}" - update_interval: "${bmex80_update_interval}" + address: "${bme_address}" + update_interval: "${bme_update_interval}" temperature: name: "Temperature" filters: diff --git a/esphome/packages/sensors/bme680.yaml b/esphome/packages/sensors/bme680.yaml index e9cb264..7fa2700 100644 --- a/esphome/packages/sensors/bme680.yaml +++ b/esphome/packages/sensors/bme680.yaml @@ -1,8 +1,8 @@ # https://esphome.io/components/sensor/bme680.html substitutions: - bmex80_address: "0x76" - bmex80_update_interval: "30s" + bme_address: "0x76" + bme_update_interval: "30s" humidity_offset: "0" pressure_offset: "0" temperature_offset: "0" @@ -62,8 +62,8 @@ number: sensor: - platform: bme680 id: bme680_sensor - address: "${bmex80_address}" - update_interval: "${bmex80_update_interval}" + address: "${bme_address}" + update_interval: "${bme_update_interval}" temperature: name: "Temperature" filters: diff --git a/esphome/packages/sensors/bme680_bsec.yaml b/esphome/packages/sensors/bme680_bsec.yaml deleted file mode 100644 index faaa340..0000000 --- a/esphome/packages/sensors/bme680_bsec.yaml +++ /dev/null @@ -1,62 +0,0 @@ -# https://esphome.io/components/sensor/bme680_bsec.html - -substitutions: - bmex80_address: "0x76" - bme680_bsec_sample_rate: lp - bme680_bsec_temperature_offset: "0" - -bme680_bsec: - address: "${bmex80_address}" - sample_rate: "${bme680_bsec_sample_rate}" - state_save_interval: 2h - temperature_offset: "${bme680_bsec_temperature_offset}" - -sensor: - - platform: bme680_bsec - temperature: - name: "Temperature" - pressure: - name: "Pressure" - humidity: - name: "Humidity" - iaq: - name: "IAQ" - id: iaq - co2_equivalent: - name: "CO2 Equivalent" - breath_voc_equivalent: - name: "Breath VOC Equivalent" - -text_sensor: - - platform: bme680_bsec - iaq_accuracy: - name: "IAQ Accuracy" - - - platform: template - name: "IAQ Classification" - icon: "mdi:checkbox-marked-circle-outline" - lambda: |- - if ( int(id(iaq).state) <= 50) { - return {"Excellent"}; - } - else if (int(id(iaq).state) >= 51 && int(id(iaq).state) <= 100) { - return {"Good"}; - } - else if (int(id(iaq).state) >= 101 && int(id(iaq).state) <= 150) { - return {"Lightly polluted"}; - } - else if (int(id(iaq).state) >= 151 && int(id(iaq).state) <= 200) { - return {"Moderately polluted"}; - } - else if (int(id(iaq).state) >= 201 && int(id(iaq).state) <= 250) { - return {"Heavily polluted"}; - } - else if (int(id(iaq).state) >= 251 && int(id(iaq).state) <= 350) { - return {"Severely polluted"}; - } - else if (int(id(iaq).state) >= 351) { - return {"Extremely polluted"}; - } - else { - return {"error"}; - } diff --git a/esphome/packages/sensors/bme68x_bsec.yaml b/esphome/packages/sensors/bme68x_bsec.yaml new file mode 100644 index 0000000..0f7f263 --- /dev/null +++ b/esphome/packages/sensors/bme68x_bsec.yaml @@ -0,0 +1,177 @@ +substitutions: + bme_address: "0x76" + co2_offset: "0" + humidity_offset: "0" + iaq_offset: "0" + pressure_offset: "0" + temperature_offset: "0" + voc_offset: "0" + +external_components: + - source: github://schluggi/esphome@dev + components: + - bme68x_bsec + +bme68x_bsec: + address: "${bme_address}" + bsec_configuration: 0,0,2,2,189,1,0,0,0,0,0,0,213,8,0,0,52,0,1,0,0,192,168,71,64,49,119,76,0,0,97,69,0,0,97,69,137,65,0,63,0,0,0,63,0,0,64,63,205,204,204,62,10,0,3,0,216,85,0,100,0,0,96,64,23,183,209,56,28,0,2,0,0,244,1,150,0,50,0,0,128,64,0,0,32,65,144,1,0,0,112,65,0,0,0,63,16,0,3,0,10,215,163,60,10,215,35,59,10,215,35,59,13,0,5,0,0,0,0,0,100,35,41,29,86,88,0,9,0,229,208,34,62,0,0,0,0,0,0,0,0,218,27,156,62,225,11,67,64,0,0,160,64,0,0,0,0,0,0,0,0,94,75,72,189,93,254,159,64,66,62,160,191,0,0,0,0,0,0,0,0,33,31,180,190,138,176,97,64,65,241,99,190,0,0,0,0,0,0,0,0,167,121,71,61,165,189,41,192,184,30,189,64,12,0,10,0,0,0,0,0,0,0,0,0,173,6,11,0,1,2,2,207,61,208,65,149,110,24,66,180,108,177,65,219,148,13,192,70,132,58,66,163,58,140,192,12,99,178,192,185,59,255,193,178,213,175,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,211,55,195,237,6,56,67,0,0,0,0,0,0,0,0,26,3,255,63,61,246,7,192,171,201,228,192,249,144,215,63,237,199,104,193,128,158,216,64,117,140,155,63,137,120,129,67,108,109,253,191,0,0,0,0,81,64,57,68,103,241,231,64,109,29,152,192,209,43,193,63,93,54,30,65,197,46,92,64,128,27,224,192,6,20,144,191,56,179,130,64,0,0,0,0,43,156,59,196,33,217,100,194,104,77,72,65,15,103,175,191,249,252,12,193,63,117,253,192,233,5,141,65,155,42,25,64,13,88,249,191,0,0,0,0,48,141,122,190,204,150,44,192,36,162,29,193,96,59,39,189,54,202,48,65,151,205,68,64,79,105,55,193,53,120,53,192,77,211,32,192,0,0,0,0,193,207,92,65,239,201,76,65,208,70,82,66,81,63,96,65,48,179,0,194,251,96,242,193,176,51,96,194,153,114,98,66,144,247,64,65,0,0,0,0,219,179,180,63,175,218,119,191,51,71,207,191,245,145,129,63,53,16,244,65,138,208,117,65,138,97,36,66,228,15,32,195,126,91,103,191,0,0,0,0,26,151,170,193,64,105,49,193,46,223,189,193,129,203,168,193,40,91,49,66,4,87,107,65,205,202,37,65,244,36,154,66,240,85,39,193,0,0,0,0,166,96,87,192,114,7,68,191,233,32,214,63,84,249,40,192,45,78,132,64,145,33,253,61,49,43,187,192,244,32,77,67,224,250,71,191,0,0,0,0,103,75,214,190,206,141,252,63,99,15,178,65,80,79,166,190,214,25,146,192,165,29,24,194,18,228,219,193,113,246,235,194,49,115,232,63,0,0,0,0,17,211,124,64,56,252,251,62,25,118,148,193,168,234,94,64,131,157,82,64,217,119,236,65,120,245,240,65,17,69,168,195,49,51,8,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,131,217,97,66,182,104,101,194,0,0,0,0,0,0,0,0,6,142,142,195,229,54,143,67,0,0,0,0,0,0,0,0,25,224,153,66,217,51,154,194,0,0,0,0,0,0,0,0,142,36,105,194,199,63,110,66,0,0,0,0,0,0,0,0,206,73,250,193,138,69,249,65,0,0,0,0,0,0,0,0,123,173,127,66,20,116,128,194,0,0,0,0,0,0,0,0,49,65,49,64,205,213,107,192,0,0,0,0,0,0,0,0,189,250,179,194,164,98,180,66,0,0,0,0,0,0,0,0,96,182,197,67,155,71,197,195,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,28,179,73,64,25,141,76,223,26,138,76,222,207,133,76,87,134,164,75,23,127,159,75,166,9,155,75,94,120,170,73,95,221,177,73,93,44,182,73,0,0,0,0,0,0,0,0,0,0,0,0,30,55,120,73,215,98,32,76,7,79,34,76,161,238,36,76,119,151,160,75,119,96,157,75,202,75,154,75,118,89,111,73,133,239,116,73,219,140,120,73,0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,87,1,254,0,2,1,5,48,117,100,0,44,1,112,23,151,7,132,3,197,0,92,4,144,1,64,1,64,1,144,1,48,117,48,117,48,117,48,117,100,0,100,0,100,0,48,117,48,117,48,117,100,0,100,0,48,117,48,117,8,7,8,7,8,7,8,7,8,7,100,0,100,0,100,0,100,0,48,117,48,117,48,117,100,0,100,0,100,0,48,117,48,117,100,0,100,0,255,255,255,255,255,255,255,255,255,255,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,255,255,255,255,255,255,255,255,255,255,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,255,255,255,255,255,255,255,255,255,255,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,220,5,220,5,220,5,255,255,255,255,255,255,220,5,220,5,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,48,117,0,5,10,5,0,2,0,10,0,30,0,5,0,5,0,5,0,5,0,5,0,5,0,64,1,100,0,100,0,100,0,200,0,200,0,200,0,64,1,64,1,64,1,10,0,0,0,0,145,33,0,0 + state_save_interval: 30min + +sensor: + - platform: bme68x_bsec + temperature: + name: "Temperature" + filters: + - offset: ${temperature_offset} + - lambda: "return x + id(temperature_offset_ui).state;" + pressure: + name: "Pressure" + device_class: atmospheric_pressure + filters: + - offset: ${pressure_offset} + - lambda: "return x + id(pressure_offset_ui).state;" + humidity: + name: "Humidity" + filters: + - offset: ${humidity_offset} + - lambda: "return x + id(humidity_offset_ui).state;" + iaq: + name: "IAQ" + id: iaq + device_class: aqi + filters: + - offset: ${iaq_offset} + - lambda: "return x + id(iaq_offset_ui).state;" + co2_equivalent: + name: "CO2 Equivalent" + device_class: carbon_dioxide + filters: + - offset: ${co2_offset} + - lambda: "return x + id(co2_offset_ui).state;" + breath_voc_equivalent: + name: "Breath VOC Equivalent" + device_class: volatile_organic_compounds + filters: + - offset: ${voc_offset} + - lambda: "return x + id(voc_offset_ui).state;" + +number: + - platform: template + name: "Temperature Offset" + id: temperature_offset_ui + unit_of_measurement: "°C" + min_value: -10 + max_value: 10 + step: 0.1 + mode: box + update_interval: never + optimistic: true + restore_value: true + initial_value: 0 + icon: "mdi:thermometer" + entity_category: config + + - platform: template + name: "Humidity Offset" + id: humidity_offset_ui + unit_of_measurement: "%" + min_value: -50 + max_value: 50 + step: 0.1 + mode: box + update_interval: never + optimistic: true + restore_value: true + initial_value: 0 + icon: "mdi:water-percent" + entity_category: config + + - platform: template + name: "Pressure Offset" + id: pressure_offset_ui + unit_of_measurement: "hPa" + min_value: -500 + max_value: 500 + step: 1 + mode: box + update_interval: never + optimistic: true + restore_value: true + initial_value: 0 + icon: "mdi:gauge" + entity_category: config + + - platform: template + name: "CO2 Offset" + id: co2_offset_ui + unit_of_measurement: "ppm" + min_value: -1000 + max_value: 1000 + step: 1 + mode: box + update_interval: never + optimistic: true + restore_value: true + initial_value: 0 + icon: "mdi:test-tube" + entity_category: config + + - platform: template + name: "VOC Offset" + id: voc_offset_ui + unit_of_measurement: "ppm" + min_value: -1000 + max_value: 1000 + step: 1 + mode: box + update_interval: never + optimistic: true + restore_value: true + initial_value: 0 + icon: "mdi:test-tube" + entity_category: config + + - platform: template + name: "IAQ Offset" + id: iaq_offset_ui + unit_of_measurement: "IAQ" + min_value: -400 + max_value: 400 + step: 1 + mode: box + update_interval: never + optimistic: true + restore_value: true + initial_value: 0 + icon: "mdi:gauge" + entity_category: config + +text_sensor: + - platform: template + name: "IAQ Classification" + icon: "mdi:checkbox-marked-circle-outline" + lambda: |- + if ( int(id(iaq).state) <= 50) { + return {"Excellent"}; + } + else if (int(id(iaq).state) >= 51 && int(id(iaq).state) <= 100) { + return {"Good"}; + } + else if (int(id(iaq).state) >= 101 && int(id(iaq).state) <= 150) { + return {"Lightly polluted"}; + } + else if (int(id(iaq).state) >= 151 && int(id(iaq).state) <= 200) { + return {"Moderately polluted"}; + } + else if (int(id(iaq).state) >= 201 && int(id(iaq).state) <= 250) { + return {"Heavily polluted"}; + } + else if (int(id(iaq).state) >= 251 && int(id(iaq).state) <= 350) { + return {"Severely polluted"}; + } + else if (int(id(iaq).state) >= 351) { + return {"Extremely polluted"}; + } + else { + return {"error"}; + } From e91856df915b5b4f9b974456238a367487e0f9a7 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 19:42:09 +0200 Subject: [PATCH 03/29] adding default temperature offset --- docs/sensors.md | 4 +++- esphome/esphome.yaml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/sensors.md b/docs/sensors.md index 04ff0a0..b6ae1c4 100644 --- a/docs/sensors.md +++ b/docs/sensors.md @@ -5,7 +5,7 @@ want but notice the compatibility.
-## 🌡️Temperature, Humidity, Pressure & Air Quality +## 🌡️Temperature, Humidity, Pressure, VOC & Air Quality For these measurements we recommend the industrial sensors BME680/BME688 or the BME280 (cheaper but without air @@ -25,6 +25,8 @@ Related to [#7](https://github.com/Schluggi/AIOsense/issues/7) sometimes SMD soldering can be inaccessible or difficult. You can use a BME PCB module instead. +The default offset is -6 °C. + ### Where to buy? | Part | Shops | diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index abc439d..fd48383 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -13,7 +13,7 @@ substitutions: # iaq_offset: "0" # bsec only # illuminance_offset: "0" # pressure_offset: "0" - # temperature_offset: "0" + temperature_offset: "-6" # voc_offset: "0" # bsec only # LD2410(c) does not work? Please notice: From dd83947c69d14db134b63228aa39d1228144976e Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:14:07 +0200 Subject: [PATCH 04/29] new docs theme --- docs/requirements.txt | 25 ++++++++++++++++++++++++- mkdocs.yml | 22 ++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 901cbfc..ed85c4c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,16 @@ +Babel==2.13.1 bracex==2.4 -click==8.1.7 +cairocffi==1.6.1 +CairoSVG==2.7.1 +certifi==2022.12.7 +cffi==1.16.0 +charset-normalizer==3.1.0 +click==8.1.3 colorama==0.4.6 +cssselect2==0.7.0 +defusedxml==0.7.1 ghp-import==2.1.0 +idna==3.4 importlib-metadata==6.8.0 Jinja2==3.1.2 Markdown==3.5 @@ -9,12 +18,26 @@ MarkupSafe==2.1.3 mergedeep==1.3.4 mkdocs==1.5.3 mkdocs-awesome-pages-plugin==2.9.2 +mkdocs-material==9.4.6 +mkdocs-material-extensions==1.3 natsort==8.4.0 packaging==23.2 +paginate==0.5.6 +pathspec==0.11.2 +Pillow==10.1.0 +platformdirs==3.11.0 +pycparser==2.21 +Pygments==2.16.1 +pymdown-extensions==10.3.1 python-dateutil==2.8.2 PyYAML==6.0.1 pyyaml_env_tag==0.1 +regex==2023.10.3 +requests==2.31.0 six==1.16.0 +tinycss2==1.2.1 +urllib3==2.0.7 watchdog==3.0.0 wcmatch==8.5 +webencodings==0.5.1 zipp==3.17.0 diff --git a/mkdocs.yml b/mkdocs.yml index 8c910b9..12e70aa 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,18 +1,32 @@ site_name: AIOsense -site_url: https://aiosense.readthedocs.io/en/latest/ +repo_name: Schluggi/AIOsense repo_url: https://github.com/Schluggi/AIOsense -edit_uri: https://github.com/Schluggi/AIOsense/edit/main/docs theme: - name: readthedocs + name: material highlightjs: true + icon: + repo: fontawesome/brands/github + palette: + - scheme: default + toggle: + icon: material/brightness-7 + name: Switch to dark mode + + - scheme: slate + toggle: + icon: material/brightness-4 + name: Switch to light mode + plugins: - - search - awesome-pages: filename: nav.yml strict: false + - search + - social + - tags markdown_extensions: - attr_list # for image scale From d5f0bfb302ef5e40e363e60d19c25ac8daa5849c Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:17:21 +0200 Subject: [PATCH 05/29] set v3 as package ref --- esphome/esphome.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index fd48383..fad60e9 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -28,7 +28,7 @@ substitutions: packages: remote_package: url: https://github.com/schluggi/AIOsense - ref: main + ref: v3 refresh: 1d files: - esphome/packages/config/base.yaml From bba3637c3cc03dff2429141212a9f730d530038a Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:35:58 +0200 Subject: [PATCH 06/29] testing --- esphome/packages/sensors/rgb_led.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 3ab8faf..ab0b233 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -42,7 +42,8 @@ light: esphome: on_boot: - then: - - light.turn_on: led - - delay: 3s - - light.turn_off: led + - priority: 0 + then: + - light.turn_on: led + - delay: 3s + - light.turn_off: led From b8956b8f9bd0e49fe3ef4941a81de1ab4d6744ec Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:40:33 +0200 Subject: [PATCH 07/29] adding on_boot priority --- esphome/packages/sensors/buzzer.yaml | 5 +++-- esphome/packages/sensors/led.yaml | 9 +++++---- esphome/packages/sensors/rgb_led.yaml | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/esphome/packages/sensors/buzzer.yaml b/esphome/packages/sensors/buzzer.yaml index 4be493e..db6eac6 100644 --- a/esphome/packages/sensors/buzzer.yaml +++ b/esphome/packages/sensors/buzzer.yaml @@ -21,5 +21,6 @@ rtttl: esphome: on_boot: - then: - - rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6" + - priority: 10 + then: + - rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6" diff --git a/esphome/packages/sensors/led.yaml b/esphome/packages/sensors/led.yaml index a9ed8fe..3860919 100644 --- a/esphome/packages/sensors/led.yaml +++ b/esphome/packages/sensors/led.yaml @@ -26,7 +26,8 @@ light: esphome: on_boot: - then: - - light.turn_on: led - - delay: 3s - - light.turn_off: led + - priority: 0 + then: + - light.turn_on: led + - delay: 2s + - light.turn_off: led diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index ab0b233..6a716a5 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -45,5 +45,5 @@ esphome: - priority: 0 then: - light.turn_on: led - - delay: 3s + - delay: 2s - light.turn_off: led From eec863c9d12de2e8be02d0f9c42e6d067908c683 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:40:43 +0200 Subject: [PATCH 08/29] adding min_version for bsec --- esphome/packages/sensors/bme68x_bsec.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome/packages/sensors/bme68x_bsec.yaml b/esphome/packages/sensors/bme68x_bsec.yaml index 0f7f263..86a138e 100644 --- a/esphome/packages/sensors/bme68x_bsec.yaml +++ b/esphome/packages/sensors/bme68x_bsec.yaml @@ -17,6 +17,9 @@ bme68x_bsec: bsec_configuration: 0,0,2,2,189,1,0,0,0,0,0,0,213,8,0,0,52,0,1,0,0,192,168,71,64,49,119,76,0,0,97,69,0,0,97,69,137,65,0,63,0,0,0,63,0,0,64,63,205,204,204,62,10,0,3,0,216,85,0,100,0,0,96,64,23,183,209,56,28,0,2,0,0,244,1,150,0,50,0,0,128,64,0,0,32,65,144,1,0,0,112,65,0,0,0,63,16,0,3,0,10,215,163,60,10,215,35,59,10,215,35,59,13,0,5,0,0,0,0,0,100,35,41,29,86,88,0,9,0,229,208,34,62,0,0,0,0,0,0,0,0,218,27,156,62,225,11,67,64,0,0,160,64,0,0,0,0,0,0,0,0,94,75,72,189,93,254,159,64,66,62,160,191,0,0,0,0,0,0,0,0,33,31,180,190,138,176,97,64,65,241,99,190,0,0,0,0,0,0,0,0,167,121,71,61,165,189,41,192,184,30,189,64,12,0,10,0,0,0,0,0,0,0,0,0,173,6,11,0,1,2,2,207,61,208,65,149,110,24,66,180,108,177,65,219,148,13,192,70,132,58,66,163,58,140,192,12,99,178,192,185,59,255,193,178,213,175,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,211,55,195,237,6,56,67,0,0,0,0,0,0,0,0,26,3,255,63,61,246,7,192,171,201,228,192,249,144,215,63,237,199,104,193,128,158,216,64,117,140,155,63,137,120,129,67,108,109,253,191,0,0,0,0,81,64,57,68,103,241,231,64,109,29,152,192,209,43,193,63,93,54,30,65,197,46,92,64,128,27,224,192,6,20,144,191,56,179,130,64,0,0,0,0,43,156,59,196,33,217,100,194,104,77,72,65,15,103,175,191,249,252,12,193,63,117,253,192,233,5,141,65,155,42,25,64,13,88,249,191,0,0,0,0,48,141,122,190,204,150,44,192,36,162,29,193,96,59,39,189,54,202,48,65,151,205,68,64,79,105,55,193,53,120,53,192,77,211,32,192,0,0,0,0,193,207,92,65,239,201,76,65,208,70,82,66,81,63,96,65,48,179,0,194,251,96,242,193,176,51,96,194,153,114,98,66,144,247,64,65,0,0,0,0,219,179,180,63,175,218,119,191,51,71,207,191,245,145,129,63,53,16,244,65,138,208,117,65,138,97,36,66,228,15,32,195,126,91,103,191,0,0,0,0,26,151,170,193,64,105,49,193,46,223,189,193,129,203,168,193,40,91,49,66,4,87,107,65,205,202,37,65,244,36,154,66,240,85,39,193,0,0,0,0,166,96,87,192,114,7,68,191,233,32,214,63,84,249,40,192,45,78,132,64,145,33,253,61,49,43,187,192,244,32,77,67,224,250,71,191,0,0,0,0,103,75,214,190,206,141,252,63,99,15,178,65,80,79,166,190,214,25,146,192,165,29,24,194,18,228,219,193,113,246,235,194,49,115,232,63,0,0,0,0,17,211,124,64,56,252,251,62,25,118,148,193,168,234,94,64,131,157,82,64,217,119,236,65,120,245,240,65,17,69,168,195,49,51,8,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,131,217,97,66,182,104,101,194,0,0,0,0,0,0,0,0,6,142,142,195,229,54,143,67,0,0,0,0,0,0,0,0,25,224,153,66,217,51,154,194,0,0,0,0,0,0,0,0,142,36,105,194,199,63,110,66,0,0,0,0,0,0,0,0,206,73,250,193,138,69,249,65,0,0,0,0,0,0,0,0,123,173,127,66,20,116,128,194,0,0,0,0,0,0,0,0,49,65,49,64,205,213,107,192,0,0,0,0,0,0,0,0,189,250,179,194,164,98,180,66,0,0,0,0,0,0,0,0,96,182,197,67,155,71,197,195,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,28,179,73,64,25,141,76,223,26,138,76,222,207,133,76,87,134,164,75,23,127,159,75,166,9,155,75,94,120,170,73,95,221,177,73,93,44,182,73,0,0,0,0,0,0,0,0,0,0,0,0,30,55,120,73,215,98,32,76,7,79,34,76,161,238,36,76,119,151,160,75,119,96,157,75,202,75,154,75,118,89,111,73,133,239,116,73,219,140,120,73,0,0,128,63,0,0,128,63,0,0,128,63,0,0,0,87,1,254,0,2,1,5,48,117,100,0,44,1,112,23,151,7,132,3,197,0,92,4,144,1,64,1,64,1,144,1,48,117,48,117,48,117,48,117,100,0,100,0,100,0,48,117,48,117,48,117,100,0,100,0,48,117,48,117,8,7,8,7,8,7,8,7,8,7,100,0,100,0,100,0,100,0,48,117,48,117,48,117,100,0,100,0,100,0,48,117,48,117,100,0,100,0,255,255,255,255,255,255,255,255,255,255,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,255,255,255,255,255,255,255,255,255,255,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,8,7,255,255,255,255,255,255,255,255,255,255,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,112,23,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,220,5,220,5,220,5,255,255,255,255,255,255,220,5,220,5,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,48,117,0,5,10,5,0,2,0,10,0,30,0,5,0,5,0,5,0,5,0,5,0,5,0,64,1,100,0,100,0,100,0,200,0,200,0,200,0,64,1,64,1,64,1,10,0,0,0,0,145,33,0,0 state_save_interval: 30min +esphome: + min_version: 2023.10.0 + sensor: - platform: bme68x_bsec temperature: From f0105fa53d5d24fe530af9b94764b385cfa924b0 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:42:40 +0200 Subject: [PATCH 09/29] fixing comments --- esphome/esphome.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index fad60e9..276c94a 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -41,15 +41,15 @@ packages: # --- select your sensors --- - esphome/packages/sensors/bh1750.yaml - # - esphome/packages/sensors/buzzer.yaml # AIOsense >= 2.1.x only - # - esphome/packages/sensors/voice_assistant.yaml # ESP32-C3 only (for now) + # - esphome/packages/sensors/buzzer.yaml # AIOsense PCB >= 2.1.x only + # - esphome/packages/sensors/voice_assistant.yaml # c3-mini only (for now) # - esphome/packages/sensors/bme280.yaml # enable for bme280 # - esphome/packages/sensors/bme680.yaml # disable for bme280 - esphome/packages/sensors/bme68x_bsec.yaml - esphome/packages/sensors/occupancy.yaml # only if pir & mmWave are on - esphome/packages/sensors/pir.yaml - - esphome/packages/sensors/rgb_led.yaml # esp32-c3-mini only - # - esphome/packages/sensors/led.yaml # d1-mini only + - esphome/packages/sensors/rgb_led.yaml # for c3-mini & s3-mini + # - esphome/packages/sensors/led.yaml # for d1-mini & s2-mini # --- select your radar sensor --- # - esphome/packages/sensors/ld2410.yaml From d8edd60870156472bd1a23513221185c327141b5 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:44:53 +0200 Subject: [PATCH 10/29] set version to 3.0.0 --- esphome/esphome.yaml | 1 - esphome/packages/config/base.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index 276c94a..e59405f 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -1,7 +1,6 @@ substitutions: name: "aiosense-bedroom" # lowercase only, have to be unique friendly_name: "AIOsense Bedroom" # device name and entity prefix - version: "2.1.0" # your AIOsense version # bh1750_update_interval: 5s diff --git a/esphome/packages/config/base.yaml b/esphome/packages/config/base.yaml index 776d9f5..ee36fd5 100644 --- a/esphome/packages/config/base.yaml +++ b/esphome/packages/config/base.yaml @@ -1,5 +1,5 @@ substitutions: - version: "2.0.0" + version: "3.0.0" esphome: name: "${name}" From 6eca1beec4832632788db52b2d846dbca674eee8 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:47:56 +0200 Subject: [PATCH 11/29] add pulse effect for booting --- esphome/packages/sensors/led.yaml | 5 ++++- esphome/packages/sensors/rgb_led.yaml | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/esphome/packages/sensors/led.yaml b/esphome/packages/sensors/led.yaml index 3860919..140d7ad 100644 --- a/esphome/packages/sensors/led.yaml +++ b/esphome/packages/sensors/led.yaml @@ -17,6 +17,7 @@ light: output: led_output icon: "mdi:led-outline" effects: + - pulse: - strobe: colors: - state: true @@ -28,6 +29,8 @@ esphome: on_boot: - priority: 0 then: - - light.turn_on: led + - light.turn_on: + id: led + effect: pulse - delay: 2s - light.turn_off: led diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 6a716a5..0281398 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -44,6 +44,8 @@ esphome: on_boot: - priority: 0 then: - - light.turn_on: led + - light.turn_on: + id: led + effect: pulse - delay: 2s - light.turn_off: led From 5df7698f0857e3c81d04b37a17f31298d69989ca Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 20:58:56 +0200 Subject: [PATCH 12/29] add substitutions for voice assistant --- esphome/packages/config/esp32-c3-mini.yaml | 9 ++++++--- esphome/packages/config/esp32-d1-mini.yaml | 5 ++++- esphome/packages/config/esp32-s2-mini.yaml | 3 +++ esphome/packages/sensors/voice_assistant.yaml | 8 +++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/esphome/packages/config/esp32-c3-mini.yaml b/esphome/packages/config/esp32-c3-mini.yaml index a937a51..8a13ed9 100644 --- a/esphome/packages/config/esp32-c3-mini.yaml +++ b/esphome/packages/config/esp32-c3-mini.yaml @@ -1,8 +1,11 @@ substitutions: - buzzer_pin: GPIO0 - pir_pin: GPIO4 + buzzer_pin: A0 + i2s_bclk_pin: A1 + i2s_din_pin: "${buzzer_pin}" + i2s_lrclk_pin: A5 + pir_pin: A4 rgb_led_pin: GPIO7 - sen0395_io_pin: GPIO2 + sen0395_io_pin: A2 uart_rx_pin: GPIO20 uart_tx_pin: GPIO21 diff --git a/esphome/packages/config/esp32-d1-mini.yaml b/esphome/packages/config/esp32-d1-mini.yaml index 87c5701..e9e887d 100644 --- a/esphome/packages/config/esp32-d1-mini.yaml +++ b/esphome/packages/config/esp32-d1-mini.yaml @@ -1,5 +1,8 @@ substitutions: - buzzer_pin: GPIO19 # untested + buzzer_pin: GPIO19 + i2s_bclk_pin: GPIO14 + i2s_din_pin: "${buzzer_pin}" + i2s_lrclk_pin: GPIO15 led_pin: GPIO2 pir_pin: GPIO23 sen0395_io_pin: GPIO26 diff --git a/esphome/packages/config/esp32-s2-mini.yaml b/esphome/packages/config/esp32-s2-mini.yaml index 5b46340..076c026 100644 --- a/esphome/packages/config/esp32-s2-mini.yaml +++ b/esphome/packages/config/esp32-s2-mini.yaml @@ -1,5 +1,8 @@ substitutions: buzzer_pin: GPIO9 + i2s_bclk_pin: GPIO7 + i2s_din_pin: "${buzzer_pin}" + i2s_lrclk_pin: GPIO12 led_invert: "true" led_pin: GPIO15 pir_pin: GPIO11 diff --git a/esphome/packages/sensors/voice_assistant.yaml b/esphome/packages/sensors/voice_assistant.yaml index b6d02e3..aa26c73 100644 --- a/esphome/packages/sensors/voice_assistant.yaml +++ b/esphome/packages/sensors/voice_assistant.yaml @@ -1,16 +1,14 @@ -# WIP, C3-mini only (for now) - i2s_audio: id: i2s_in - i2s_lrclk_pin: A5 # WS - i2s_bclk_pin: A1 # SCK + i2s_lrclk_pin: "${i2s_lrclk_pin}" # WS + i2s_bclk_pin: "${i2s_bclk_pin}" # SCK microphone: - platform: i2s_audio id: mic_i2s channel: left adc_type: external - i2s_din_pin: A0 # SD + i2s_din_pin: "${i2s_din_pin}" # SD i2s_audio_id: i2s_in pdm: false From ca2657c1370fb031b6cc64fef182da72558b5212 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Tue, 24 Oct 2023 21:13:23 +0200 Subject: [PATCH 13/29] rename comments --- esphome/esphome.yaml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index e59405f..6355cf2 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -32,25 +32,31 @@ packages: files: - esphome/packages/config/base.yaml - # --- select your board --- + # ----- select your board ----- - esphome/packages/config/esp32-c3-mini.yaml # - esphome/packages/config/esp32-d1-mini.yaml # - esphome/packages/config/esp32-s2-mini.yaml # - esphome/packages/config/esp8266-d1-mini.yaml - # --- select your sensors --- + # ----- select your modules (general) ----- - esphome/packages/sensors/bh1750.yaml - # - esphome/packages/sensors/buzzer.yaml # AIOsense PCB >= 2.1.x only - # - esphome/packages/sensors/voice_assistant.yaml # c3-mini only (for now) # - esphome/packages/sensors/bme280.yaml # enable for bme280 # - esphome/packages/sensors/bme680.yaml # disable for bme280 - esphome/packages/sensors/bme68x_bsec.yaml - - esphome/packages/sensors/occupancy.yaml # only if pir & mmWave are on + - esphome/packages/sensors/buzzer.yaml # AIOsense PCB >= 2.1.x only + - esphome/packages/sensors/occupancy.yaml # only if pir & mmWave are activated - esphome/packages/sensors/pir.yaml - - esphome/packages/sensors/rgb_led.yaml # for c3-mini & s3-mini - # - esphome/packages/sensors/led.yaml # for d1-mini & s2-mini + - esphome/packages/sensors/voice_assistant.yaml # esp32 (all versions) only - # --- select your radar sensor --- + # ----- rgb led modules (esp32-c3 & esp32-s3 only) ----- + - esphome/packages/sensors/rgb_led.yaml + # - esphome/packages/sensors/voice_assistant_rgb_led.yaml + + # ----- single color led modules (esp32-d1 & esp32-s2 only) ----- + # - esphome/packages/sensors/led.yaml + # - esphome/packages/sensors/voice_assistant_led.yaml # esp32-s2 only + + # ----- select your radar sensor ----- # - esphome/packages/sensors/ld2410.yaml - esphome/packages/sensors/sen0395.yaml From 47438b4096dc5479f9db0239313ffd5581a8e370 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Mon, 6 Nov 2023 22:27:48 +0100 Subject: [PATCH 14/29] Revert "add pulse effect for booting" This reverts commit 6eca1beec4832632788db52b2d846dbca674eee8. --- esphome/packages/sensors/led.yaml | 5 +---- esphome/packages/sensors/rgb_led.yaml | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/esphome/packages/sensors/led.yaml b/esphome/packages/sensors/led.yaml index 140d7ad..3860919 100644 --- a/esphome/packages/sensors/led.yaml +++ b/esphome/packages/sensors/led.yaml @@ -17,7 +17,6 @@ light: output: led_output icon: "mdi:led-outline" effects: - - pulse: - strobe: colors: - state: true @@ -29,8 +28,6 @@ esphome: on_boot: - priority: 0 then: - - light.turn_on: - id: led - effect: pulse + - light.turn_on: led - delay: 2s - light.turn_off: led diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 0281398..6a716a5 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -44,8 +44,6 @@ esphome: on_boot: - priority: 0 then: - - light.turn_on: - id: led - effect: pulse + - light.turn_on: led - delay: 2s - light.turn_off: led From b443748ad5e638351df3b7efed2afd1b9bc37ec5 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 21:15:00 +0100 Subject: [PATCH 15/29] add basic support for S3 mini --- esphome/packages/config/esp32-s3-mini.yaml | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 esphome/packages/config/esp32-s3-mini.yaml diff --git a/esphome/packages/config/esp32-s3-mini.yaml b/esphome/packages/config/esp32-s3-mini.yaml new file mode 100644 index 0000000..95f11d0 --- /dev/null +++ b/esphome/packages/config/esp32-s3-mini.yaml @@ -0,0 +1,24 @@ +substitutions: + buzzer_pin: GPIO13 + i2s_bclk_pin: GPIO12 + i2s_din_pin: "${buzzer_pin}" + i2s_lrclk_pin: GPIO10 + pir_pin: GPIO11 + rgb_led_pin: GPIO47 + sen0395_io_pin: GPIO4 + uart_rx_pin: GPIO44 + uart_tx_pin: GPIO43 + +esp32: + board: esp32-s3-devkitc-1 + variant: esp32s3 + framework: + type: arduino + +i2c: + sda: GPIO35 + scl: GPIO36 + +sensor: + - platform: internal_temperature + name: "CPU Temperature" From 78f14de6a1b9de7482d792632f0ad5fd3f4640e8 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 21:18:36 +0100 Subject: [PATCH 16/29] fixing defaults --- esphome/esphome.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index 6355cf2..7778302 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -33,9 +33,10 @@ packages: - esphome/packages/config/base.yaml # ----- select your board ----- - - esphome/packages/config/esp32-c3-mini.yaml + # - esphome/packages/config/esp32-c3-mini.yaml # - esphome/packages/config/esp32-d1-mini.yaml # - esphome/packages/config/esp32-s2-mini.yaml + - esphome/packages/config/esp32-s3-mini.yaml # - esphome/packages/config/esp8266-d1-mini.yaml # ----- select your modules (general) ----- From 6015fb8ed5cdf19f150104abd4c19419357490f6 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 21:46:05 +0100 Subject: [PATCH 17/29] bump s3 framework version --- esphome/packages/config/esp32-s3-mini.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/packages/config/esp32-s3-mini.yaml b/esphome/packages/config/esp32-s3-mini.yaml index 95f11d0..f9f50e7 100644 --- a/esphome/packages/config/esp32-s3-mini.yaml +++ b/esphome/packages/config/esp32-s3-mini.yaml @@ -14,6 +14,7 @@ esp32: variant: esp32s3 framework: type: arduino + version: latest i2c: sda: GPIO35 From 72db02976d2a4fdd87b9cf91df491d603279c831 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 21:47:57 +0100 Subject: [PATCH 18/29] fixing S3 led colors --- esphome/packages/config/esp32-s3-mini.yaml | 1 + esphome/packages/sensors/rgb_led.yaml | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/packages/config/esp32-s3-mini.yaml b/esphome/packages/config/esp32-s3-mini.yaml index f9f50e7..9f65767 100644 --- a/esphome/packages/config/esp32-s3-mini.yaml +++ b/esphome/packages/config/esp32-s3-mini.yaml @@ -5,6 +5,7 @@ substitutions: i2s_lrclk_pin: GPIO10 pir_pin: GPIO11 rgb_led_pin: GPIO47 + rgb_led_type: RGB sen0395_io_pin: GPIO4 uart_rx_pin: GPIO44 uart_tx_pin: GPIO43 diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 6a716a5..18c2af4 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -2,12 +2,13 @@ substitutions: led_strobe_on: 50ms led_strobe_off: 100ms + rgb_led_type: GRB light: - platform: neopixelbus - name: "LED" + name: "${rgb_led_type}" id: led - type: GRB + type: type variant: WS2812X num_leds: 1 pin: "${rgb_led_pin}" From d3e6ec62a72706f825ae70c4f17ce46f56816e47 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 21:49:25 +0100 Subject: [PATCH 19/29] fixing S3 led type --- esphome/packages/sensors/rgb_led.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 18c2af4..5fcd1eb 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -6,9 +6,9 @@ substitutions: light: - platform: neopixelbus - name: "${rgb_led_type}" + name: "LED" id: led - type: type + type: "${rgb_led_type}" variant: WS2812X num_leds: 1 pin: "${rgb_led_pin}" From 64da6989d28cd0bfd2219d724031e4ce728d0421 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 21:56:43 +0100 Subject: [PATCH 20/29] led debugging --- esphome/packages/sensors/rgb_led.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 5fcd1eb..fbd2f03 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -2,7 +2,7 @@ substitutions: led_strobe_on: 50ms led_strobe_off: 100ms - rgb_led_type: GRB + rgb_led_type: RGB #GRB light: - platform: neopixelbus From cfb71448aa1ac8c628535691e4098047e351c85d Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 22:05:38 +0100 Subject: [PATCH 21/29] led debugging --- esphome/packages/sensors/rgb_led.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index fbd2f03..5fcd1eb 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -2,7 +2,7 @@ substitutions: led_strobe_on: 50ms led_strobe_off: 100ms - rgb_led_type: RGB #GRB + rgb_led_type: GRB light: - platform: neopixelbus From e5a626081d709eb996ae1e00d7ce803507b7ba98 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 22:08:43 +0100 Subject: [PATCH 22/29] led debugging --- esphome/packages/config/esp32-c3-mini.yaml | 1 + esphome/packages/sensors/rgb_led.yaml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/packages/config/esp32-c3-mini.yaml b/esphome/packages/config/esp32-c3-mini.yaml index 8a13ed9..a6922f0 100644 --- a/esphome/packages/config/esp32-c3-mini.yaml +++ b/esphome/packages/config/esp32-c3-mini.yaml @@ -5,6 +5,7 @@ substitutions: i2s_lrclk_pin: A5 pir_pin: A4 rgb_led_pin: GPIO7 + rgb_led_type: GRB sen0395_io_pin: A2 uart_rx_pin: GPIO20 uart_tx_pin: GPIO21 diff --git a/esphome/packages/sensors/rgb_led.yaml b/esphome/packages/sensors/rgb_led.yaml index 5fcd1eb..869447d 100644 --- a/esphome/packages/sensors/rgb_led.yaml +++ b/esphome/packages/sensors/rgb_led.yaml @@ -2,7 +2,6 @@ substitutions: led_strobe_on: 50ms led_strobe_off: 100ms - rgb_led_type: GRB light: - platform: neopixelbus From b44154efe35cdb5f057c7a65795bf1a6cb9135ce Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Wed, 15 Nov 2023 23:46:06 +0100 Subject: [PATCH 23/29] replacing the sen0395 component the new official one (closes #125) --- esphome/packages/sensors/sen0395.yaml | 152 ++++++++++++-------------- 1 file changed, 67 insertions(+), 85 deletions(-) diff --git a/esphome/packages/sensors/sen0395.yaml b/esphome/packages/sensors/sen0395.yaml index 40a9911..080002c 100644 --- a/esphome/packages/sensors/sen0395.yaml +++ b/esphome/packages/sensors/sen0395.yaml @@ -4,6 +4,9 @@ uart: rx_pin: "${uart_rx_pin}" baud_rate: 115200 +dfrobot_sen0395: + uart_id: uart_bus + binary_sensor: - platform: gpio name: "mmWave" @@ -14,119 +17,98 @@ binary_sensor: mode: INPUT_PULLDOWN switch: - - platform: template + - platform: dfrobot_sen0395 name: "mmWave Sensor" - id: "mmwave_sensor" - entity_category: config - optimistic: true - restore_mode: RESTORE_DEFAULT_ON - assumed_state: true - turn_on_action: - - uart.write: "sensorStart" - - delay: 1s - turn_off_action: - - uart.write: "sensorStop" - - delay: 1s + type: sensor_active - - platform: template + - platform: dfrobot_sen0395 + name: "mmWave Presence Via Uart" + type: presence_via_uart + disabled_by_default: true + + - platform: dfrobot_sen0395 + name: "mmWave Autostart" + type: start_after_boot + disabled_by_default: true + + - platform: dfrobot_sen0395 name: "mmWave LED" - id: "mmwave_led" - entity_category: config - optimistic: true - restore_mode: RESTORE_DEFAULT_OFF - assumed_state: true - turn_on_action: - - switch.turn_off: mmwave_sensor - - delay: 1s - - uart.write: "setLedMode 1 0" - - delay: 1s - - uart.write: "saveConfig" - - delay: 3s - - switch.turn_on: mmwave_sensor - turn_off_action: - - switch.turn_off: mmwave_sensor - - delay: 1s - - uart.write: "setLedMode 1 1" - - delay: 1s - - uart.write: "saveConfig" - - delay: 3s - - switch.turn_on: mmwave_sensor + type: turn_on_led number: - platform: template - name: "mmWave Distance" - id: mmwave_distance + name: "mmWave Sensitivity" + id: mmwave_sensitivity entity_category: config min_value: 0 - max_value: 800 - initial_value: 315 + max_value: 9 + initial_value: 7 optimistic: true - step: 50 + step: 1 restore_value: true - unit_of_measurement: cm - mode: slider - set_action: - - switch.turn_off: mmwave_sensor - - delay: 1s - - uart.write: !lambda int cm = (int)ceil(x / 15.0); - std::string cms = "detRangeCfg -1 0 " + to_string(cm); - return std::vector(cms.begin(), cms.end()); - - delay: 1s - - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89" - - delay: 1s - - switch.turn_on: mmwave_sensor - platform: template name: "mmWave Off Latency" - id: mmwave_latency + id: mmwave_off_latency entity_category: config min_value: 0 - max_value: 65000 - initial_value: 12500 + max_value: 60 + initial_value: 10 optimistic: true - step: 25 + step: 0.025 restore_value: true - unit_of_measurement: ms + unit_of_measurement: s mode: box - set_action: - - switch.turn_off: mmwave_sensor - - delay: 1s - - uart.write: !lambda int ms = (int)ceil(x / 25.0); - std::string mss = "outputLatency -1 0 " + to_string(ms); - return std::vector(mss.begin(), mss.end()); - - delay: 1s - - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89" - - delay: 1s - - switch.turn_on: mmwave_sensor - platform: template - name: "mmWave Sensitivity" - id: mmwave_sensitivity + name: "mmWave On Latency" + id: mmwave_on_latency + entity_category: config + min_value: 0 + max_value: 60 + initial_value: 2.5 + optimistic: true + step: 0.025 + restore_value: true + unit_of_measurement: s + mode: box + + - platform: template + name: "mmWave Distance" + id: mmwave_distance entity_category: config min_value: 0 max_value: 9 - initial_value: 7 + initial_value: 3 optimistic: true - step: 1 + step: 0.15 restore_value: true - set_action: - - switch.turn_off: mmwave_sensor - - delay: 1s - - uart.write: - !lambda std::string mss = "setSensitivity " + to_string((int)x); - return std::vector(mss.begin(), mss.end()); - - delay: 1s - - uart.write: "saveConfig" - - delay: 1s - - switch.turn_on: mmwave_sensor + unit_of_measurement: m + mode: box button: - platform: template name: "mmWave Factory Reset" + entity_category: diagnostic + on_press: + - dfrobot_sen0395.settings: + factory_reset: true + + - platform: template + name: "mmWave Restart" + entity_category: diagnostic + on_press: + - dfrobot_sen0395.reset + + - platform: template + name: "mmWave Apply Settings" entity_category: config on_press: - - switch.turn_off: mmwave_sensor - - delay: 1s - - uart.write: "resetCfg" - - delay: 3s - - switch.turn_on: mmwave_sensor + - dfrobot_sen0395.settings: + sensitivity: !lambda return id(mmwave_sensitivity).state; + detection_segments: + - !lambda return 0; + - !lambda return id(mmwave_distance).state; + output_latency: + delay_after_detect: !lambda return id(mmwave_on_latency).state; + delay_after_disappear: !lambda return id(mmwave_off_latency).state; From 4d426dfec0ca33044cc40167a4dfdf867a53b83d Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Sat, 18 Nov 2023 13:23:08 +0100 Subject: [PATCH 24/29] adding distance segment zones (closes #107) --- esphome/packages/sensors/sen0395.yaml | 117 ++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 6 deletions(-) diff --git a/esphome/packages/sensors/sen0395.yaml b/esphome/packages/sensors/sen0395.yaml index 080002c..9084565 100644 --- a/esphome/packages/sensors/sen0395.yaml +++ b/esphome/packages/sensors/sen0395.yaml @@ -74,8 +74,20 @@ number: mode: box - platform: template - name: "mmWave Distance" - id: mmwave_distance + name: "mmWave Segment 1 Begin" + id: mmwave_segment_1_begin + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segment 1 End" + id: mmwave_segment_1_end entity_category: config min_value: 0 max_value: 9 @@ -83,8 +95,92 @@ number: optimistic: true step: 0.15 restore_value: true - unit_of_measurement: m - mode: box + mode: BOX + + + - platform: template + name: "mmWave Segment 2 Begin" + id: mmwave_segment_2_begin + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segment 2 End" + id: mmwave_segment_2_end + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segment 3 Begin" + id: mmwave_segment_3_begin + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segment 3 End" + id: mmwave_segment_3_end + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segment 4 Begin" + id: mmwave_segment_4_begin + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segment 4 End" + id: mmwave_segment_4_end + entity_category: config + min_value: 0 + max_value: 9 + initial_value: 0 + optimistic: true + step: 0.15 + restore_value: true + mode: BOX + + - platform: template + name: "mmWave Segments" + id: mmwave_segments + entity_category: config + min_value: 1 + max_value: 4 + initial_value: 1 + optimistic: true + step: 1 + restore_value: true + mode: SLIDER button: - platform: template @@ -107,8 +203,17 @@ button: - dfrobot_sen0395.settings: sensitivity: !lambda return id(mmwave_sensitivity).state; detection_segments: - - !lambda return 0; - - !lambda return id(mmwave_distance).state; + - !lambda return id(mmwave_segment_1_begin).state; + - !lambda return id(mmwave_segment_1_end).state; + + - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_2_begin).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_2_end).state; } else { return -1; }; + + - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_3_begin).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_3_end).state; } else { return -1; }; + + - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_4_begin).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_4_end).state; } else { return -1; }; output_latency: delay_after_detect: !lambda return id(mmwave_on_latency).state; delay_after_disappear: !lambda return id(mmwave_off_latency).state; From 161ee68bb827f55a413e37bd02192dac9e465b1d Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Sat, 18 Nov 2023 13:25:35 +0100 Subject: [PATCH 25/29] adding unit_of_measurement --- esphome/packages/sensors/sen0395.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/esphome/packages/sensors/sen0395.yaml b/esphome/packages/sensors/sen0395.yaml index 9084565..6a57dc0 100644 --- a/esphome/packages/sensors/sen0395.yaml +++ b/esphome/packages/sensors/sen0395.yaml @@ -83,6 +83,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template @@ -95,9 +96,9 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - - platform: template name: "mmWave Segment 2 Begin" id: mmwave_segment_2_begin @@ -108,6 +109,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template @@ -120,6 +122,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template @@ -132,6 +135,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template @@ -144,6 +148,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template @@ -156,6 +161,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template @@ -168,6 +174,7 @@ number: optimistic: true step: 0.15 restore_value: true + unit_of_measurement: m mode: BOX - platform: template From e821a72fa91d814e94a6acfdf22b5eb4f3894ee6 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Sat, 18 Nov 2023 13:38:27 +0100 Subject: [PATCH 26/29] fixing mmwave_segments --- esphome/packages/sensors/sen0395.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/packages/sensors/sen0395.yaml b/esphome/packages/sensors/sen0395.yaml index 6a57dc0..43c2fcf 100644 --- a/esphome/packages/sensors/sen0395.yaml +++ b/esphome/packages/sensors/sen0395.yaml @@ -216,11 +216,11 @@ button: - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_2_begin).state; } else { return -1; }; - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_2_end).state; } else { return -1; }; - - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_3_begin).state; } else { return -1; }; - - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_3_end).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 3){ return id(mmwave_segment_3_begin).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 3){ return id(mmwave_segment_3_end).state; } else { return -1; }; - - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_4_begin).state; } else { return -1; }; - - !lambda if(id(mmwave_segments).state >= 2){ return id(mmwave_segment_4_end).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 4){ return id(mmwave_segment_4_begin).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state >= 4){ return id(mmwave_segment_4_end).state; } else { return -1; }; output_latency: delay_after_detect: !lambda return id(mmwave_on_latency).state; delay_after_disappear: !lambda return id(mmwave_off_latency).state; From 30141eaecfa4d2ea162c7b7f5598246f189bb503 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Sat, 18 Nov 2023 13:38:52 +0100 Subject: [PATCH 27/29] improve mmwave_segments --- esphome/packages/sensors/sen0395.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/packages/sensors/sen0395.yaml b/esphome/packages/sensors/sen0395.yaml index 43c2fcf..b58b0f3 100644 --- a/esphome/packages/sensors/sen0395.yaml +++ b/esphome/packages/sensors/sen0395.yaml @@ -219,8 +219,8 @@ button: - !lambda if(id(mmwave_segments).state >= 3){ return id(mmwave_segment_3_begin).state; } else { return -1; }; - !lambda if(id(mmwave_segments).state >= 3){ return id(mmwave_segment_3_end).state; } else { return -1; }; - - !lambda if(id(mmwave_segments).state >= 4){ return id(mmwave_segment_4_begin).state; } else { return -1; }; - - !lambda if(id(mmwave_segments).state >= 4){ return id(mmwave_segment_4_end).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state == 4){ return id(mmwave_segment_4_begin).state; } else { return -1; }; + - !lambda if(id(mmwave_segments).state == 4){ return id(mmwave_segment_4_end).state; } else { return -1; }; output_latency: delay_after_detect: !lambda return id(mmwave_on_latency).state; delay_after_disappear: !lambda return id(mmwave_off_latency).state; From 7d10f51bd5cbeae89c9a771871e698bb98419cb1 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Mon, 27 Nov 2023 21:12:35 +0100 Subject: [PATCH 28/29] bump remote_package version --- esphome/esphome.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index 7778302..c2ef640 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -27,7 +27,7 @@ substitutions: packages: remote_package: url: https://github.com/schluggi/AIOsense - ref: v3 + ref: esphome-v3.0.0 refresh: 1d files: - esphome/packages/config/base.yaml From 6ef79d3da4527ff6034c431b838978d8619c4170 Mon Sep 17 00:00:00 2001 From: Lukas Schulte Date: Mon, 27 Nov 2023 21:43:18 +0100 Subject: [PATCH 29/29] add support for voice assistant with single color leds --- esphome/esphome.yaml | 22 ++-- .../packages/sensors/voice_assistant-led.yaml | 101 ++++++++++++++++++ ...tant.yaml => voice_assistant-rgb_led.yaml} | 0 3 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 esphome/packages/sensors/voice_assistant-led.yaml rename esphome/packages/sensors/{voice_assistant.yaml => voice_assistant-rgb_led.yaml} (100%) diff --git a/esphome/esphome.yaml b/esphome/esphome.yaml index c2ef640..4382ca3 100644 --- a/esphome/esphome.yaml +++ b/esphome/esphome.yaml @@ -32,32 +32,30 @@ packages: files: - esphome/packages/config/base.yaml - # ----- select your board ----- + # ----- board ----- # - esphome/packages/config/esp32-c3-mini.yaml # - esphome/packages/config/esp32-d1-mini.yaml # - esphome/packages/config/esp32-s2-mini.yaml - esphome/packages/config/esp32-s3-mini.yaml # - esphome/packages/config/esp8266-d1-mini.yaml - # ----- select your modules (general) ----- + # ----- modules ----- - esphome/packages/sensors/bh1750.yaml # - esphome/packages/sensors/bme280.yaml # enable for bme280 - # - esphome/packages/sensors/bme680.yaml # disable for bme280 - - esphome/packages/sensors/bme68x_bsec.yaml - - esphome/packages/sensors/buzzer.yaml # AIOsense PCB >= 2.1.x only + - esphome/packages/sensors/bme68x_bsec.yaml # disable for bme280 + - esphome/packages/sensors/buzzer.yaml # PCB >= v2.1.0 - esphome/packages/sensors/occupancy.yaml # only if pir & mmWave are activated - esphome/packages/sensors/pir.yaml - - esphome/packages/sensors/voice_assistant.yaml # esp32 (all versions) only + + # ----- voice assistant (use rgb_led for esp32-c3 & esp32-s3 only----- + # - esphome/packages/sensors/voice_assistant-rgb_led.yaml + - esphome/packages/sensors/voice_assistant-led.yaml - # ----- rgb led modules (esp32-c3 & esp32-s3 only) ----- + # ----- led modules (use rgb_led for esp32-c3 & esp32-s3 only) ----- - esphome/packages/sensors/rgb_led.yaml - # - esphome/packages/sensors/voice_assistant_rgb_led.yaml - - # ----- single color led modules (esp32-d1 & esp32-s2 only) ----- # - esphome/packages/sensors/led.yaml - # - esphome/packages/sensors/voice_assistant_led.yaml # esp32-s2 only - # ----- select your radar sensor ----- + # ----- mmWave radar sensor ----- # - esphome/packages/sensors/ld2410.yaml - esphome/packages/sensors/sen0395.yaml diff --git a/esphome/packages/sensors/voice_assistant-led.yaml b/esphome/packages/sensors/voice_assistant-led.yaml new file mode 100644 index 0000000..16c07cc --- /dev/null +++ b/esphome/packages/sensors/voice_assistant-led.yaml @@ -0,0 +1,101 @@ +i2s_audio: + id: i2s_in + i2s_lrclk_pin: "${i2s_lrclk_pin}" # WS + i2s_bclk_pin: "${i2s_bclk_pin}" # SCK + +microphone: + - platform: i2s_audio + id: mic_i2s + channel: left + adc_type: external + i2s_din_pin: "${i2s_din_pin}" # SD + i2s_audio_id: i2s_in + pdm: false + +voice_assistant: + id: va + microphone: mic_i2s + noise_suppression_level: 2 + auto_gain: 31dBFS + volume_multiplier: 2.0 + on_listening: + - light.turn_on: + id: led + effect: strobe + on_tts_start: + - light.turn_on: + id: led + effect: strobe + on_end: + - delay: 100ms + - script.execute: reset_led + on_error: + - light.turn_on: + id: led + effect: none + - delay: 1s + - script.execute: reset_led + - script.wait: reset_led + - lambda: |- + if (code == "wake-provider-missing" || code == "wake-engine-missing") { + id(use_wake_word).turn_off(); + } + +script: + - id: reset_led + then: + - if: + condition: + - switch.is_on: use_wake_word + - switch.is_on: listen_light + then: + - light.turn_on: + id: led + effect: none + else: + - light.turn_off: led + +switch: + - platform: template + name: "VA Use Wake Word" + id: use_wake_word + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - lambda: id(va).set_use_wake_word(true); + - if: + condition: + not: + - voice_assistant.is_running + then: + - voice_assistant.start_continuous + - script.execute: reset_led + on_turn_off: + - voice_assistant.stop + - lambda: id(va).set_use_wake_word(false); + - script.execute: reset_led + + - platform: template + name: "VA Listen Light" + id: listen_light + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + entity_category: config + on_turn_on: + - script.execute: reset_led + on_turn_off: + - script.execute: reset_led + +esphome: + min_version: 2023.10.0 + on_boot: + - priority: -100 + then: + - wait_until: api.connected + - delay: 1s + - if: + condition: + switch.is_on: use_wake_word + then: + - voice_assistant.start_continuous: diff --git a/esphome/packages/sensors/voice_assistant.yaml b/esphome/packages/sensors/voice_assistant-rgb_led.yaml similarity index 100% rename from esphome/packages/sensors/voice_assistant.yaml rename to esphome/packages/sensors/voice_assistant-rgb_led.yaml