more esphome devices and fixes
This commit is contained in:
+108
-73
@@ -1,29 +1,59 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# 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/
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# TITLE: NISSAN LEAF 12V BATTERY MONITOR
|
||||
# zorruno.com layout v1.1 2026
|
||||
#:########################################################################################:#
|
||||
# REPO:
|
||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-leafbattery.yaml
|
||||
#:########################################################################################:#
|
||||
# VERSIONS:
|
||||
# V1.1 2026-03-22 Updated yaml to zorruno layout V1.1
|
||||
# V1.0 2025-??-?? Initial Version
|
||||
#:########################################################################################:#
|
||||
# HARDWARE:
|
||||
# - Generic ESP8266 D1 Mini
|
||||
# - Nissan Leaf 12V battery monitor
|
||||
# - Voltage measured with a resistor divider into the ESP8266 analogue pin
|
||||
# - Device only transmits when the vehicle is within WiFi range
|
||||
# - Reference:
|
||||
# https://zorruno.com/2022/vehicle-12v-battery-monitoring/
|
||||
#:########################################################################################:#
|
||||
# OPERATION NOTES:
|
||||
# - Monitors the Nissan Leaf 12V battery voltage.
|
||||
# - Device wakes for a short period, publishes voltage, then deep sleeps.
|
||||
# - Deep sleep is PREVENTED on boot by default.
|
||||
# - Device waits up to 30 seconds for MQTT to connect.
|
||||
# - If MQTT does not connect within 30 seconds, it enters a longer fallback sleep period.
|
||||
# - If MQTT connects, deep sleep can be controlled by MQTT command topic.
|
||||
# - Battery voltage is read from A0 and calibrated using a linear table.
|
||||
# - Voltage is published immediately when it changes by 0.05 V or more.
|
||||
# - Voltage is also republished every 60 seconds while awake.
|
||||
#
|
||||
# MQTT COMMANDS:
|
||||
# - ${mqtt_command_topic}/deepsleep = ON
|
||||
# - Allow deep sleep when run_duration expires
|
||||
# - ${mqtt_command_topic}/deepsleep = OFF
|
||||
# - Prevent deep sleep
|
||||
#
|
||||
# MQTT STATUS:
|
||||
# - ${mqtt_status_topic}/availability = online/offline
|
||||
# - ${mqtt_status_topic}/batteryvoltage = voltage value
|
||||
#:########################################################################################:#
|
||||
|
||||
##########################################################################################
|
||||
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||
#:########################################################################################:#
|
||||
# SUBSTITUTIONS:
|
||||
# Specific device variable substitutions
|
||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
substitutions:
|
||||
# Device Naming
|
||||
# Device Naming
|
||||
device_name: "esp-leafbattery"
|
||||
friendly_name: "Nissan Leaf 12V Battery Monitor"
|
||||
description_comment: "Nissan Leaf 12V Battery Monitor (when home)"
|
||||
device_area: "Garage" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
description_comment: "Nissan Leaf 12V Battery Monitor (when home) (Layout V1.1)"
|
||||
device_area: "Garage" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Generic ESP8266.D1 Mini" # Project Details
|
||||
project_version: "v1.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
project_name: "Generic ESP8266.D1 Mini" # Project Details
|
||||
project_version: "v1.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||
@@ -32,26 +62,28 @@ substitutions:
|
||||
mqtt_command_main_topic: !secret mqtt_command_main_topic
|
||||
mqtt_status_main_topic: !secret mqtt_status_main_topic
|
||||
|
||||
# If we are changing IP addresses, you must update the current IP address here, otherwise it remains
|
||||
# Don't forget to switch it back when changed.
|
||||
current_ip_address: ${static_ip_address}
|
||||
|
||||
# MQTT LOCAL Controls
|
||||
mqtt_device_name: "leaf-battery"
|
||||
mqtt_command_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||
mqtt_status_topic: "${mqtt_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
||||
|
||||
# Device Settings
|
||||
#relay_icon: "mdi:lightbulb-group"
|
||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||
update_interval: "60s" # update time for for general sensors etc
|
||||
|
||||
wake_interval: "20s"
|
||||
sleep_interval: "300s"
|
||||
mqtt_fail_sleep: "1h" # If MQTT is unavailable after boot wait, sleep this long
|
||||
mqtt_fail_sleep: "1h" # If MQTT is unavailable after boot wait, sleep this long
|
||||
|
||||
##########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
#:########################################################################################:#
|
||||
# PACKAGES:
|
||||
# Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
@@ -60,6 +92,7 @@ packages:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
local_current_ip_address: "${current_ip_address}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
@@ -73,28 +106,32 @@ packages:
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
|
||||
#### WEB PORTAL ####
|
||||
common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
#:########################################################################################:#
|
||||
# ESPHOME:
|
||||
# https://esphome.io/components/esphome.html
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${friendly_name}
|
||||
comment: ${description_comment} #appears on the esphome page in HA
|
||||
name: "${device_name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "${description_comment}" # appears on the esphome page in HA
|
||||
area: "${device_area}"
|
||||
min_version: 2024.6.0
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
on_boot:
|
||||
priority: 600
|
||||
then:
|
||||
@@ -115,41 +152,41 @@ esphome:
|
||||
- logger.log: "MQTT unreachable after 30s -> entering FALLBACK sleep for ${mqtt_fail_sleep}."
|
||||
- deep_sleep.enter:
|
||||
id: deep_sleep_1
|
||||
sleep_duration: ${mqtt_fail_sleep} # override only this cycle
|
||||
sleep_duration: ${mqtt_fail_sleep} # override only this cycle
|
||||
else:
|
||||
- logger.log: "MQTT connected; awaiting '${mqtt_command_topic}/deepsleep' command."
|
||||
|
||||
##########################################################################################
|
||||
# ESP Platform and Framework
|
||||
#:########################################################################################:#
|
||||
# ESP PLATFORM AND FRAMEWORK:
|
||||
# https://esphome.io/components/esp8266.html
|
||||
# https://esphome.io/components/esp32.html
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
esp8266:
|
||||
board: d1_mini
|
||||
framework:
|
||||
version: latest #recommended, latest or dev
|
||||
version: latest # recommended, latest or dev
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome Logging Enable
|
||||
#:########################################################################################:#
|
||||
# LOGGER:
|
||||
# https://esphome.io/components/logger.html
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
logger:
|
||||
level: "${log_level}" #INFO Level suggested, or DEBUG for testing
|
||||
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||
level: "${log_level}" # INFO Level suggested, or DEBUG for testing
|
||||
#baud_rate: 0 # set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#############################################
|
||||
# Enable Over the Air Update Capability
|
||||
# https://esphome.io/components/ota.html?highlight=ota
|
||||
#############################################
|
||||
#:########################################################################################:#
|
||||
# OTA:
|
||||
# https://esphome.io/components/ota.html
|
||||
#:########################################################################################:#
|
||||
ota:
|
||||
- platform: web_server # Uncomment if you want to be able to do OTA with the web interface
|
||||
|
||||
##########################################################################################
|
||||
# MQTT COMMANDS
|
||||
#:########################################################################################:#
|
||||
# MQTT COMMANDS:
|
||||
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
mqtt:
|
||||
# Availability Topic
|
||||
birth_message:
|
||||
@@ -173,19 +210,19 @@ mqtt:
|
||||
- deep_sleep.prevent: deep_sleep_1
|
||||
- logger.log: "Deep sleep PREVENTED via MQTT."
|
||||
|
||||
##########################################################################################
|
||||
# Deep Sleep
|
||||
#:########################################################################################:#
|
||||
# DEEP SLEEP:
|
||||
# https://esphome.io/components/deep_sleep.html
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
deep_sleep:
|
||||
id: deep_sleep_1
|
||||
run_duration: ${wake_interval}
|
||||
sleep_duration: ${sleep_interval}
|
||||
|
||||
##########################################################################################
|
||||
# SENSOR COMPONENT
|
||||
run_duration: ${wake_interval}
|
||||
sleep_duration: ${sleep_interval}
|
||||
|
||||
#:########################################################################################:#
|
||||
# SENSOR COMPONENT:
|
||||
# https://esphome.io/components/sensor/
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
sensor:
|
||||
- platform: adc
|
||||
pin: A0
|
||||
@@ -208,8 +245,8 @@ sensor:
|
||||
- 0.32 -> 07.00
|
||||
- 0.28 -> 06.00
|
||||
- 0.23 -> 05.00
|
||||
- delta: 0.05 # publish immediately if change >= 0.05 V
|
||||
- throttle: 2s # avoid bursts if noisy
|
||||
- delta: 0.05 # publish immediately if change >= 0.05 V
|
||||
- throttle: 2s # avoid bursts if noisy
|
||||
on_value:
|
||||
then:
|
||||
- mqtt.publish:
|
||||
@@ -221,9 +258,10 @@ sensor:
|
||||
snprintf(buf, sizeof(buf), "%.2f", x);
|
||||
return std::string(buf);
|
||||
|
||||
##########################################################################################
|
||||
# INTERVAL COMPONENT
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# INTERVAL COMPONENT:
|
||||
# https://esphome.io/components/interval.html
|
||||
#:########################################################################################:#
|
||||
interval:
|
||||
- interval: 60s
|
||||
then:
|
||||
@@ -237,6 +275,3 @@ interval:
|
||||
snprintf(buf, sizeof(buf), "%.2f", v);
|
||||
return std::string(buf);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user