Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional 2nd package to add radar and battery sensors to esp32-s3-box-3.yaml #165

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1c61b6a
Create esp32-s3-box-3-sensor.yaml
jaymunro Feb 22, 2024
c68d601
Rename esp32-s3-box-3-sensor.yaml to esp32-s3-box-3-sensor.yaml
jaymunro Feb 22, 2024
28d9b98
Update esp32-s3-box-3-sensor.yaml
jaymunro Feb 22, 2024
cd79eb3
Create esp32s3box3sensor.yaml
jaymunro Feb 23, 2024
a73164e
Merge branch 'esphome:main' into sensor_dock
jaymunro Feb 24, 2024
095cffa
Update esp32-s3-box-3-sensor.yaml
jaymunro Feb 24, 2024
3fb8013
Update esp32-s3-box-3-sensor.yaml
jaymunro Feb 24, 2024
a164972
Rename esp32s3box3sensor.yaml to box3-sensor-generic.yaml
jaymunro Feb 25, 2024
59643bd
Rename esp32-s3-box-3-sensor.yaml to box-3-sensor-for-voice-assistant…
jaymunro Feb 25, 2024
d68bda5
Rename box-3-sensor-for-voice-assistant.yaml to box3-sensor-for-voice…
jaymunro Feb 25, 2024
50e7f5b
Update box3-sensor-for-voice-assistant.yaml
jaymunro Feb 25, 2024
b94a694
Rename folder to be more generic
jaymunro Feb 25, 2024
580963d
Update docs to new path
jaymunro Feb 25, 2024
340b47b
Update box3-sensor-for-voice-assistant.yaml
jaymunro Feb 25, 2024
5108662
Update box3-sensor-generic.yaml
jaymunro Feb 25, 2024
e396fae
Update box3-sensor-for-voice-assistant.yaml
jaymunro Feb 25, 2024
eafee3e
Update box3-sensor-generic.yaml
jaymunro Feb 25, 2024
186ad8a
Update box3-sensor-generic.yaml
jaymunro Feb 26, 2024
e003d6e
Merge branch 'esphome:main' into sensor_dock
jaymunro Feb 29, 2024
2e6e757
Update box3-sensor-for-voice-assistant.yaml
jaymunro Apr 1, 2024
f496121
Merge branch 'esphome:main' into sensor_dock
jaymunro Apr 12, 2024
dbcbcd7
Merge branch 'main' into sensor_dock
jaymunro Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions esp32-box-docks/box3-sensor-for-voice-assistant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This firmware is soley for the Espressif ESP32-S3-Box-3 with the Sensor dock.
# It sets up sensors and configuration entities in Home Assistant for the radar and battery in the sensor dock.
# It is designed to be added as a second package to be inserted after the esp32-s3-box-3.yaml package.
#
# Enables the box:
# - to be carried around as a portable VA and have an idea when the battery is about to go out.
# - goes offline and stops listening/streaming when no-one is in the room (the screen is too bright at night).
# - consume much less power when no-one is in the room in order to preserve the battery the VA .
#
# The following are provided:
#
# Sensor:
# battery voltage (hidden)
# battery level (%)
#
# Binary Sensor:
# Presence detect (occupancy)
#
# Number:
# Presence duration (timeout to keep Presence detect true, default 60 seconds)
#
# Switch:
# Mute when absent (turns microphone and backlight off for low power, default OFF)
#
# To use, add the following to your device's yaml:
# ------------------------------------------------
# packages:
# esphome.voice-assistant-sensor: github://esphome/firmware/esp32-box-docks/box3-sensor-for-voice-assistant.yaml
# ------------------------------------------------

substitutions:
name: esp32-s3-box-3-sensor
friendly_name: ESP32 S3 Box 3 Sensor

sensor:
- platform: adc
pin: GPIO10
name: "Battery voltage"
id: battery_voltage
unit_of_measurement: "V"
accuracy_decimals: 3
device_class: "voltage"
entity_category: "diagnostic"
disabled_by_default: true
update_interval: 60s
attenuation: auto
filters:
- multiply: 4.01

