lifire/firebeetle2.yaml
Michael Hope 36ed9e50c0
All checks were successful
continuous-integration/drone/push Build is passing
lifire: improve the LIPO percentage mapping; support OTA mode
2024-05-09 16:38:44 +02:00

139 lines
2.8 KiB
YAML

esphome:
name: ${device_id}
name_add_mac_suffix: true
project:
name: "${project_name}"
version: "${project_version}"
external_components:
- source:
type: local
path: components
# Remove post 2024.04?
- source: github://esphome/esphome@dev
components:
- logger
esp32:
board: esp32-c6-devkitm-1
variant: esp32c6
flash_size: 4MB
framework:
type: esp-idf
version: 5.2.1
platform_version: 6.6.0
sdkconfig_options:
CONFIG_ESPTOOLPY_FLASHSIZE_4MB: y
logger:
level: INFO
baud_rate: 921600
hardware_uart: USB_SERIAL_JTAG
api:
encryption:
key: !secret api_key
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: "HIGH"
# Connect to the first AP found.
fast_connect: true
deep_sleep:
id: deep_sleep0
# Ensure the device sleeps even if Wifi or Home Assistant is unavailable.
run_duration: 120s
sleep_duration: ${sleep_duration}
switch:
- platform: restart
name: Restart
light:
- platform: status_led
name: "LED"
id: led
pin: GPIO15
binary_sensor:
- platform: gpio
name: "Boot"
id: boot_button
pin:
number: GPIO9
inverted: true
- platform: homeassistant
id: ota_mode
entity_id: input_boolean.${device_id}_ota_mode
publish_initial_state: true
on_state:
then:
if:
condition:
lambda: return x;
then:
- deep_sleep.prevent: deep_sleep0
else:
- deep_sleep.allow: deep_sleep0
sensor:
- platform: uptime
name: Uptime
id: uptime0
update_interval: 15s
- platform: adc
pin: GPIO0
name: Battery voltage
id: battery_voltage
unit_of_measurement: 'V'
device_class: voltage
state_class: measurement
accuracy_decimals: 3
# IDF 5.2.1 does not support 11dB
attenuation: 12db
# Read and average the results.
update_interval: 200ms
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
send_first_at: 5
- throttle: 10s
# VBAT goes through a 2:1 voltage divider.
- multiply: 2
# My board mildly overestimates the voltage
- multiply: 0.98
on_value:
- component.update: battery_level
- platform: template
name: Battery level
id: battery_level
unit_of_measurement: '%'
device_class: battery
state_class: measurement
icon: mdi:battery-high
lambda: "return id(battery_voltage).state;"
filters:
- calibrate_linear:
- 3.45 -> 0.0
- 3.69 -> 10.0
- 3.73 -> 20.0
- 3.80 -> 40.0
- 3.87 -> 60.0
- 4.02 -> 80.0
- 4.20 -> 100.0
- clamp:
min_value: 0
max_value: 100
time:
- platform: homeassistant
id: homeassistant_time