various esphome yaml tidyups

This commit is contained in:
root
2024-06-06 11:08:40 +12:00
parent 29c092232b
commit 8851f8da5e
5 changed files with 493 additions and 387 deletions

View File

@@ -1,16 +1,60 @@
#############################################
# Common
#############################################
#############################################
# Nissan Leaf 12V Battery Monitor
# Monitoring the status of a vehicle 12V battery with
# an esp8266 (D1 Mini). It will obviously only
# transmit when the vehicle is within wifi range.
# Voltage is measured with a resistor voltage divider
# into the analogue GPIO on the esp8266.
# https://zorruno.com/2022/vehicle-12v-battery-monitoring/
##############################################
# zorruno 2022-09-31 V1 Untested
# zorruno 2024-06-02 V2 YAML Tidyups
#############################################
#############################################
#############################################
# Variable Substitutions
# Give this a useful name & description here
# and change values accordingly
#############################################
substitutions:
devicename: esp-leafbat2
nice_devicename: "Leaf Battery Monitor 2"
devicename: "esp-leafbat2"
friendly_name: "Nissan Leaf 12V Battery Monitor"
description_comment: "Nissan Leaf 12V Battery Monitor (when home)"
#if NOT using a secrets file, just replace these with the passwords etc in speech marks
api_key: !secret esp-leafbat_api_key #unfortunately you can't use substitutions in secrets names
ota_pass: !secret esp-leafbat_ota_pass #unfortunately you can't use substitutions in secrets names
#update_time: 30s #update time for for temp sensors etc
wifi_ssid: !secret wifi_ssid
wifi_pass: !secret wifi_password
#Add these if we are giving it a static ip, or remove them in the Wifi section
static_ip_address: !secret esp-leafbat_static_ip
static_ip_gateway: !secret esp-leafbat_gateway
static_ip_subnet: !secret esp-leafbat_subnet
mqtt_server: !secret mqtt_server
mqtt_username: !secret mqtt_username
mqtt_password: !secret mqtt_password
mqtt_topic: "esphome/esp-leafbat2" #main topic for the mqtt server, call it what you like
web_server_username: !secret web_server_username
web_server_password: !secret web_server_password
fallback_ap_ssid: "Esp-Leafbat2 Fallback Hotspot"
fallback_ap_password: !secret fallback_ap_password
#############################################
# ESPHome
#############################################
esphome:
name: $devicename
name: ${devicename}
comment: ${description_comment} #appears on the esphome page in HA
########################################
# Specific board for ESPHome device
@@ -28,7 +72,7 @@ logger:
########################################
api:
encryption:
key: !secret esp-leafbat2_api_key
key: ${api_key}
########################################
# Enable Over the Air Update Capability
@@ -36,24 +80,24 @@ api:
########################################
ota:
safe_mode: true
password: !secret esp-leafbat2_ota_pass
password: ${ota_pass}
########################################
# Use Wifi
# (credentials are in secrets file)
########################################
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ssid: ${wifi_ssid}
password: ${wifi_password}
# Details for fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Leafbat2 Fallback Hotspot"
password: !secret fallback_ap_password
ssid: ${fallback_ap_ssid}
password: ${fallback_ap_password}
# Static IP (for lower power/quicker on time)
manual_ip:
static_ip: !secret esp-leafbat2_static_ip
gateway: !secret esp-leafbat2_gateway
subnet: !secret esp-leafbat2_subnet
static_ip: ${static_ip_address}
gateway: ${static_ip_gateway}
subnet: ${static_ip_subnet}
#############################################
# Fallback captive portal
@@ -66,17 +110,17 @@ captive_portal:
web_server:
port: 80
auth:
username: !secret web_server_username
password: !secret web_server_password
username: ${web_server_username}
password: ${web_server_password}
########################################
# MQTT Monitoring
########################################
mqtt:
broker: !secret mqtt_server
topic_prefix: esphome/esp-leafbat2
username: !secret mqtt_username
password: !secret mqtt_password
broker: ${mqtt_server}
topic_prefix: ${mqtt_topic}
username: ${mqtt_username}
password: ${mqtt_password}
#
# Availability Topic
#birth_message:
@@ -87,11 +131,11 @@ mqtt:
# payload: offline
# A way to prevent deep sleep using MQTT command
on_message:
- topic: viewroad-commands/leafbat2/deepsleepoff
- topic: viewroad-commands/leafbat2/deepsleep
payload: 'ON'
then:
- deep_sleep.prevent: deep_sleep_1
- topic: viewroad-commands/leafbat2/deepsleepon
- topic: viewroad-commands/leafbat2/deepsleep
payload: 'ON'
then:
- deep_sleep.enter: deep_sleep_1