- platform: copy
source_id: battery_voltage
name: "Battery level"
unit_of_measurement: "%"
accuracy_decimals: 0
device_class: "battery"
entity_category: "diagnostic"
filters:
- lambda: return (x - 3.1) / (4.14 - 3.1) * 100;
- clamp:
min_value: 0
max_value: 100
ignore_out_of_range: true

switch:
- platform: template
name: "Mute when absent"
id: mute_when_absent
icon: mdi:account-right-arrow
optimistic: true
entity_category: config
restore_mode: RESTORE_DEFAULT_OFF

number:
- platform: template
name: "Presence duration"
id: radar_delayed_off
icon: mdi:account-clock
optimistic: true
restore_value: true
initial_value: 60
min_value: 0
step: 5
max_value: 300
unit_of_measurement: s
entity_category: config
mode: box

binary_sensor:
- platform: gpio
pin:
number: GPIO21
name: "Presence detect"
disabled_by_default: false
device_class: "occupancy"
filters:
- delayed_off: !lambda return id(radar_delayed_off).state * 1000;
on_release:
then:
- if:
condition:
switch.is_on: mute_when_absent
then:
- switch.turn_on: mute
- light.turn_off: led
on_press:
then:
- if:
condition:
switch.is_on: mute_when_absent
then:
- switch.turn_off: mute
- light.turn_on: led
116 changes: 116 additions & 0 deletions esp32-box-docks/box3-sensor-generic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# This firmware is soley for the Espressif ESP32-S3-Box-3 with the Sensor dock
# It sets up sensors and configuration entities in Home Assistant for this specific hardware

substitutions:
name: esp32-s3-box-3-sensor
friendly_name: ESP32 S3 Box 3 Sensor

esphome:
name: "${name}"
friendly_name: "${friendly_name}"
name_add_mac_suffix: true
platformio_options:
board_build.flash_mode: dio
project:
name: esphome.esp_web_tools_example
jaymunro marked this conversation as resolved.
Show resolved Hide resolved
version: "1.0"

esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
jaymunro marked this conversation as resolved.
Show resolved Hide resolved

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow OTA updates
ota:

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
# Set up a wifi access point
ap:
ssid: "ESP Web Tools"
jaymunro marked this conversation as resolved.
Show resolved Hide resolved

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
package_import_url: github://esphome/firmware/esp-web-tools/esp32s3.yaml@v2
jaymunro marked this conversation as resolved.
Show resolved Hide resolved

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none

# To have a "next url" for improv serial
web_server:

# The yaml below is specific to the ESP32-S3-Box-3 with Sensor dock

# Sensors for the battery if it is installed
sensor:
- platform: adc
pin: GPIO10
name: "Battery voltage"
id: battery_voltage
unit_of_measurement: "V"
accuracy_decimals: 3
device_class: "voltage"
entity_category: "diagnostic"
disabled_by_default: true
update_interval: 60s
attenuation: auto
filters:
- multiply: 4.01

- platform: copy
source_id: battery_voltage
name: "Battery level"
unit_of_measurement: "%"
accuracy_decimals: 0
device_class: "battery"
entity_category: "diagnostic"
filters:
- lambda: return (x - 3.1) / (4.14 - 3.1) * 100;
- clamp:
min_value: 0
max_value: 100
ignore_out_of_range: true

# Timeout to keep Presence detect true, default 60 seconds
number:
- platform: template
name: "Presence duration"
id: radar_delayed_off
icon: mdi:account-clock
optimistic: true
restore_value: true
initial_value: 60
min_value: 0
step: 5
max_value: 300
unit_of_measurement: s
entity_category: config
mode: box

# Binary sensor for automations in Home Assistant
binary_sensor:
- platform: gpio
pin:
number: GPIO21
name: "Presence detect"
disabled_by_default: false
device_class: "occupancy"
filters:
- delayed_off: !lambda return id(radar_delayed_off).state * 1000;
on_release:
then: # do something in-device when absence is detected
on_press:
then: # do something in-device when presence is detected