esphome mi 1s lamp

This commit is contained in:
root
2024-09-04 22:46:30 +12:00
parent 74d1c18615
commit 83549c6c1e
26 changed files with 2934 additions and 929 deletions

View File

@@ -19,19 +19,36 @@ substitutions:
description_comment: "Atto3 12V Battery Monitor (when home)"
api_key: !secret esp-attobat_api_key #unfortunately you can't use substitutions in secrets names
ota_pass: !secret esp-attobat_ota_pass #unfortunately you can't use substitutions in secrets names
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
update_time: 30s #update time for for temp sensors etc
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
fallback_ap_password: !secret fallback_ap_password
#Add these if we are giving it a static ip, or remove them in the Wifi section
#A static IP will speed things up slightly in that it doesn't have to negotiate DHCP
static_ip_address: !secret esp-attobat_static_ip
static_ip_gateway: !secret esp-attobat_gateway
static_ip_subnet: !secret esp-attobat_subnet
mqtt_server: !secret mqtt_server
mqtt_username: !secret mqtt_username
mqtt_password: !secret mqtt_password
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
mqtt_commandstopic: "viewroad-commands" #main topic for commands (ie sleep), call it what you like
#web_server_username: !secret web_server_username
#web_server_password: !secret web_server_password
update_time: 10s #update time for for general temp sensors etc
#############################################
# ESPHome
#############################################
# https://esphome.io/components/esphome.html
#############################################
esphome:
name: $devicename
name: ${devicename}
friendly_name: ${friendly_name}
comment: ${description_comment} #appears on the esphome page in HA
min_version: 2024.6.0
#############################################
# ESP Platform and Framework
@@ -66,39 +83,49 @@ api:
# https://esphome.io/components/ota.html?highlight=ota
#############################################
ota:
safe_mode: true #Safe mode will detect boot loops
password: ${ota_pass}
- platform: esphome
password: ${ota_pass}
#############################################
# Safe Mode
# Safe mode will detect boot loops
# https://esphome.io/components/safe_mode
#############################################
safe_mode:
#############################################
# Wifi Settings
# https://esphome.io/components/wifi.html
#
# Power Save mode (can reduce wifi reliability)
# NONE (least power saving, Default for ESP8266)
# LIGHT (Default for ESP32)
# HIGH (most power saving)
#############################################
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ssid: ${wifi_ssid}
password: ${wifi_password}
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
# Static IP (for lower power/quicker on time)
manual_ip:
manual_ip: #optional static IP address
static_ip: ${static_ip_address}
gateway: ${static_ip_gateway}
subnet: ${static_ip_subnet}
ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
ssid: ${devicename} fallback AP
password: !secret fallback_ap_password
ap_timeout: 5min #default is 1min
captive_portal: # Fallback captive portal https://esphome.io/components/captive_portal.html
password: ${fallback_ap_password}
ap_timeout: 30min #Time until it brings up fallback AP. default is 1min
#############################################
# Web Portal for display and monitoring
#############################################
web_server:
port: 80
version: 2
include_internal: true
ota: false
auth:
username: !secret web_server_username
password: !secret web_server_password
#version: 2
#include_internal: true
#ota: false
#auth:
#username: ${web_server_username}
#password: ${web_server_password}
#############################################
# MQTT Monitoring
@@ -106,29 +133,42 @@ web_server:
# MUST also have api enabled if you enable MQTT
#############################################
mqtt:
broker: !secret mqtt_server
broker: ${mqtt_server}
topic_prefix: ${mqtt_topic}/${devicename}
#username: !secret mqtt_username
#password: !secret mqtt_password
#
username: ${mqtt_username}
password: ${mqtt_password}
# Availability Topic
#birth_message:
# topic: esphome/esp-leafbat2/availability
# payload: online
#will_message:
# topic: esphome/esp-leafbat2/availability
# payload: offline
birth_message:
topic: ${mqtt_topic}/${devicename}/availability
payload: online
will_message:
topic: ${mqtt_topic}/${devicename}/availability
payload: offline
# A way to prevent deep sleep using MQTT command
on_message:
- topic: viewroad-commands/attobat/deepsleep
payload: 'OFF'
- topic: ${mqtt_commandstopic}/${devicename}/deepsleep
payload: "OFF"
then:
- deep_sleep.prevent: deep_sleep_1
- topic: viewroad-commands/attobat/deepsleep
payload: 'ON'
- topic: ${mqtt_commandstopic}/${devicename}/deepsleep
payload: "ON"
then:
- deep_sleep.enter: deep_sleep_1
# on_message:
# - topic: ${mqtt_commandstopic}/${devicename}/deepsleepon
# payload: 'ON'
# then:
# - deep_sleep.prevent: deep_sleep_1
# - topic: ${mqtt_commandstopic}/${devicename}/deepsleepoff
# payload: 'OFF'
# then:
# - deep_sleep.enter: deep_sleep_1
########################################
# Deep Sleep
# https://esphome.io/components/deep_sleep.html
@@ -144,27 +184,32 @@ deep_sleep:
#############################################
#############################################
sensor:
# Quality of Wifi in dBm
#Quality of Wifi in dBm
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 10s
retain: true
# Analog sensor for voltage reading (A0)
update_interval: ${update_time}
retain: true #Retain this as you'll have no value between sleeps otherwise
#Analog sensor for voltage reading (A0)
- platform: uptime
name: "Uptime"
update_interval: ${update_time}
retain: true #Retain this as you'll have no value between sleeps otherwise
- platform: adc
pin: A0
name: "Battery Voltage"
update_interval: 10s
retain: true
update_interval: ${update_time}
retain: true #Retain this as you'll have no value between sleeps otherwise
filters:
#- multiply: 18.52 # trial and error calc/measure
- calibrate_linear:
- 0.41 -> 6.00
- 0.48 -> 7.00
- 0.54 -> 8.00
- 0.61 -> 9.00
- 0.68 -> 10.00
- 0.75 -> 11.00
- 0.81 -> 12.00
- 0.88 -> 13.00
- 0.94 -> 13.99
- 0.99 -> 14.70
- multiply: 3.3 #D1 mini V divider, 3.3V -> 1V on esp8266
- calibrate_linear: #Read values with voltmeter and bench supply
- 3.11 -> 14.00
- 3.00 -> 13.50
- 2.89 -> 13.00
- 2.77 -> 12.50
- 2.67 -> 12.00
- 2.55 -> 11.50
- 2.45 -> 11.00
- 2.34 -> 10.50
- 2.22 -> 10.00
- 2.11 -> 09.50
- 2.00 -> 09.00