esphome pelmet LEDs, lounge scenes and other fixes
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
{"pid": 67, "version": 1, "ha_version": "2025.10.1", "start_ts": 1759647901.614362}
|
{"pid": 68, "version": 1, "ha_version": "2025.10.2", "start_ts": 1760251204.265106}
|
||||||
@@ -8,7 +8,7 @@ substitutions:
|
|||||||
|
|
||||||
# Debug helpers (loop time / heap / reset info)
|
# Debug helpers (loop time / heap / reset info)
|
||||||
debug:
|
debug:
|
||||||
update_interval: ${local_update_interval}
|
update_interval: 5min
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
# Free heap via debug (replaces template-based ESP.getFreeHeap if you prefer)
|
# Free heap via debug (replaces template-based ESP.getFreeHeap if you prefer)
|
||||||
@@ -16,12 +16,22 @@ sensor:
|
|||||||
free:
|
free:
|
||||||
name: "Free Heap"
|
name: "Free Heap"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
|
disabled_by_default: true
|
||||||
|
filters:
|
||||||
|
- delta: 1024 # only if heap changes by ≥1 KB
|
||||||
|
- heartbeat: 5min # but still publish every 5 min
|
||||||
|
|
||||||
|
|
||||||
# Loop time via debug (replaces broken template loop time)
|
# Loop time via debug (replaces broken template loop time)
|
||||||
- platform: debug
|
- platform: debug
|
||||||
loop_time:
|
loop_time:
|
||||||
name: "Loop Time"
|
name: "Loop Time"
|
||||||
|
disabled_by_default: true
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
|
filters:
|
||||||
|
- delta: 2 # only if loop time changes by ≥2 ms
|
||||||
|
- heartbeat: 5min
|
||||||
|
|
||||||
|
|
||||||
## If you’d rather keep the legacy heap sensor, uncomment below and
|
## If you’d rather keep the legacy heap sensor, uncomment below and
|
||||||
## delete the debug "free" block above to avoid duplicates:
|
## delete the debug "free" block above to avoid duplicates:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ text_sensor:
|
|||||||
- platform: version
|
- platform: version
|
||||||
name: "Version:"
|
name: "Version:"
|
||||||
entity_category: "diagnostic"
|
entity_category: "diagnostic"
|
||||||
|
disabled_by_default: true
|
||||||
|
|
||||||
- platform: wifi_info
|
- platform: wifi_info
|
||||||
ip_address:
|
ip_address:
|
||||||
@@ -19,10 +20,12 @@ text_sensor:
|
|||||||
name: "Connected SSID"
|
name: "Connected SSID"
|
||||||
icon: mdi:wifi-strength-2
|
icon: mdi:wifi-strength-2
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
disabled_by_default: true
|
||||||
mac_address:
|
mac_address:
|
||||||
name: "MAC Address:"
|
name: "MAC Address:"
|
||||||
icon: mdi:network-pos
|
icon: mdi:network-pos
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
|
disabled_by_default: true
|
||||||
|
|
||||||
#####################################################################################################
|
#####################################################################################################
|
||||||
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
# Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
|
||||||
|
|||||||
@@ -1,217 +0,0 @@
|
|||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
# BYD ATTO3 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/
|
|
||||||
##############################################
|
|
||||||
#############################################
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Variable Substitutions
|
|
||||||
#############################################
|
|
||||||
substitutions:
|
|
||||||
devicename: "esp-attobat"
|
|
||||||
friendly_name: "Atto3 12V Battery Monitor"
|
|
||||||
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
|
|
||||||
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}
|
|
||||||
friendly_name: ${friendly_name}
|
|
||||||
comment: ${description_comment} #appears on the esphome page in HA
|
|
||||||
min_version: 2024.6.0
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESPHome Logging Enable
|
|
||||||
# https://esphome.io/components/logger.html
|
|
||||||
#############################################
|
|
||||||
logger:
|
|
||||||
level: INFO #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 the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${api_key}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- platform: esphome
|
|
||||||
password: ${ota_pass}
|
|
||||||
- platform: web_server # Uncomment if you want to be able to do OTA with the web interface
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# 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: ${wifi_ssid}
|
|
||||||
password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
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: ${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: ${web_server_username}
|
|
||||||
#password: ${web_server_password}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: False # enable entity discovery (true is default, we don't want two HA Instances)
|
|
||||||
|
|
||||||
# Availability Topic
|
|
||||||
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: ${mqtt_commandstopic}/${devicename}/deepsleep
|
|
||||||
payload: "OFF"
|
|
||||||
then:
|
|
||||||
- deep_sleep.prevent: deep_sleep_1
|
|
||||||
- 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
|
|
||||||
########################################
|
|
||||||
deep_sleep:
|
|
||||||
run_duration: 20s
|
|
||||||
sleep_duration: 5min
|
|
||||||
id: deep_sleep_1
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
# MAIN SENSORS
|
|
||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
sensor:
|
|
||||||
#Quality of Wifi in dBm
|
|
||||||
- platform: wifi_signal
|
|
||||||
name: "WiFi Signal"
|
|
||||||
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: ${update_time}
|
|
||||||
retain: true #Retain this as you'll have no value between sleeps otherwise
|
|
||||||
filters:
|
|
||||||
- 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
|
|
||||||
@@ -34,20 +34,21 @@ substitutions:
|
|||||||
|
|
||||||
# MQTT LOCAL Controls
|
# MQTT LOCAL Controls
|
||||||
mqtt_device_name: "atto-battery"
|
mqtt_device_name: "atto-battery"
|
||||||
mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
mqtt_command_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||||
mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status 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
|
# Device Settings
|
||||||
#relay_icon: "mdi:lightbulb-group"
|
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
log_level: "DEBUG" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
|
||||||
update_interval: "60s" # update time for for general sensors etc
|
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
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES: Included Common Packages
|
# PACKAGES: Included Common Packages
|
||||||
# https://esphome.io/components/packages.html
|
# https://esphome.io/components/packages.html
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
|
||||||
##########################################################################################
|
|
||||||
packages:
|
packages:
|
||||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||||
common_wifi: !include
|
common_wifi: !include
|
||||||
@@ -74,12 +75,12 @@ packages:
|
|||||||
common_webportal: !include common/webportal_common.yaml
|
common_webportal: !include common/webportal_common.yaml
|
||||||
|
|
||||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
#### 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 ####
|
#### DIAGNOSTICS Sensors ####
|
||||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||||
diag_more: !include common/include_more_diag_sensors.yaml
|
diag_more: !include common/include_more_diag_sensors.yaml
|
||||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -91,6 +92,29 @@ esphome:
|
|||||||
friendly_name: ${friendly_name}
|
friendly_name: ${friendly_name}
|
||||||
comment: ${description_comment} #appears on the esphome page in HA
|
comment: ${description_comment} #appears on the esphome page in HA
|
||||||
min_version: 2024.6.0
|
min_version: 2024.6.0
|
||||||
|
on_boot:
|
||||||
|
priority: 600
|
||||||
|
then:
|
||||||
|
# Default: do NOT deep sleep until explicitly enabled via MQTT
|
||||||
|
- deep_sleep.prevent: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep prevented by default on boot."
|
||||||
|
|
||||||
|
# Fail-safe: wait up to 30s for MQTT; if not connected, sleep longer (backoff)
|
||||||
|
- wait_until:
|
||||||
|
condition:
|
||||||
|
mqtt.connected:
|
||||||
|
timeout: 30s
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
not:
|
||||||
|
mqtt.connected:
|
||||||
|
then:
|
||||||
|
- 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
|
||||||
|
else:
|
||||||
|
- logger.log: "MQTT connected; awaiting '${mqtt_command_topic}/deepsleep' command."
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# ESP Platform and Framework
|
# ESP Platform and Framework
|
||||||
@@ -124,58 +148,51 @@ ota:
|
|||||||
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
mqtt:
|
mqtt:
|
||||||
|
|
||||||
# Availability Topic
|
# Availability Topic
|
||||||
birth_message:
|
birth_message:
|
||||||
topic: ${mqtt_local_status_topic}/availability
|
topic: ${mqtt_status_topic}/availability
|
||||||
payload: online
|
payload: online
|
||||||
will_message:
|
will_message:
|
||||||
topic: ${mqtt_local_status_topic}/availability
|
topic: ${mqtt_status_topic}/availability
|
||||||
payload: offline
|
payload: offline
|
||||||
|
|
||||||
# A way to prevent deep sleep using MQTT command
|
# Control deep sleep over MQTT
|
||||||
on_message:
|
on_message:
|
||||||
- topic: ${mqtt_local_command_topic}/deepsleep
|
- topic: ${mqtt_command_topic}/deepsleep
|
||||||
|
payload: "ON"
|
||||||
|
then:
|
||||||
|
- deep_sleep.allow: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep ALLOWED via MQTT. Device will sleep when run_duration elapses."
|
||||||
|
|
||||||
|
- topic: ${mqtt_command_topic}/deepsleep
|
||||||
payload: "OFF"
|
payload: "OFF"
|
||||||
then:
|
then:
|
||||||
- deep_sleep.prevent: deep_sleep_1
|
- deep_sleep.prevent: deep_sleep_1
|
||||||
- topic: ${mqtt_local_command_topic}/deepsleep
|
- logger.log: "Deep sleep PREVENTED via MQTT."
|
||||||
payload: "ON"
|
|
||||||
then:
|
|
||||||
- deep_sleep.enter: deep_sleep_1
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Deep Sleep
|
# Deep Sleep
|
||||||
# https://esphome.io/components/deep_sleep.html
|
# https://esphome.io/components/deep_sleep.html
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
deep_sleep:
|
deep_sleep:
|
||||||
run_duration: 20s
|
|
||||||
sleep_duration: 5min
|
|
||||||
id: deep_sleep_1
|
id: deep_sleep_1
|
||||||
|
run_duration: ${wake_interval}
|
||||||
|
sleep_duration: ${sleep_interval}
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# SENSOR COMPONENT
|
# SENSOR COMPONENT
|
||||||
# https://esphome.io/components/sensor/
|
# https://esphome.io/components/sensor/
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
sensor:
|
sensor:
|
||||||
#Quality of Wifi in dBm
|
|
||||||
- platform: wifi_signal
|
|
||||||
name: "WiFi Signal"
|
|
||||||
update_interval: ${update_interval}
|
|
||||||
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_interval}
|
|
||||||
retain: true #Retain this as you'll have no value between sleeps otherwise
|
|
||||||
- platform: adc
|
- platform: adc
|
||||||
pin: A0
|
pin: A0
|
||||||
name: "Battery Voltage"
|
name: "Battery Voltage"
|
||||||
update_interval: ${update_interval}
|
id: battery_voltage
|
||||||
retain: true #Retain this as you'll have no value between sleeps otherwise
|
update_interval: 4s
|
||||||
|
retain: true
|
||||||
filters:
|
filters:
|
||||||
- multiply: 3.3 #D1 mini V divider, 3.3V -> 1V on esp8266
|
- multiply: 3.3
|
||||||
- calibrate_linear: #Read values with voltmeter and bench supply
|
- calibrate_linear:
|
||||||
- 3.11 -> 14.00
|
- 3.11 -> 14.00
|
||||||
- 3.00 -> 13.50
|
- 3.00 -> 13.50
|
||||||
- 2.89 -> 13.00
|
- 2.89 -> 13.00
|
||||||
@@ -187,3 +204,16 @@ sensor:
|
|||||||
- 2.22 -> 10.00
|
- 2.22 -> 10.00
|
||||||
- 2.11 -> 09.50
|
- 2.11 -> 09.50
|
||||||
- 2.00 -> 09.00
|
- 2.00 -> 09.00
|
||||||
|
- delta: 0.05 # publish immediately if change >= 0.05 V
|
||||||
|
- throttle: 2s # avoid bursts if noisy
|
||||||
|
on_value:
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_status_topic}/batteryvoltage"
|
||||||
|
qos: 1
|
||||||
|
retain: true
|
||||||
|
payload: !lambda |-
|
||||||
|
char buf[10];
|
||||||
|
snprintf(buf, sizeof(buf), "%.2f", x);
|
||||||
|
return std::string(buf);
|
||||||
|
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ substitutions:
|
|||||||
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
||||||
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
||||||
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
||||||
pwm_frequency: "1000hz" # PWM output Frequency. High enough to avoid audible/visible artifacts
|
pwm_frequency: "1000" # PWM output Frequency in Hz. High enough to avoid audible/visible artifacts
|
||||||
|
|
||||||
# Device Specific GPIO (so we can easily update for other devices)
|
# Device Specific GPIO (so we can easily update for other devices)
|
||||||
device_status_led: GPIO02 # Can't really see if there is an LED
|
device_status_led: GPIO02
|
||||||
device_mosfet_out: GPIO12
|
device_mosfet_out: GPIO12
|
||||||
device_usr_button: GPIO04 # this is just a fake/safeish choice so it compiles with my generic yaml
|
device_usr_button: GPIO04 # if no button, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
device_fading_led: GPIO13 # this is just a fake/safeish choice so it compiles with my generic yaml
|
device_fading_led: GPIO13 # if no LED, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES: Included Common Packages
|
# PACKAGES: Included Common Packages
|
||||||
@@ -124,8 +124,8 @@ packages:
|
|||||||
|
|
||||||
#### DIAGNOSTICS Sensors ####
|
#### DIAGNOSTICS Sensors ####
|
||||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||||
#diag_more: !include common/include_more_diag_sensors.yaml
|
diag_more: !include common/include_more_diag_sensors.yaml
|
||||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -180,7 +180,7 @@ esphome:
|
|||||||
- lambda: 'id(booting) = false;'
|
- lambda: 'id(booting) = false;'
|
||||||
|
|
||||||
# NEW: force indicator OFF after boot logic
|
# NEW: force indicator OFF after boot logic
|
||||||
- output.turn_off: green_led_out
|
# (Removed: output.turn_off: green_led_out)
|
||||||
|
|
||||||
# Only if you want to play with build flags...
|
# Only if you want to play with build flags...
|
||||||
# platformio_options:
|
# platformio_options:
|
||||||
@@ -228,6 +228,11 @@ globals:
|
|||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "${max_on_default_hours}"
|
initial_value: "${max_on_default_hours}"
|
||||||
|
# Compile time Gamma
|
||||||
|
- id: led_gamma_f
|
||||||
|
type: float
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${led_gamma} # <-- numeric at compile time
|
||||||
|
|
||||||
# Default Fading Up Time (Selectable and will be retained)
|
# Default Fading Up Time (Selectable and will be retained)
|
||||||
- id: ramp_up_ms # fade-in when turned ON
|
- id: ramp_up_ms # fade-in when turned ON
|
||||||
@@ -389,7 +394,6 @@ button:
|
|||||||
# Stop any pending scripts (and their delayed actions)
|
# Stop any pending scripts (and their delayed actions)
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
// We are no longer ramping (up or down)
|
// We are no longer ramping (up or down)
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -485,10 +489,11 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:percent
|
icon: mdi:percent
|
||||||
accuracy_decimals: 0
|
accuracy_decimals: 0
|
||||||
update_interval: 1s # consider 200ms if you want fewer updates
|
update_interval: 2s # consider 200ms if you want fewer updates
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
return cv.is_on() ? (float) (int)(cv.get_brightness() * 100.0f + 0.5f) : 0.0f;
|
||||||
|
|
||||||
on_value:
|
on_value:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -515,18 +520,16 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:square-wave
|
icon: mdi:square-wave
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
update_interval: 1s
|
update_interval: 2s
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (!cv.is_on()) return 0.0f;
|
if (!cv.is_on()) return 0.0f;
|
||||||
const float lin = cv.get_brightness(); // 0..1 linear brightness
|
const float lin = cv.get_brightness();
|
||||||
const float gamma = atof("${led_gamma}"); // parse substitution string -> float
|
float pwm = powf(lin, id(led_gamma_f));
|
||||||
float pwm = powf(lin, gamma); // approx PWM duty after gamma
|
|
||||||
if (pwm < 0.0f) pwm = 0.0f;
|
if (pwm < 0.0f) pwm = 0.0f;
|
||||||
if (pwm > 1.0f) pwm = 1.0f;
|
if (pwm > 1.0f) pwm = 1.0f;
|
||||||
return pwm * 100.0f;
|
return pwm * 100.0f;
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# OUTPUT COMPONENT
|
# OUTPUT COMPONENT
|
||||||
# https://esphome.io/components/light/index.html
|
# https://esphome.io/components/light/index.html
|
||||||
@@ -561,6 +564,7 @@ light:
|
|||||||
|
|
||||||
# ON: publish state, track intent, arm watchdog if configured
|
# ON: publish state, track intent, arm watchdog if configured
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
|
- output.turn_on: green_led_out
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}/light/state"
|
topic: "${mqtt_local_status_topic}/light/state"
|
||||||
payload: "${mqtt_local_device_command_ON}"
|
payload: "${mqtt_local_device_command_ON}"
|
||||||
@@ -580,6 +584,7 @@ light:
|
|||||||
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
||||||
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
|
- output.turn_off: green_led_out
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return !id(booting);'
|
lambda: 'return !id(booting);'
|
||||||
@@ -600,13 +605,15 @@ light:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
const float cap = id(max_brightness_pct) / 100.0f;
|
const float cap = id(max_brightness_pct) / 100.0f;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (cv.is_on() && cv.get_brightness() > cap + 0.001f) {
|
if (!cv.is_on()) return;
|
||||||
auto call = id(mosfet_leds).make_call();
|
const float b = cv.get_brightness();
|
||||||
call.set_state(true);
|
if (b <= cap + 0.001f) return; // no call if already at/under cap
|
||||||
call.set_brightness(cap);
|
auto call = id(mosfet_leds).make_call();
|
||||||
call.set_transition_length(0);
|
call.set_state(true);
|
||||||
call.perform();
|
call.set_brightness(cap);
|
||||||
}
|
call.set_transition_length(0);
|
||||||
|
call.perform();
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# NUMBER COMPONENT
|
# NUMBER COMPONENT
|
||||||
@@ -768,7 +775,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at at least the floor without a visible "pop".
|
# Ensure we start at at least the floor without a visible "pop".
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -805,7 +811,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -820,7 +825,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at the floor cleanly.
|
# Ensure we start at the floor cleanly.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -863,7 +867,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -881,7 +884,6 @@ script:
|
|||||||
id(is_ramping) = true;
|
id(is_ramping) = true;
|
||||||
id(ramping_for_off) = true;
|
id(ramping_for_off) = true;
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||||
@@ -902,7 +904,6 @@ script:
|
|||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 150ms
|
transition_length: 150ms
|
||||||
- delay: 150ms
|
- delay: 150ms
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -962,4 +963,4 @@ script:
|
|||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 0s
|
transition_length: 0s
|
||||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
# (Removed: output.turn_off: green_led_out) # make sure LED is off if no ramp
|
||||||
@@ -42,15 +42,15 @@ substitutions:
|
|||||||
|
|
||||||
# MQTT LOCAL Controls
|
# MQTT LOCAL Controls
|
||||||
mqtt_local_device_name: "stair-mainlights-lower"
|
mqtt_local_device_name: "stair-mainlights-lower"
|
||||||
mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}/set" # Topic we will use to command this locally without HA
|
mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}" # Topic we will use to command this locally without HA
|
||||||
mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}/state" # Topic we will use to view status locally without HA
|
mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}" # Topic we will use to view status locally without HA
|
||||||
mqtt_local_device_command_ON: "ON"
|
mqtt_local_device_command_ON: "ON"
|
||||||
mqtt_local_device_command_OFF: "OFF"
|
mqtt_local_device_command_OFF: "OFF"
|
||||||
|
|
||||||
# MQTT REMOTE Controls
|
# MQTT REMOTE Controls
|
||||||
mqtt_remote_device1_name: "stair-footerlights"
|
mqtt_remote_device1_name: "stair-footerlights"
|
||||||
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}/set"
|
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}"
|
||||||
mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state"
|
mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}"
|
||||||
#mqtt_remote_device2_name: "stair-mainlights-upper"
|
#mqtt_remote_device2_name: "stair-mainlights-upper"
|
||||||
#mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set"
|
#mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set"
|
||||||
#mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state"
|
#mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state"
|
||||||
|
|||||||
@@ -42,15 +42,15 @@ substitutions:
|
|||||||
|
|
||||||
# MQTT LOCAL Controls
|
# MQTT LOCAL Controls
|
||||||
mqtt_local_device_name: "stair-footerlights"
|
mqtt_local_device_name: "stair-footerlights"
|
||||||
mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}/set" # Topic we will use to command this locally without HA
|
mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}" # Topic we will use to command this locally without HA
|
||||||
mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}/state" # Topic we will use to view status locally without HA
|
mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}" # Topic we will use to view status locally without HA
|
||||||
mqtt_local_device_command_ON: "ON"
|
mqtt_local_device_command_ON: "ON"
|
||||||
mqtt_local_device_command_OFF: "OFF"
|
mqtt_local_device_command_OFF: "OFF"
|
||||||
|
|
||||||
# MQTT REMOTE Controls
|
# MQTT REMOTE Controls
|
||||||
mqtt_remote_device1_name: "stair-mainlights-lower"
|
mqtt_remote_device1_name: "stair-mainlights-lower"
|
||||||
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}/set"
|
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}"
|
||||||
mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state"
|
mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}"
|
||||||
#mqtt_remote_device2_name: "stair-mainlights-upper"
|
#mqtt_remote_device2_name: "stair-mainlights-upper"
|
||||||
#mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set"
|
#mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set"
|
||||||
#mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state"
|
#mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state"
|
||||||
|
|||||||
@@ -94,13 +94,13 @@ substitutions:
|
|||||||
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
||||||
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
||||||
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
||||||
pwm_frequency: "1000 hz" # PWM output Frequency. High enough to avoid audible/visible artifacts
|
pwm_frequency: "1000" # PWM output Frequency in Hz. High enough to avoid audible/visible artifacts
|
||||||
|
|
||||||
# Device Specific GPIO (so we can easily update for other devices)
|
# Device Specific GPIO (so we can easily update for other devices)
|
||||||
device_status_led: GPIO02
|
device_status_led: GPIO02
|
||||||
device_mosfet_out: GPIO04
|
device_mosfet_out: GPIO04
|
||||||
device_usr_button: GPIO12
|
device_usr_button: GPIO12 # if no button, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
device_fading_led: GPIO13
|
device_fading_led: GPIO13 # if no LED, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES: Included Common Packages
|
# PACKAGES: Included Common Packages
|
||||||
@@ -117,8 +117,8 @@ packages:
|
|||||||
|
|
||||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||||
common_api: !include
|
common_api: !include
|
||||||
file: common/api_common.yaml
|
#file: common/api_common.yaml
|
||||||
#file: common/api_common_noencryption.yaml
|
file: common/api_common_noencryption.yaml
|
||||||
vars:
|
vars:
|
||||||
local_api_key: "${api_key}"
|
local_api_key: "${api_key}"
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ packages:
|
|||||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||||
diag_more: !include common/include_more_diag_sensors.yaml
|
diag_more: !include common/include_more_diag_sensors.yaml
|
||||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# ESPHome CORE CONFIGURATION
|
# ESPHome CORE CONFIGURATION
|
||||||
@@ -191,7 +191,7 @@ esphome:
|
|||||||
- lambda: 'id(booting) = false;'
|
- lambda: 'id(booting) = false;'
|
||||||
|
|
||||||
# NEW: force indicator OFF after boot logic
|
# NEW: force indicator OFF after boot logic
|
||||||
- output.turn_off: green_led_out
|
# (Removed: output.turn_off: green_led_out)
|
||||||
|
|
||||||
# Only if you want to play with build flags...
|
# Only if you want to play with build flags...
|
||||||
# platformio_options:
|
# platformio_options:
|
||||||
@@ -239,6 +239,11 @@ globals:
|
|||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "${max_on_default_hours}"
|
initial_value: "${max_on_default_hours}"
|
||||||
|
# Compile time Gamma
|
||||||
|
- id: led_gamma_f
|
||||||
|
type: float
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${led_gamma} # <-- numeric at compile time
|
||||||
|
|
||||||
# Default Fading Up Time (Selectable and will be retained)
|
# Default Fading Up Time (Selectable and will be retained)
|
||||||
- id: ramp_up_ms # fade-in when turned ON
|
- id: ramp_up_ms # fade-in when turned ON
|
||||||
@@ -400,7 +405,6 @@ button:
|
|||||||
# Stop any pending scripts (and their delayed actions)
|
# Stop any pending scripts (and their delayed actions)
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
// We are no longer ramping (up or down)
|
// We are no longer ramping (up or down)
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -496,10 +500,11 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:percent
|
icon: mdi:percent
|
||||||
accuracy_decimals: 0
|
accuracy_decimals: 0
|
||||||
update_interval: 1s # consider 200ms if you want fewer updates
|
update_interval: 2s # consider 200ms if you want fewer updates
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
return cv.is_on() ? (float) (int)(cv.get_brightness() * 100.0f + 0.5f) : 0.0f;
|
||||||
|
|
||||||
on_value:
|
on_value:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -526,18 +531,16 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:square-wave
|
icon: mdi:square-wave
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
update_interval: 1s
|
update_interval: 2s
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (!cv.is_on()) return 0.0f;
|
if (!cv.is_on()) return 0.0f;
|
||||||
const float lin = cv.get_brightness(); // 0..1 linear brightness
|
const float lin = cv.get_brightness();
|
||||||
const float gamma = atof("${led_gamma}"); // parse substitution string -> float
|
float pwm = powf(lin, id(led_gamma_f));
|
||||||
float pwm = powf(lin, gamma); // approx PWM duty after gamma
|
|
||||||
if (pwm < 0.0f) pwm = 0.0f;
|
if (pwm < 0.0f) pwm = 0.0f;
|
||||||
if (pwm > 1.0f) pwm = 1.0f;
|
if (pwm > 1.0f) pwm = 1.0f;
|
||||||
return pwm * 100.0f;
|
return pwm * 100.0f;
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# OUTPUT COMPONENT
|
# OUTPUT COMPONENT
|
||||||
# https://esphome.io/components/light/index.html
|
# https://esphome.io/components/light/index.html
|
||||||
@@ -572,6 +575,7 @@ light:
|
|||||||
|
|
||||||
# ON: publish state, track intent, arm watchdog if configured
|
# ON: publish state, track intent, arm watchdog if configured
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
|
- output.turn_on: green_led_out
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}/light/state"
|
topic: "${mqtt_local_status_topic}/light/state"
|
||||||
payload: "${mqtt_local_device_command_ON}"
|
payload: "${mqtt_local_device_command_ON}"
|
||||||
@@ -591,6 +595,7 @@ light:
|
|||||||
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
||||||
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
|
- output.turn_off: green_led_out
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return !id(booting);'
|
lambda: 'return !id(booting);'
|
||||||
@@ -611,13 +616,15 @@ light:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
const float cap = id(max_brightness_pct) / 100.0f;
|
const float cap = id(max_brightness_pct) / 100.0f;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (cv.is_on() && cv.get_brightness() > cap + 0.001f) {
|
if (!cv.is_on()) return;
|
||||||
auto call = id(mosfet_leds).make_call();
|
const float b = cv.get_brightness();
|
||||||
call.set_state(true);
|
if (b <= cap + 0.001f) return; // no call if already at/under cap
|
||||||
call.set_brightness(cap);
|
auto call = id(mosfet_leds).make_call();
|
||||||
call.set_transition_length(0);
|
call.set_state(true);
|
||||||
call.perform();
|
call.set_brightness(cap);
|
||||||
}
|
call.set_transition_length(0);
|
||||||
|
call.perform();
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# NUMBER COMPONENT
|
# NUMBER COMPONENT
|
||||||
@@ -779,7 +786,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at at least the floor without a visible "pop".
|
# Ensure we start at at least the floor without a visible "pop".
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -816,7 +822,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -831,7 +836,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at the floor cleanly.
|
# Ensure we start at the floor cleanly.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -874,7 +878,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -892,7 +895,6 @@ script:
|
|||||||
id(is_ramping) = true;
|
id(is_ramping) = true;
|
||||||
id(ramping_for_off) = true;
|
id(ramping_for_off) = true;
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||||
@@ -913,7 +915,6 @@ script:
|
|||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 150ms
|
transition_length: 150ms
|
||||||
- delay: 150ms
|
- delay: 150ms
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -973,5 +974,4 @@ script:
|
|||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 0s
|
transition_length: 0s
|
||||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
# (Removed: output.turn_off: green_led_out) # make sure LED is off if no ramp
|
||||||
|
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
# 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/
|
|
||||||
##############################################
|
|
||||||
#############################################
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Variable Substitutions
|
|
||||||
#############################################
|
|
||||||
substitutions:
|
|
||||||
devicename: "esp-leafbat"
|
|
||||||
friendly_name: "Nissan Leaf 12V Battery Monitor"
|
|
||||||
description_comment: "Nissan Leaf 12V Battery Monitor (when home)"
|
|
||||||
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
|
|
||||||
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-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" #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}
|
|
||||||
friendly_name: ${friendly_name}
|
|
||||||
comment: ${description_comment} #appears on the esphome page in HA
|
|
||||||
min_version: 2024.6.0
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# ESPHome Logging Enable
|
|
||||||
# https://esphome.io/components/logger.html
|
|
||||||
#############################################
|
|
||||||
logger:
|
|
||||||
level: INFO #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
|
|
||||||
|
|
||||||
#uart:
|
|
||||||
# id: uart_output
|
|
||||||
# tx_pin: GPIO12
|
|
||||||
# rx_pin: GPIO13
|
|
||||||
# baud_rate: 9600
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable the Home Assistant API
|
|
||||||
# https://esphome.io/components/api.html
|
|
||||||
#############################################
|
|
||||||
api:
|
|
||||||
encryption:
|
|
||||||
key: ${api_key}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# Enable Over the Air Update Capability
|
|
||||||
# https://esphome.io/components/ota.html?highlight=ota
|
|
||||||
#############################################
|
|
||||||
ota:
|
|
||||||
- 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: ${wifi_ssid}
|
|
||||||
password: ${wifi_password}
|
|
||||||
#power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode
|
|
||||||
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: ${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: ${web_server_username}
|
|
||||||
#password: ${web_server_password}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
# MQTT Monitoring
|
|
||||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
|
||||||
# MUST also have api enabled if you enable MQTT
|
|
||||||
#############################################
|
|
||||||
mqtt:
|
|
||||||
broker: ${mqtt_server}
|
|
||||||
topic_prefix: ${mqtt_topic}/${devicename}
|
|
||||||
username: ${mqtt_username}
|
|
||||||
password: ${mqtt_password}
|
|
||||||
discovery: False # enable entity discovery (true is default, we don't want two HA Instances)
|
|
||||||
|
|
||||||
# Availability Topic
|
|
||||||
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: ${mqtt_commandstopic}/${devicename}/deepsleep
|
|
||||||
payload: 'OFF'
|
|
||||||
then:
|
|
||||||
- deep_sleep.prevent: deep_sleep_1
|
|
||||||
- topic: ${mqtt_commandstopic}/${devicename}/deepsleep
|
|
||||||
payload: 'ON'
|
|
||||||
then:
|
|
||||||
- deep_sleep.enter: deep_sleep_1
|
|
||||||
|
|
||||||
########################################
|
|
||||||
# Deep Sleep
|
|
||||||
# https://esphome.io/components/deep_sleep.html
|
|
||||||
########################################
|
|
||||||
deep_sleep:
|
|
||||||
run_duration: 20s
|
|
||||||
sleep_duration: 5min
|
|
||||||
id: deep_sleep_1
|
|
||||||
|
|
||||||
#time:
|
|
||||||
# - platform: homeassistant
|
|
||||||
# id: ha_time
|
|
||||||
# timezone: Pacific/Auckland
|
|
||||||
|
|
||||||
#text_sensor:
|
|
||||||
# - platform: template
|
|
||||||
# name: "Current time"
|
|
||||||
# id: current_time
|
|
||||||
# lambda: return id(ha_time).now().strftime("%H%M");
|
|
||||||
# lambda: |-
|
|
||||||
# char str[17];
|
|
||||||
# time_t currTime = id(ha_time).now().timestamp;
|
|
||||||
# strftime(str, sizeof(str), "%Y-%m-%d %H:%M", localtime(&currTime));
|
|
||||||
# return { str };
|
|
||||||
# update_interval: ${update_time}
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
# MAIN SENSORS
|
|
||||||
#############################################
|
|
||||||
#############################################
|
|
||||||
sensor:
|
|
||||||
#Quality of Wifi in dBm
|
|
||||||
- platform: wifi_signal
|
|
||||||
name: "WiFi Signal"
|
|
||||||
id: wifi_strength
|
|
||||||
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"
|
|
||||||
id: battery_voltage
|
|
||||||
#mqtt_id: battery_voltage
|
|
||||||
update_interval: ${update_time}
|
|
||||||
retain: true #Retain this as you'll have no value between sleeps otherwise
|
|
||||||
# This set used a voltage divider with a 100k and a 4.7k R value
|
|
||||||
filters:
|
|
||||||
- multiply: 3.3 #D1 mini V divider, 3.3V -> 1V on esp8266
|
|
||||||
- calibrate_linear: #Read values with voltmeter and bench supply
|
|
||||||
- 0.72 -> 16.00
|
|
||||||
- 0.68 -> 15.00
|
|
||||||
- 0.63 -> 14.00
|
|
||||||
- 0.59 -> 13.00
|
|
||||||
- 0.55 -> 12.00
|
|
||||||
- 0.51 -> 11.00
|
|
||||||
- 0.45 -> 10.00
|
|
||||||
- 0.40 -> 09.00
|
|
||||||
- 0.36 -> 08.00
|
|
||||||
- 0.32 -> 07.00
|
|
||||||
- 0.28 -> 06.00
|
|
||||||
- 0.23 -> 05.00
|
|
||||||
# on_value:
|
|
||||||
# - logger.log:
|
|
||||||
# level: INFO
|
|
||||||
# format: "time,%s,battery,%.1f,wifi,%.1f"
|
|
||||||
# args: [ 'id(ha_time).now()', 'id(battery_voltage).state', 'id(wifi_strength).state' ]
|
|
||||||
|
|
||||||
# - uart.write:
|
|
||||||
# id: uart_output
|
|
||||||
# data: !lambda char buf[128];
|
|
||||||
# sprintf(buf, "%s", id(battery_voltage).state);
|
|
||||||
# std::string s = buf;
|
|
||||||
# return std::vector<unsigned char>( s.begin(), s.end() );
|
|
||||||
# - logger.log:
|
|
||||||
# level: INFO
|
|
||||||
# format: "time,%.1f,battery,%.1f,wifi,%.1f"
|
|
||||||
# args: [ 'id(sntp_time).now()', 'id(battery_voltage).state', 'id(wifi_strength).state' ]
|
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
##########################################################################################
|
||||||
|
##########################################################################################
|
||||||
|
# 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/
|
||||||
|
##########################################################################################
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
##########################################################################################
|
||||||
|
substitutions:
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Passwords & Secrets
|
||||||
|
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-leafbattery_ip
|
||||||
|
mqtt_command_main_topic: !secret mqtt_command_main_topic
|
||||||
|
mqtt_status_main_topic: !secret mqtt_status_main_topic
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# 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
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_device_name: "${device_name}"
|
||||||
|
local_static_ip_address: "${static_ip_address}"
|
||||||
|
local_ota_pass: "${ota_pass}"
|
||||||
|
|
||||||
|
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
#file: common/api_common_noencryption.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: "${api_key}"
|
||||||
|
|
||||||
|
#### MQTT ####
|
||||||
|
common_mqtt: !include
|
||||||
|
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
|
||||||
|
|
||||||
|
#### 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
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# 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
|
||||||
|
min_version: 2024.6.0
|
||||||
|
on_boot:
|
||||||
|
priority: 600
|
||||||
|
then:
|
||||||
|
# Default: do NOT deep sleep until explicitly enabled via MQTT
|
||||||
|
- deep_sleep.prevent: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep prevented by default on boot."
|
||||||
|
|
||||||
|
# Fail-safe: wait up to 30s for MQTT; if not connected, sleep longer (backoff)
|
||||||
|
- wait_until:
|
||||||
|
condition:
|
||||||
|
mqtt.connected:
|
||||||
|
timeout: 30s
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
not:
|
||||||
|
mqtt.connected:
|
||||||
|
then:
|
||||||
|
- 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
|
||||||
|
else:
|
||||||
|
- logger.log: "MQTT connected; awaiting '${mqtt_command_topic}/deepsleep' command."
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# 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
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# 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)
|
||||||
|
#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:
|
||||||
|
- platform: web_server # Uncomment if you want to be able to do OTA with the web interface
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# MQTT COMMANDS
|
||||||
|
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||||
|
##########################################################################################
|
||||||
|
mqtt:
|
||||||
|
# Availability Topic
|
||||||
|
birth_message:
|
||||||
|
topic: ${mqtt_status_topic}/availability
|
||||||
|
payload: online
|
||||||
|
will_message:
|
||||||
|
topic: ${mqtt_status_topic}/availability
|
||||||
|
payload: offline
|
||||||
|
|
||||||
|
# Control deep sleep over MQTT
|
||||||
|
on_message:
|
||||||
|
- topic: ${mqtt_command_topic}/deepsleep
|
||||||
|
payload: "ON"
|
||||||
|
then:
|
||||||
|
- deep_sleep.allow: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep ALLOWED via MQTT. Device will sleep when run_duration elapses."
|
||||||
|
|
||||||
|
- topic: ${mqtt_command_topic}/deepsleep
|
||||||
|
payload: "OFF"
|
||||||
|
then:
|
||||||
|
- deep_sleep.prevent: deep_sleep_1
|
||||||
|
- logger.log: "Deep sleep PREVENTED via MQTT."
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# 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
|
||||||
|
# https://esphome.io/components/sensor/
|
||||||
|
##########################################################################################
|
||||||
|
sensor:
|
||||||
|
- platform: adc
|
||||||
|
pin: A0
|
||||||
|
name: "Battery Voltage"
|
||||||
|
id: battery_voltage
|
||||||
|
update_interval: 4s
|
||||||
|
retain: true
|
||||||
|
filters:
|
||||||
|
- multiply: 3.3
|
||||||
|
- calibrate_linear:
|
||||||
|
- 0.72 -> 16.00
|
||||||
|
- 0.68 -> 15.00
|
||||||
|
- 0.63 -> 14.00
|
||||||
|
- 0.59 -> 13.00
|
||||||
|
- 0.55 -> 12.00
|
||||||
|
- 0.51 -> 11.00
|
||||||
|
- 0.45 -> 10.00
|
||||||
|
- 0.40 -> 09.00
|
||||||
|
- 0.36 -> 08.00
|
||||||
|
- 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
|
||||||
|
on_value:
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_status_topic}/batteryvoltage"
|
||||||
|
qos: 1
|
||||||
|
retain: true
|
||||||
|
payload: !lambda |-
|
||||||
|
char buf[10];
|
||||||
|
snprintf(buf, sizeof(buf), "%.2f", x);
|
||||||
|
return std::string(buf);
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# INTERVAL COMPONENT
|
||||||
|
##########################################################################################
|
||||||
|
interval:
|
||||||
|
- interval: 60s
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_status_topic}/batteryvoltage"
|
||||||
|
qos: 1
|
||||||
|
retain: true
|
||||||
|
payload: !lambda |-
|
||||||
|
const float v = id(battery_voltage).state; // current filtered state
|
||||||
|
char buf[10];
|
||||||
|
snprintf(buf, sizeof(buf), "%.2f", v);
|
||||||
|
return std::string(buf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -83,13 +83,13 @@ substitutions:
|
|||||||
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
||||||
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
||||||
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
||||||
pwm_frequency: "1000hz" # PWM output Frequency. High enough to avoid audible/visible artifacts
|
pwm_frequency: "1000" # PWM output Frequency in Hz. High enough to avoid audible/visible artifacts
|
||||||
|
|
||||||
# Device Specific GPIO (so we can easily update for other devices)
|
# Device Specific GPIO (so we can easily update for other devices)
|
||||||
device_status_led: GPIO02 # Can't really see if there is an LED
|
device_status_led: GPIO02
|
||||||
device_mosfet_out: GPIO12
|
device_mosfet_out: GPIO12
|
||||||
device_usr_button: GPIO04 # this is just a fake/safeish choice so it compiles with my generic yaml
|
device_usr_button: GPIO04 # if no button, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
device_fading_led: GPIO13 # this is just a fake/safeish choice so it compiles with my generic yaml
|
device_fading_led: GPIO13 # if no LED, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES: Included Common Packages
|
# PACKAGES: Included Common Packages
|
||||||
@@ -124,8 +124,8 @@ packages:
|
|||||||
|
|
||||||
#### DIAGNOSTICS Sensors ####
|
#### DIAGNOSTICS Sensors ####
|
||||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||||
#diag_more: !include common/include_more_diag_sensors.yaml
|
diag_more: !include common/include_more_diag_sensors.yaml
|
||||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -180,7 +180,7 @@ esphome:
|
|||||||
- lambda: 'id(booting) = false;'
|
- lambda: 'id(booting) = false;'
|
||||||
|
|
||||||
# NEW: force indicator OFF after boot logic
|
# NEW: force indicator OFF after boot logic
|
||||||
- output.turn_off: green_led_out
|
# (Removed: output.turn_off: green_led_out)
|
||||||
|
|
||||||
# Only if you want to play with build flags...
|
# Only if you want to play with build flags...
|
||||||
# platformio_options:
|
# platformio_options:
|
||||||
@@ -228,6 +228,11 @@ globals:
|
|||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "${max_on_default_hours}"
|
initial_value: "${max_on_default_hours}"
|
||||||
|
# Compile time Gamma
|
||||||
|
- id: led_gamma_f
|
||||||
|
type: float
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${led_gamma} # <-- numeric at compile time
|
||||||
|
|
||||||
# Default Fading Up Time (Selectable and will be retained)
|
# Default Fading Up Time (Selectable and will be retained)
|
||||||
- id: ramp_up_ms # fade-in when turned ON
|
- id: ramp_up_ms # fade-in when turned ON
|
||||||
@@ -389,7 +394,6 @@ button:
|
|||||||
# Stop any pending scripts (and their delayed actions)
|
# Stop any pending scripts (and their delayed actions)
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
// We are no longer ramping (up or down)
|
// We are no longer ramping (up or down)
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -485,10 +489,11 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:percent
|
icon: mdi:percent
|
||||||
accuracy_decimals: 0
|
accuracy_decimals: 0
|
||||||
update_interval: 1s # consider 200ms if you want fewer updates
|
update_interval: 2s # consider 200ms if you want fewer updates
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
return cv.is_on() ? (float) (int)(cv.get_brightness() * 100.0f + 0.5f) : 0.0f;
|
||||||
|
|
||||||
on_value:
|
on_value:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -515,18 +520,16 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:square-wave
|
icon: mdi:square-wave
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
update_interval: 1s
|
update_interval: 2s
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (!cv.is_on()) return 0.0f;
|
if (!cv.is_on()) return 0.0f;
|
||||||
const float lin = cv.get_brightness(); // 0..1 linear brightness
|
const float lin = cv.get_brightness();
|
||||||
const float gamma = atof("${led_gamma}"); // parse substitution string -> float
|
float pwm = powf(lin, id(led_gamma_f));
|
||||||
float pwm = powf(lin, gamma); // approx PWM duty after gamma
|
|
||||||
if (pwm < 0.0f) pwm = 0.0f;
|
if (pwm < 0.0f) pwm = 0.0f;
|
||||||
if (pwm > 1.0f) pwm = 1.0f;
|
if (pwm > 1.0f) pwm = 1.0f;
|
||||||
return pwm * 100.0f;
|
return pwm * 100.0f;
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# OUTPUT COMPONENT
|
# OUTPUT COMPONENT
|
||||||
# https://esphome.io/components/light/index.html
|
# https://esphome.io/components/light/index.html
|
||||||
@@ -561,6 +564,7 @@ light:
|
|||||||
|
|
||||||
# ON: publish state, track intent, arm watchdog if configured
|
# ON: publish state, track intent, arm watchdog if configured
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
|
- output.turn_on: green_led_out
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}/light/state"
|
topic: "${mqtt_local_status_topic}/light/state"
|
||||||
payload: "${mqtt_local_device_command_ON}"
|
payload: "${mqtt_local_device_command_ON}"
|
||||||
@@ -580,6 +584,7 @@ light:
|
|||||||
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
||||||
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
|
- output.turn_off: green_led_out
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return !id(booting);'
|
lambda: 'return !id(booting);'
|
||||||
@@ -600,13 +605,15 @@ light:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
const float cap = id(max_brightness_pct) / 100.0f;
|
const float cap = id(max_brightness_pct) / 100.0f;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (cv.is_on() && cv.get_brightness() > cap + 0.001f) {
|
if (!cv.is_on()) return;
|
||||||
auto call = id(mosfet_leds).make_call();
|
const float b = cv.get_brightness();
|
||||||
call.set_state(true);
|
if (b <= cap + 0.001f) return; // no call if already at/under cap
|
||||||
call.set_brightness(cap);
|
auto call = id(mosfet_leds).make_call();
|
||||||
call.set_transition_length(0);
|
call.set_state(true);
|
||||||
call.perform();
|
call.set_brightness(cap);
|
||||||
}
|
call.set_transition_length(0);
|
||||||
|
call.perform();
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# NUMBER COMPONENT
|
# NUMBER COMPONENT
|
||||||
@@ -768,7 +775,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at at least the floor without a visible "pop".
|
# Ensure we start at at least the floor without a visible "pop".
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -805,7 +811,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -820,7 +825,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at the floor cleanly.
|
# Ensure we start at the floor cleanly.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -863,7 +867,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -881,7 +884,6 @@ script:
|
|||||||
id(is_ramping) = true;
|
id(is_ramping) = true;
|
||||||
id(ramping_for_off) = true;
|
id(ramping_for_off) = true;
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||||
@@ -902,7 +904,6 @@ script:
|
|||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 150ms
|
transition_length: 150ms
|
||||||
- delay: 150ms
|
- delay: 150ms
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -962,5 +963,4 @@ script:
|
|||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 0s
|
transition_length: 0s
|
||||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
# (Removed: output.turn_off: green_led_out) # make sure LED is off if no ramp
|
||||||
|
|
||||||
@@ -83,18 +83,18 @@ substitutions:
|
|||||||
|
|
||||||
# Device Specific Settings
|
# Device Specific Settings
|
||||||
log_level: "NONE" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (default), VERBOSE, VERY_VERBOSE
|
log_level: "NONE" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (default), VERBOSE, VERY_VERBOSE
|
||||||
update_interval: "20s" # Update time for general sensors, etc.
|
update_interval: "30s" # Update time for general sensors, etc.
|
||||||
led_gamma: "1.2" # Gamma from 1.2-3 is sensible to normalise the LED fading vs PWM
|
led_gamma: "1.2" # Gamma from 1.2-3 is sensible to normalise the LED fading vs PWM
|
||||||
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
|
||||||
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
|
||||||
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
|
||||||
pwm_frequency: "1000hz" # PWM output Frequency. High enough to avoid audible/visible artifacts
|
pwm_frequency: "1000" # PWM output Frequency in Hz. High enough to avoid audible/visible artifacts
|
||||||
|
|
||||||
# Device Specific GPIO (so we can easily update for other devices)
|
# Device Specific GPIO (so we can easily update for other devices)
|
||||||
device_status_led: GPIO02
|
device_status_led: GPIO02
|
||||||
device_mosfet_out: GPIO04
|
device_mosfet_out: GPIO04
|
||||||
device_usr_button: GPIO12
|
device_usr_button: GPIO12 # if no button, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
device_fading_led: GPIO13
|
device_fading_led: GPIO13 # if no LED, this is just a fake/safeish choice so it compiles with the generic yaml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES: Included Common Packages
|
# PACKAGES: Included Common Packages
|
||||||
@@ -185,7 +185,7 @@ esphome:
|
|||||||
- lambda: 'id(booting) = false;'
|
- lambda: 'id(booting) = false;'
|
||||||
|
|
||||||
# NEW: force indicator OFF after boot logic
|
# NEW: force indicator OFF after boot logic
|
||||||
- output.turn_off: green_led_out
|
# (Removed: output.turn_off: green_led_out)
|
||||||
|
|
||||||
# Only if you want to play with build flags...
|
# Only if you want to play with build flags...
|
||||||
# platformio_options:
|
# platformio_options:
|
||||||
@@ -233,6 +233,11 @@ globals:
|
|||||||
type: int
|
type: int
|
||||||
restore_value: true
|
restore_value: true
|
||||||
initial_value: "${max_on_default_hours}"
|
initial_value: "${max_on_default_hours}"
|
||||||
|
# Compile time Gamma
|
||||||
|
- id: led_gamma_f
|
||||||
|
type: float
|
||||||
|
restore_value: false
|
||||||
|
initial_value: ${led_gamma} # <-- numeric at compile time
|
||||||
|
|
||||||
# Default Fading Up Time (Selectable and will be retained)
|
# Default Fading Up Time (Selectable and will be retained)
|
||||||
- id: ramp_up_ms # fade-in when turned ON
|
- id: ramp_up_ms # fade-in when turned ON
|
||||||
@@ -394,7 +399,6 @@ button:
|
|||||||
# Stop any pending scripts (and their delayed actions)
|
# Stop any pending scripts (and their delayed actions)
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
// We are no longer ramping (up or down)
|
// We are no longer ramping (up or down)
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -490,10 +494,11 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:percent
|
icon: mdi:percent
|
||||||
accuracy_decimals: 0
|
accuracy_decimals: 0
|
||||||
update_interval: 1s # consider 200ms if you want fewer updates
|
update_interval: 2s # consider 200ms if you want fewer updates
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
return cv.is_on() ? (float) (int)(cv.get_brightness() * 100.0f + 0.5f) : 0.0f;
|
||||||
|
|
||||||
on_value:
|
on_value:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -520,18 +525,16 @@ sensor:
|
|||||||
unit_of_measurement: "%"
|
unit_of_measurement: "%"
|
||||||
icon: mdi:square-wave
|
icon: mdi:square-wave
|
||||||
accuracy_decimals: 1
|
accuracy_decimals: 1
|
||||||
update_interval: 1s
|
update_interval: 2s
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (!cv.is_on()) return 0.0f;
|
if (!cv.is_on()) return 0.0f;
|
||||||
const float lin = cv.get_brightness(); // 0..1 linear brightness
|
const float lin = cv.get_brightness();
|
||||||
const float gamma = atof("${led_gamma}"); // parse substitution string -> float
|
float pwm = powf(lin, id(led_gamma_f));
|
||||||
float pwm = powf(lin, gamma); // approx PWM duty after gamma
|
|
||||||
if (pwm < 0.0f) pwm = 0.0f;
|
if (pwm < 0.0f) pwm = 0.0f;
|
||||||
if (pwm > 1.0f) pwm = 1.0f;
|
if (pwm > 1.0f) pwm = 1.0f;
|
||||||
return pwm * 100.0f;
|
return pwm * 100.0f;
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# OUTPUT COMPONENT
|
# OUTPUT COMPONENT
|
||||||
# https://esphome.io/components/light/index.html
|
# https://esphome.io/components/light/index.html
|
||||||
@@ -566,6 +569,7 @@ light:
|
|||||||
|
|
||||||
# ON: publish state, track intent, arm watchdog if configured
|
# ON: publish state, track intent, arm watchdog if configured
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
|
- output.turn_on: green_led_out
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}/light/state"
|
topic: "${mqtt_local_status_topic}/light/state"
|
||||||
payload: "${mqtt_local_device_command_ON}"
|
payload: "${mqtt_local_device_command_ON}"
|
||||||
@@ -585,6 +589,7 @@ light:
|
|||||||
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
# OFF: publish state, track intent, clear watchdog, and persist OFF so Mode 1 will not restore
|
||||||
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
# Guarded by booting flag so the automatic OFF at boot from ALWAYS_OFF does not zero persistence.
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
|
- output.turn_off: green_led_out
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return !id(booting);'
|
lambda: 'return !id(booting);'
|
||||||
@@ -605,13 +610,15 @@ light:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
const float cap = id(max_brightness_pct) / 100.0f;
|
const float cap = id(max_brightness_pct) / 100.0f;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
if (cv.is_on() && cv.get_brightness() > cap + 0.001f) {
|
if (!cv.is_on()) return;
|
||||||
auto call = id(mosfet_leds).make_call();
|
const float b = cv.get_brightness();
|
||||||
call.set_state(true);
|
if (b <= cap + 0.001f) return; // no call if already at/under cap
|
||||||
call.set_brightness(cap);
|
auto call = id(mosfet_leds).make_call();
|
||||||
call.set_transition_length(0);
|
call.set_state(true);
|
||||||
call.perform();
|
call.set_brightness(cap);
|
||||||
}
|
call.set_transition_length(0);
|
||||||
|
call.perform();
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# NUMBER COMPONENT
|
# NUMBER COMPONENT
|
||||||
@@ -773,7 +780,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at at least the floor without a visible "pop".
|
# Ensure we start at at least the floor without a visible "pop".
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -810,7 +816,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -825,7 +830,6 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: 'id(is_ramping) = true;'
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
# Ensure we start at the floor cleanly.
|
# Ensure we start at the floor cleanly.
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -868,7 +872,6 @@ script:
|
|||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -886,7 +889,6 @@ script:
|
|||||||
id(is_ramping) = true;
|
id(is_ramping) = true;
|
||||||
id(ramping_for_off) = true;
|
id(ramping_for_off) = true;
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- output.turn_on: green_led_out
|
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||||
@@ -907,7 +909,6 @@ script:
|
|||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 150ms
|
transition_length: 150ms
|
||||||
- delay: 150ms
|
- delay: 150ms
|
||||||
- output.turn_off: green_led_out
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
id(ramping_for_off) = false;
|
id(ramping_for_off) = false;
|
||||||
@@ -967,4 +968,4 @@ script:
|
|||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 0s
|
transition_length: 0s
|
||||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
# (Removed: output.turn_off: green_led_out) # make sure LED is off if no ramp
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,18 +30,20 @@ substitutions:
|
|||||||
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
static_ip_address: !secret esp-loungesouthleftswitch_ip
|
static_ip_address: !secret esp-loungesouthleftswitch_ip
|
||||||
#mqtt_local_command_main_topic: !secret mqtt_local_command_main_topic
|
mqtt_command_main_topic: !secret mqtt_command_main_topic
|
||||||
#mqtt_local_status_main_topic: !secret mqtt_local_status_main_topic
|
mqtt_status_main_topic: !secret mqtt_status_main_topic
|
||||||
|
|
||||||
# Device Settings
|
# Device Settings
|
||||||
#relay_icon: "mdi:lightbulb-group"
|
#relay_icon: "mdi:lightbulb-group"
|
||||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
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
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
# MQTT LOCAL Controls
|
# MQTT REMOTE Controls
|
||||||
#mqtt_device_name: "bedroom2-lights"
|
mqtt_remote_device_name: "garage-corridor-lights"
|
||||||
#mqtt_local_command_topic: "${mqtt_local_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
mqtt_remote_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device_name}"
|
||||||
#mqtt_local_status_topic: "${mqtt_local_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
mqtt_remote_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device_name}"
|
||||||
|
mqtt_remote_device_command_ON: "ON"
|
||||||
|
mqtt_remote_device_command_OFF: "OFF"
|
||||||
|
|
||||||
# Switch Naming
|
# Switch Naming
|
||||||
switch_1_name: "Wall Washer Left"
|
switch_1_name: "Wall Washer Left"
|
||||||
@@ -98,10 +100,6 @@ esphome:
|
|||||||
project:
|
project:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
#on_boot:
|
|
||||||
# priority: 200
|
|
||||||
# then:
|
|
||||||
# - switch.turn_on: Relay_2
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# ESP Platform and Framework
|
# ESP Platform and Framework
|
||||||
@@ -122,6 +120,12 @@ logger:
|
|||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: relay2_change_origin_remote
|
||||||
|
type: bool
|
||||||
|
restore_value: no
|
||||||
|
initial_value: "false"
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# STATUS LED
|
# STATUS LED
|
||||||
# https://esphome.io/components/status_led.html
|
# https://esphome.io/components/status_led.html
|
||||||
@@ -154,15 +158,38 @@ binary_sensor:
|
|||||||
on_press:
|
on_press:
|
||||||
- switch.toggle: Relay_2
|
- switch.toggle: Relay_2
|
||||||
|
|
||||||
# KS-811-2 is a double only
|
text_sensor:
|
||||||
# - platform: gpio
|
- platform: mqtt_subscribe
|
||||||
# pin:
|
id: remote2_status
|
||||||
# number: GPIO4
|
topic: "${mqtt_remote_status_topic}"
|
||||||
# mode: INPUT
|
on_value:
|
||||||
# inverted: True
|
then:
|
||||||
# name: "Button 3: ${switch_3_name}"
|
- if:
|
||||||
# on_press:
|
condition:
|
||||||
# - switch.toggle: Relay_3
|
lambda: |-
|
||||||
|
return x == "${mqtt_remote_device_command_ON}";
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
not:
|
||||||
|
switch.is_on: Relay_2
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(relay2_change_origin_remote) = true;
|
||||||
|
- switch.turn_on: Relay_2
|
||||||
|
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: |-
|
||||||
|
return x == "${mqtt_remote_device_command_OFF}";
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
switch.is_on: Relay_2
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(relay2_change_origin_remote) = true;
|
||||||
|
- switch.turn_off: Relay_2
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# SWITCH COMPONENT
|
# SWITCH COMPONENT
|
||||||
@@ -178,11 +205,24 @@ switch:
|
|||||||
name: "Relay 2: ${switch_2_name}"
|
name: "Relay 2: ${switch_2_name}"
|
||||||
pin: GPIO12
|
pin: GPIO12
|
||||||
id: Relay_2
|
id: Relay_2
|
||||||
|
on_turn_on:
|
||||||
# KS-811-2 is a double only
|
- if:
|
||||||
# - platform: gpio
|
condition:
|
||||||
# name: "Relay 3: ${switch_3_name}"
|
lambda: 'return !id(relay2_change_origin_remote);'
|
||||||
# pin: GPIO14
|
then:
|
||||||
# id: Relay_3
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_remote_command_topic}"
|
||||||
|
payload: "${mqtt_remote_device_command_ON}"
|
||||||
|
- lambda: 'id(relay2_change_origin_remote) = false;'
|
||||||
|
on_turn_off:
|
||||||
|
- if:
|
||||||
|
condition:
|
||||||
|
lambda: 'return !id(relay2_change_origin_remote);'
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_remote_command_topic}"
|
||||||
|
payload: "${mqtt_remote_device_command_OFF}"
|
||||||
|
- lambda: 'id(relay2_change_origin_remote) = false;'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ substitutions:
|
|||||||
|
|
||||||
# MQTT REMOTE Controls
|
# MQTT REMOTE Controls
|
||||||
mqtt_remote_device1_name: "stair-footerlights"
|
mqtt_remote_device1_name: "stair-footerlights"
|
||||||
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}/set"
|
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}"
|
||||||
#mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state"
|
#mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state"
|
||||||
mqtt_remote_device_command_ON: "ON"
|
mqtt_remote_device_command_ON: "ON"
|
||||||
mqtt_remote_device_command_OFF: "OFF"
|
mqtt_remote_device_command_OFF: "OFF"
|
||||||
|
|||||||
@@ -74,107 +74,120 @@ script:
|
|||||||
#####################################################################
|
#####################################################################
|
||||||
scene_settings:
|
scene_settings:
|
||||||
Bright:
|
Bright:
|
||||||
light.esp_lounge6chdimmer_couch_spots_left: 00
|
light.esp_lounge6chdimmer_couch_spots_left: 0
|
||||||
light.esp_lounge6chdimmer_couch_spots_right: 00
|
light.esp_lounge6chdimmer_couch_spots_right: 0
|
||||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 100 # Centre Downlights (x6, dimmable)
|
light.esp_lounge6chdimmer_lounge_downlights_centre: 100
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_south: 100 # South Downlights (x4, dimmable)
|
light.esp_lounge6chdimmer_lounge_downlights_south: 100
|
||||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 100 # Buttons in Rafters (x3, dimmable)
|
light.esp_lounge6chdimmer_lounge_rafter_buttons: 100
|
||||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: "on" # North Downlights (x2 over stairs, non dimmable)
|
switch.esp_loungemiddleswitch_relay_3_downlights_north: "on"
|
||||||
light.esp_breakfastbarleds_breakfast_bar_leds: 90
|
light.esp_breakfastbarleds_breakfast_bar_leds: 90
|
||||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 90
|
light.esp_loungecabinetleds2_lounge_cabinet_leds: 90
|
||||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 90
|
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 90
|
||||||
light.tasmo_h801_loungeled1_6180_a: 90
|
switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
||||||
light.tasmo_h801_loungeled1_6180_b: 90
|
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: "on"
|
||||||
switch.lounge_cupboard_dual_usb_xus09_l2: on
|
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: "on"
|
||||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: on # Back wall wallwasher Left
|
switch.tasmo_ks811t_0702_lounge_3c: "on"
|
||||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: on # Back wall wallwasher right
|
#switch.esp_loungenorthswitch_relay_1_main_lights: "on"
|
||||||
switch.tasmo_ks811t_0702_lounge_3c: on # North Downlights (x2 over stairs, non dimmable)
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_a_output_set_0_100: 100
|
||||||
switch.esp_loungenorthswitch_relay_1_main_lights: on # Single switch to hallway relay output (Pelmet LEDs)
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_b_output_set_0_100: 100
|
||||||
|
|
||||||
|
TV General:
|
||||||
|
light.esp_lounge6chdimmer_couch_spots_left: 60
|
||||||
|
light.esp_lounge6chdimmer_couch_spots_right: 60
|
||||||
|
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||||
|
light.esp_lounge6chdimmer_lounge_downlights_centre: 60
|
||||||
|
light.esp_lounge6chdimmer_lounge_downlights_south: 60
|
||||||
|
light.esp_lounge6chdimmer_lounge_rafter_buttons: 40
|
||||||
|
light.esp_breakfastbarleds_breakfast_bar_leds: 60
|
||||||
|
light.esp_loungecabinetleds2_lounge_cabinet_leds: 60
|
||||||
|
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 60
|
||||||
|
switch.esp_loungemiddleswitch_relay_3_downlights_north: "off" # non-dimmable pair
|
||||||
|
switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
||||||
|
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: "off"
|
||||||
|
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: "off"
|
||||||
|
#switch.esp_loungenorthswitch_relay_1_main_lights: "on"
|
||||||
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_a_output_set_0_100: 60
|
||||||
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_b_output_set_0_100: 60
|
||||||
|
|
||||||
Movie:
|
Movie:
|
||||||
#light.esp_lounge6chdimmer_couch_spots_left: 40
|
light.esp_lounge6chdimmer_couch_spots_left: 20
|
||||||
#light.esp_lounge6chdimmer_couch_spots_right: 40
|
light.esp_lounge6chdimmer_couch_spots_right: 20
|
||||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 20 # Centre Downlights (x6, dimmable)
|
light.esp_lounge6chdimmer_lounge_downlights_centre: 20
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_south: 20 # South Downlights (x4, dimmable)
|
light.esp_lounge6chdimmer_lounge_downlights_south: 20
|
||||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 20 # Buttons in Rafters (x3, dimmable)
|
light.esp_lounge6chdimmer_lounge_rafter_buttons: 20
|
||||||
light.esp_breakfastbarleds_breakfast_bar_leds: 40
|
light.esp_breakfastbarleds_breakfast_bar_leds: 40
|
||||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 40
|
light.esp_loungecabinetleds2_lounge_cabinet_leds: 40
|
||||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 40
|
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 40
|
||||||
light.tasmo_h801_loungeled1_6180_a: 60
|
switch.esp_loungemiddleswitch_relay_3_downlights_north: "off"
|
||||||
light.tasmo_h801_loungeled1_6180_b: 60
|
switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
||||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: off # North Downlights (x2 over stairs, non dimmable) switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: "off"
|
||||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: "off"
|
||||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
#switch.esp_loungenorthswitch_relay_1_main_lights: "on"
|
||||||
switch.esp_loungenorthswitch_relay_1_main_lights: on # Single switch to hallway relay output (Pelmet LEDs)
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_a_output_set_0_100: 40
|
||||||
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_b_output_set_0_100: 40
|
||||||
Night Light:
|
|
||||||
#light.esp_lounge6chdimmer_couch_spots_left: 40
|
|
||||||
#light.esp_lounge6chdimmer_couch_spots_right: 40
|
|
||||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 5 # Centre Downlights (x6, dimmable)
|
|
||||||
#light.esp_lounge6chdimmer_lounge_downlights_south: 20 # South Downlights (x4, dimmable)
|
|
||||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 5 # Buttons in Rafters (x3, dimmable)
|
|
||||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
|
||||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
|
||||||
|
|
||||||
Reading On/Off:
|
Reading On/Off:
|
||||||
light.esp_lounge6chdimmer_couch_spots_left: toggle_75
|
light.esp_lounge6chdimmer_couch_spots_left: "toggle_75"
|
||||||
light.esp_lounge6chdimmer_couch_spots_right: toggle_75
|
light.esp_lounge6chdimmer_couch_spots_right: "toggle_75"
|
||||||
#light.esp_lounge6chdimmer_dining_table_light: 60
|
#light.esp_lounge6chdimmer_dining_table_light: 60
|
||||||
#light.esp_lounge6chdimmer_lounge_downlights_centre: 45
|
#light.esp_lounge6chdimmer_lounge_downlights_centre: 45
|
||||||
#light.esp_lounge6chdimmer_lounge_downlights_south: 35
|
#light.esp_lounge6chdimmer_lounge_downlights_south: 35
|
||||||
#light.esp_lounge6chdimmer_lounge_rafter_buttons: 20
|
#light.esp_lounge6chdimmer_lounge_rafter_buttons: 20
|
||||||
#switch.tasmo_ks811t_0702_lounge_3c: on
|
#switch.tasmo_ks811t_0702_lounge_3c: "on"
|
||||||
|
|
||||||
|
Night Light:
|
||||||
|
#light.esp_lounge6chdimmer_couch_spots_left: 20
|
||||||
|
#light.esp_lounge6chdimmer_couch_spots_right: 20
|
||||||
|
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||||
|
light.esp_lounge6chdimmer_lounge_downlights_centre: 0
|
||||||
|
light.esp_lounge6chdimmer_lounge_downlights_south: 0
|
||||||
|
light.esp_lounge6chdimmer_lounge_rafter_buttons: 0
|
||||||
|
light.esp_breakfastbarleds_breakfast_bar_leds: 5
|
||||||
|
light.esp_loungecabinetleds2_lounge_cabinet_leds: 5
|
||||||
|
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 5
|
||||||
|
switch.esp_loungemiddleswitch_relay_3_downlights_north: "off"
|
||||||
|
switch.lounge_cupboard_dual_usb_xus09_l2: "off"
|
||||||
|
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: "off"
|
||||||
|
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: "off"
|
||||||
|
#switch.esp_loungenorthswitch_relay_1_main_lights: "on"
|
||||||
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_a_output_set_0_100: 5
|
||||||
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_b_output_set_0_100: 5
|
||||||
|
|
||||||
Warm Cozy:
|
Warm Cozy:
|
||||||
light.esp_lounge6chdimmer_couch_spots_left: 30
|
light.esp_lounge6chdimmer_couch_spots_left: 20
|
||||||
light.esp_lounge6chdimmer_couch_spots_right: 30
|
light.esp_lounge6chdimmer_couch_spots_right: 20
|
||||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 15
|
light.esp_lounge6chdimmer_lounge_rafter_buttons: 15
|
||||||
light.esp_breakfastbarleds_breakfast_bar_leds: 25
|
light.esp_breakfastbarleds_breakfast_bar_leds: 25
|
||||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 30
|
light.esp_loungecabinetleds2_lounge_cabinet_leds: 30
|
||||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 30
|
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 30
|
||||||
light.tasmo_h801_loungeled1_6180_a: 25
|
light.tasmo_h801_loungeled1_6180_a: 25
|
||||||
light.tasmo_h801_loungeled1_6180_b: 25
|
light.tasmo_h801_loungeled1_6180_b: 25
|
||||||
switch.lounge_cupboard_dual_usb_xus09_l2: on
|
switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
||||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: on # Back wall wallwasher Left
|
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: "on"
|
||||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: on # Back wall wallwasher right
|
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: "on"
|
||||||
|
#switch.esp_loungenorthswitch_relay_1_main_lights: "on"
|
||||||
TV General:
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_a_output_set_0_100: 20
|
||||||
light.esp_lounge6chdimmer_couch_spots_left: 50
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_b_output_set_0_100: 20
|
||||||
light.esp_lounge6chdimmer_couch_spots_right: 50
|
|
||||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 40 # Centre Downlights (x6, dimmable)
|
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_south: 40 # South Downlights (x4, dimmable)
|
|
||||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 40 # Buttons in Rafters (x3, dimmable)
|
|
||||||
light.esp_breakfastbarleds_breakfast_bar_leds: 60
|
|
||||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 60
|
|
||||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 60
|
|
||||||
light.tasmo_h801_loungeled1_6180_a: 60
|
|
||||||
light.tasmo_h801_loungeled1_6180_b: 60
|
|
||||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: off # North Downlights (x2 over stairs, non dimmable) switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
|
||||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
|
||||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
|
||||||
switch.esp_loungenorthswitch_relay_1_main_lights: on # Single switch to hallway relay output (Pelmet LEDs)
|
|
||||||
|
|
||||||
All Off:
|
All Off:
|
||||||
light.esp_lounge6chdimmer_couch_spots_left: 0
|
light.esp_lounge6chdimmer_couch_spots_left: 0
|
||||||
light.esp_lounge6chdimmer_couch_spots_right: 0
|
light.esp_lounge6chdimmer_couch_spots_right: 0
|
||||||
light.esp_lounge6chdimmer_dining_table_light: 0
|
light.esp_lounge6chdimmer_dining_table_light: 0
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 0 # Centre Downlights (x6, dimmable)
|
light.esp_lounge6chdimmer_lounge_downlights_centre: 0
|
||||||
light.esp_lounge6chdimmer_lounge_downlights_south: 0 # South Downlights (x4, dimmable)
|
light.esp_lounge6chdimmer_lounge_downlights_south: 0
|
||||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 0 # Buttons in Rafters (x3, dimmable)
|
light.esp_lounge6chdimmer_lounge_rafter_buttons: 0
|
||||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: "off" # North Downlights (x2 over stairs, non dimmable)
|
switch.esp_loungemiddleswitch_relay_3_downlights_north: "off"
|
||||||
light.esp_breakfastbarleds_breakfast_bar_leds: 0
|
light.esp_breakfastbarleds_breakfast_bar_leds: 0
|
||||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 0
|
light.esp_loungecabinetleds2_lounge_cabinet_leds: 0
|
||||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 0
|
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 0
|
||||||
light.tasmo_h801_loungeled1_6180_a: 0
|
switch.lounge_cupboard_dual_usb_xus09_l2: "off"
|
||||||
light.tasmo_h801_loungeled1_6180_b: 0
|
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: "off"
|
||||||
switch.lounge_cupboard_dual_usb_xus09_l2: off
|
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: "off"
|
||||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
#switch.esp_loungenorthswitch_relay_1_main_lights: "on"
|
||||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_a_output_set_0_100: 0
|
||||||
switch.esp_loungenorthswitch_relay_1_main_lights: off # Single switch to hallway relay output (Pelmet LEDs)
|
number.esp_loungepelmetleds2_lounge_pelmet_leds_b_output_set_0_100: 0
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@@ -202,8 +215,17 @@ script:
|
|||||||
is_toggle: "{{ (not is_num) and (vstr|lower).startswith('toggle') }}"
|
is_toggle: "{{ (not is_num) and (vstr|lower).startswith('toggle') }}"
|
||||||
toggle_pct: "{{ (vstr.split('_')|last)|int if ('_' in vstr) else 100 }}"
|
toggle_pct: "{{ (vstr.split('_')|last)|int if ('_' in vstr) else 100 }}"
|
||||||
currently_on: "{{ is_state(ent, 'on') }}"
|
currently_on: "{{ is_state(ent, 'on') }}"
|
||||||
|
is_number_ent: "{{ ent.startswith('number.') }}" # 🔹 NEW
|
||||||
|
|
||||||
- choose:
|
- choose:
|
||||||
|
# 0) Numbers: set numeric value (e.g. 0..100)
|
||||||
|
- conditions: "{{ is_number_ent and is_num }}" # 🔹 NEW
|
||||||
|
sequence:
|
||||||
|
- service: number.set_value
|
||||||
|
data:
|
||||||
|
entity_id: "{{ ent }}"
|
||||||
|
value: "{{ val|float }}"
|
||||||
|
|
||||||
# 1) Lights: toggle[_NN] -> if on turn off, else turn on to NN (default 100)
|
# 1) Lights: toggle[_NN] -> if on turn off, else turn on to NN (default 100)
|
||||||
- conditions: "{{ is_light and is_toggle }}"
|
- conditions: "{{ is_light and is_toggle }}"
|
||||||
sequence:
|
sequence:
|
||||||
|
|||||||
@@ -1,370 +0,0 @@
|
|||||||
rest:
|
|
||||||
scan_interval: 5
|
|
||||||
resource_template: "http://192.168.2.31:7125/server/files/metadata?filename={{ states(('sensor.3d_printer_current_print')) | urlencode }}"
|
|
||||||
sensor:
|
|
||||||
- name: printer_3d_file_metadata
|
|
||||||
unique_id: "192.168.2.315ec44d90-419c-419c-802d-d34071639c08"
|
|
||||||
json_attributes_path: "$.result"
|
|
||||||
json_attributes:
|
|
||||||
- layer_height
|
|
||||||
- object_height
|
|
||||||
- thumbnails
|
|
||||||
value_template: "OK"
|
|
||||||
|
|
||||||
#camera:
|
|
||||||
# Loading generic IP camera via configuration.yaml is deprecated, it will be automatically imported. Once you have confirmed correct operation, please remove 'generic' (IP camera) section(s) from configuration.yaml
|
|
||||||
# Directions in the README.md for how to add the Thumbnail now.
|
|
||||||
# - platform: generic
|
|
||||||
# name: "3D Printer Thumbnail"
|
|
||||||
# still_image_url: http://192.168.2.31:7125/server/files/gcodes/{{ states("sensor.3d_printer_object_thumbnails") }}
|
|
||||||
# verify_ssl: false
|
|
||||||
|
|
||||||
# This no longer works broken in current builds https://www.home-assistant.io/blog/2022/05/04/release-20225/#breaking-changes -> MJPEG IP Camera
|
|
||||||
# Directions in the README.md for how to add the MJPEG IP Camera now.
|
|
||||||
# - platform: mjpeg
|
|
||||||
# name: "3D Printer Camera"
|
|
||||||
# still_image_url: http://192.168.2.31/webcam/?action=snapshot
|
|
||||||
# mjpeg_url: http://192.168.2.31/webcam/?action=stream
|
|
||||||
# verify_ssl: false
|
|
||||||
|
|
||||||
rest_command:
|
|
||||||
3d_printer_emergency_stop:
|
|
||||||
url: "http://192.168.2.31:7125/printer/emergency_stop"
|
|
||||||
method: post
|
|
||||||
3d_printer_firmware_restart:
|
|
||||||
url: "http://192.168.2.31:7125/printer/firmware_restart"
|
|
||||||
method: post
|
|
||||||
3d_printer_cancel:
|
|
||||||
url: "http://192.168.2.31:7125/printer/print/cancel"
|
|
||||||
method: post
|
|
||||||
3d_printer_pause:
|
|
||||||
url: "http://192.168.2.31:7125/printer/print/pause"
|
|
||||||
method: post
|
|
||||||
3d_printer_resume:
|
|
||||||
url: "http://192.168.2.31:7125/printer/print/resume"
|
|
||||||
method: post
|
|
||||||
|
|
||||||
sensor:
|
|
||||||
- platform: rest
|
|
||||||
name: printer_3d_sensor
|
|
||||||
unique_id: "192.168.2.313a0c25fa-297d-4c19-b03c-ddf04840682b"
|
|
||||||
resource: "http://192.168.2.31:7125/printer/objects/query?heater_bed&extruder&print_stats&toolhead&display_status&virtual_sdcard&gcode_move&filament_motion_sensor%20btt_smart_filament&temperature_sensor%20Chamber_Temp"
|
|
||||||
json_attributes_path: "$.result.status"
|
|
||||||
json_attributes:
|
|
||||||
- heater_bed
|
|
||||||
- extruder
|
|
||||||
- print_stats
|
|
||||||
- toolhead
|
|
||||||
- display_status
|
|
||||||
- virtual_sdcard
|
|
||||||
- gcode_move
|
|
||||||
- "filament_motion_sensor btt_smart_filament_sensor"
|
|
||||||
- "temperature_sensor Chamber_Temp"
|
|
||||||
value_template: "OK"
|
|
||||||
force_update: true
|
|
||||||
scan_interval: 1
|
|
||||||
|
|
||||||
- platform: rest
|
|
||||||
name: printer_3d_info
|
|
||||||
unique_id: "192.168.2.311cba6677-02bd-4273-9083-b8301bf6943b"
|
|
||||||
scan_interval: 1
|
|
||||||
resource_template: "http://192.168.2.31:7125/printer/info"
|
|
||||||
json_attributes_path: "$.result"
|
|
||||||
json_attributes:
|
|
||||||
- state_message
|
|
||||||
- state
|
|
||||||
value_template: "OK"
|
|
||||||
|
|
||||||
- platform: rest
|
|
||||||
name: printer_3d_server
|
|
||||||
unique_id: "192.168.2.311cba6677-02bd-4273-9083-b8301bf6949"
|
|
||||||
scan_interval: 1
|
|
||||||
resource_template: "http://192.168.2.31:7125/server/database/item?namespace=mainsail&key=general"
|
|
||||||
json_attributes_path: "$.result.value"
|
|
||||||
json_attributes:
|
|
||||||
- printername
|
|
||||||
value_template: "OK"
|
|
||||||
|
|
||||||
template:
|
|
||||||
- binary_sensor:
|
|
||||||
- name: 3d_printer_filament
|
|
||||||
unique_id: "192.168.2.315ce32fc9-5e95-49e7-80e7-bfdd2cf1d1fd"
|
|
||||||
device_class: motion
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["filament_switch_sensor Filament"]["filament_detected"] }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:printer-3d-nozzle-alert
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Filament Detected"
|
|
||||||
- sensor:
|
|
||||||
- name: 3d_printer_printername
|
|
||||||
unique_id: "192.168.2.313a0f3144-a801-422f-adb6-e2ed35796074"
|
|
||||||
state: '{{ states.sensor.printer_3d_server.attributes["printername"]}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_server'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:printer-3d
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Printer Name"
|
|
||||||
- name: 3d_printer_chamber_temp
|
|
||||||
unique_id: "192.168.2.31167e5dec-719c-42d3-9560-4f177573f741"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["temperature_sensor Chamber_Temp"]["temperature"] | float(0) | round(1) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "°C"
|
|
||||||
icon: mdi:thermometer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Chamber Actual"
|
|
||||||
- name: 3d_printer_hotend_target
|
|
||||||
unique_id: "192.168.2.31167e5dec-719c-42d3-9560-4f177573f740"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["extruder"]["target"] | float(0) | round(1) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "°C"
|
|
||||||
icon: mdi:thermometer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Hotend Target"
|
|
||||||
- name: 3d_printer_hotend_actual
|
|
||||||
unique_id: "192.168.2.317c2593fb-a7dd-4ed7-a865-2e4dddddbb40"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["extruder"]["temperature"] | float(0) | round(1) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "°C"
|
|
||||||
icon: mdi:thermometer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Hotend Actual"
|
|
||||||
- name: 3d_printer_hotend_power
|
|
||||||
unique_id: "192.168.2.31c57a1e35-92fa-403e-b3cf-ec1e97ef94cf"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["extruder"]["power"] | float(0) | round(3) * 100}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "%"
|
|
||||||
icon: mdi:flash
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Hotend Power"
|
|
||||||
- name: 3d_printer_bed_target
|
|
||||||
unique_id: "192.168.2.31eadec415-c281-4814-8fba-17c6c42670ec"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["heater_bed"]["target"] | float(0) | round(1) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "°C"
|
|
||||||
icon: mdi:thermometer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Bed Target"
|
|
||||||
- name: 3d_printer_bed_actual
|
|
||||||
unique_id: "192.168.2.31cb33503c-c5d4-4e06-b79b-c1cd64ca2d7a"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["heater_bed"]["temperature"] | float(0) | round(1) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "°C"
|
|
||||||
icon: mdi:thermometer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Bed Actual"
|
|
||||||
- name: 3d_printer_bed_power
|
|
||||||
unique_id: "192.168.2.31abb2fc5b-8173-4131-a942-fb11e30f4efa"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["heater_bed"]["power"] | float(0) | round(3) * 100 }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "%"
|
|
||||||
icon: mdi:flash
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Bed Power"
|
|
||||||
- name: 3d_printer_state
|
|
||||||
unique_id: "192.168.2.31758ce84c-3210-4f29-b6b3-38139180de96"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["print_stats"]["state"] }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: >
|
|
||||||
{% set val = states.sensor.printer_3d_sensor.attributes["print_stats"]["state"] %}
|
|
||||||
{% if val == 'standby' %}
|
|
||||||
mdi:sleep
|
|
||||||
{% elif val == 'error' %}
|
|
||||||
mdi:alert-circle
|
|
||||||
{% elif val == 'printing' %}
|
|
||||||
mdi:printer-3d-nozzle
|
|
||||||
{% elif val == 'paused' %}
|
|
||||||
mdi:pause-circle
|
|
||||||
{% elif val == 'complete' %}
|
|
||||||
mdi:printer-3d
|
|
||||||
{% else %}
|
|
||||||
mdi:help-circle
|
|
||||||
{% endif %}
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Printer State"
|
|
||||||
- name: 3d_printer_current_print
|
|
||||||
unique_id: "192.168.2.313a0f3144-a801-422f-adb6-e2ed35796072"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["print_stats"]["filename"]}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:file
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Current Print"
|
|
||||||
- name: 3d_printer_current_progress
|
|
||||||
unique_id: "192.168.2.318ec7163b-be00-4a10-8051-48cf9a260a29"
|
|
||||||
state: '{{ ((states.sensor.printer_3d_sensor.attributes["display_status"]["progress"])*100) | round(0, "floor") }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "%"
|
|
||||||
icon: mdi:progress-clock
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Progress"
|
|
||||||
- name: 3d_printer_print_time
|
|
||||||
unique_id: "192.168.2.31e1ac0fac-e8ba-4e05-8fa0-c8d8076f9f63"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["print_stats"]["print_duration"] |timestamp_custom("%H:%M:%S", 0)}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:camera-timer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Time Elapsed"
|
|
||||||
- name: 3d_printer_time_remaining
|
|
||||||
unique_id: "192.168.2.31e12c8def-5ebe-43a4-9f75-605a0c46fc0f"
|
|
||||||
state: '{{ (((states.sensor.printer_3d_sensor.attributes["print_stats"]["print_duration"]/states.sensor.printer_3d_sensor.attributes["display_status"]["progress"]- states.sensor.printer_3d_sensor.attributes["print_stats"]["print_duration"]) if states.sensor.printer_3d_sensor.attributes["display_status"]["progress"]>0 else 0)) | timestamp_custom("%H:%M:%S", 0)}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:timer-sand
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Time Remaining"
|
|
||||||
- name: 3d_printer_eta
|
|
||||||
unique_id: "192.168.2.31a2b57068-9a32-4d2c-8cc9-57d2389a9082"
|
|
||||||
state: '{{ (as_timestamp(now())+((states.sensor.printer_3d_sensor.attributes["print_stats"]["print_duration"]/states.sensor.printer_3d_sensor.attributes["display_status"]["progress"]- states.sensor.printer_3d_sensor.attributes["print_stats"]["print_duration"]) if states.sensor.printer_3d_sensor.attributes["display_status"]["progress"]>0 else 0)) | timestamp_custom("%H:%M:%S", 1)}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:av-timer
|
|
||||||
attributes:
|
|
||||||
friendly_name: "ETA"
|
|
||||||
- name: 3d_printer_message
|
|
||||||
unique_id: "192.168.2.310c418c0d-e59e-4d4e-aa11-8fae53df58f8"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["display_status"]["message"]}}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:message-cog
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Message"
|
|
||||||
- name: 3d_printer_layer_height
|
|
||||||
unique_id: "192.168.2.316cca455d-c327-4567-b886-4d7f99714265"
|
|
||||||
state: '{{ states.sensor.printer_3d_file_metadata.attributes["layer_height"] | float(0) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_file_metadata'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "mm"
|
|
||||||
icon: mdi:arrow-collapse-down
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Layer Height"
|
|
||||||
- name: 3d_printer_object_height
|
|
||||||
unique_id: "192.168.2.316d6d9dc0-9a02-4ce4-a797-c84b42e011a6"
|
|
||||||
state: '{{ (states.sensor.printer_3d_file_metadata.attributes["object_height"] | float(0)) - (states.sensor.printer_3d_file_metadata.attributes["layer_height"] | float(0)) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_file_metadata'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "mm"
|
|
||||||
icon: mdi:arrow-expand-vertical
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Object Height"
|
|
||||||
- name: 3d_printer_current_height
|
|
||||||
unique_id: "192.168.2.31d440e568-d4d1-4b3f-85c4-fdacd68c0e1a"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes["gcode_move"]["gcode_position"][2] | float(0) | round(2) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
unit_of_measurement: "mm"
|
|
||||||
icon: mdi:arrow-collapse-down
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Current Height"
|
|
||||||
- name: 3d_printer_current_layer
|
|
||||||
unique_id: "192.168.2.316a77acc1-8134-4354-b2f6-390adab81993"
|
|
||||||
state: '{{ (states("sensor.3d_printer_current_height")|float(0) / states("sensor.3d_printer_layer_height")|float(0))|round(0) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.3d_printer_current_height','sensor.3d_printer_layer_height'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:counter
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Current Layer"
|
|
||||||
- name: 3d_printer_total_layers
|
|
||||||
unique_id: "192.168.2.3153cfe906-28ec-44cd-926a-b08ffb8766e5"
|
|
||||||
state: '{{ (states("sensor.3d_printer_object_height")|float(0) / states("sensor.3d_printer_layer_height")|float(0))|round(0) }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.3d_printer_object_height','sensor.3d_printer_layer_height'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:counter
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Total Layer"
|
|
||||||
- name: 3d_printer_actual_layer
|
|
||||||
unique_id: "192.168.2.31167e5dec-719c-42d3-9560-4f177573f742"
|
|
||||||
state: '{{ states.sensor.printer_3d_sensor.attributes.print_stats["info"]["current_layer"] }} / {{ states.sensor.printer_3d_sensor.attributes.print_stats["info"]["total_layer"] }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_sensor'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:layers-triple
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Actual Layer"
|
|
||||||
- name: 3d_printer_object_thumbnails
|
|
||||||
unique_id: "192.168.2.3159b37837-b751-4d31-98c2-516a52edf833"
|
|
||||||
state: >
|
|
||||||
{% set dir = states('sensor.3d_printer_current_print') %}
|
|
||||||
{% set thumb = state_attr('sensor.printer_3d_file_metadata','thumbnails') %}
|
|
||||||
{% set img = (thumb | last).relative_path if thumb else 'not available' %}
|
|
||||||
{{ (dir.split('/')[:-1] + [img]) | join('/') }}
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_file_metadata'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:image
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Object Thumbnails"
|
|
||||||
- name: 3d_printer_state_message
|
|
||||||
unique_id: "192.168.2.319a5184c9-ac5b-44a9-a691-2b67c243d197"
|
|
||||||
state: '{{ states.sensor.printer_3d_info.attributes["state_message"] }}'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.printer_3d_info'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:message-cog
|
|
||||||
attributes:
|
|
||||||
friendly_name: "State Message"
|
|
||||||
- name: 3d_printer_heaters_power
|
|
||||||
unique_id: "192.168.2.313988e9be-c910-4634-8205-38d53170d5a5"
|
|
||||||
state: '{{ states("sensor.3d_printer_bed_power")|float(0) | round(1) }}% / {{ states("sensor.3d_printer_hotend_power")|float(0) | round(1) }}%'
|
|
||||||
availability: >
|
|
||||||
{% set items = ['sensor.3d_printer_bed_power','sensor.3d_printer_hotend_power'] %}
|
|
||||||
{{ expand(items)|rejectattr('state','in',['unknown','unavailable'])
|
|
||||||
|list|count == items|count }}
|
|
||||||
icon: mdi:meter-electric-outline
|
|
||||||
attributes:
|
|
||||||
friendly_name: "Bed and Nozzle Power"
|
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
###############################################################################
|
||||||
|
# PACKAGE: OpenHASP Thermostat (MQTT-only, all BUTTON objects)
|
||||||
|
# NODE/TOPIC ROOT: hasp/openhasp_1/
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
input_number:
|
||||||
|
lounge_setpoint:
|
||||||
|
name: Lounge Setpoint
|
||||||
|
min: 10
|
||||||
|
max: 30
|
||||||
|
step: 0.5
|
||||||
|
mode: box
|
||||||
|
unit_of_measurement: "C"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# AUTOMATIONS
|
||||||
|
###############################################################################
|
||||||
|
automation:
|
||||||
|
# --- PUSH LABEL TEXTS (on buttons) ----------------------------------------
|
||||||
|
- id: hasp_temp_to_btn_text
|
||||||
|
alias: "HASP: update temp (p1b1.text)"
|
||||||
|
mode: queued
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: sensor.lounge_inside_temperature
|
||||||
|
action:
|
||||||
|
- service: mqtt.publish
|
||||||
|
data:
|
||||||
|
topic: "hasp/openhasp_1/command/p1b1.text"
|
||||||
|
payload: "{{ states('sensor.lounge_inside_temperature')|float(0)|round(1) }} C"
|
||||||
|
|
||||||
|
- id: hasp_setpoint_to_btn_text
|
||||||
|
alias: "HASP: update setpoint (p1b2.text)"
|
||||||
|
mode: queued
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_number.lounge_setpoint
|
||||||
|
action:
|
||||||
|
- service: mqtt.publish
|
||||||
|
data:
|
||||||
|
topic: "hasp/openhasp_1/command/p1b2.text"
|
||||||
|
payload: "Set: {{ states('input_number.lounge_setpoint')|float(0)|round(1) }} C"
|
||||||
|
|
||||||
|
- id: hasp_heater_status_to_btn_text
|
||||||
|
alias: "HASP: update heater status (p1b5.text)"
|
||||||
|
mode: queued
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: switch.lounge_heater
|
||||||
|
action:
|
||||||
|
- service: mqtt.publish
|
||||||
|
data:
|
||||||
|
topic: "hasp/openhasp_1/command/p1b5.text"
|
||||||
|
payload: >
|
||||||
|
{% if is_state('sensor.gas_heater_operating','ON') %}
|
||||||
|
HEAT ON
|
||||||
|
{% else %}
|
||||||
|
HEAT OFF
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# --- BUTTON HANDLING FROM THE PLATE (listens on /state/) ------------------
|
||||||
|
- id: hasp_btn_up_increment
|
||||||
|
alias: "HASP: p1b3 up -> increment setpoint"
|
||||||
|
mode: queued
|
||||||
|
trigger:
|
||||||
|
- platform: mqtt
|
||||||
|
topic: "hasp/openhasp_1/state/p1b4"
|
||||||
|
condition:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.payload_json.event|default('') == 'up' }}"
|
||||||
|
action:
|
||||||
|
- service: input_number.increment
|
||||||
|
target:
|
||||||
|
entity_id: input_number.lounge_setpoint
|
||||||
|
|
||||||
|
- id: hasp_btn_down_decrement
|
||||||
|
alias: "HASP: p1b4 up -> decrement setpoint"
|
||||||
|
mode: queued
|
||||||
|
trigger:
|
||||||
|
- platform: mqtt
|
||||||
|
topic: "hasp/openhasp_1/state/p1b3"
|
||||||
|
condition:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ trigger.payload_json.event|default('') == 'up' }}"
|
||||||
|
action:
|
||||||
|
- service: input_number.decrement
|
||||||
|
target:
|
||||||
|
entity_id: input_number.lounge_setpoint
|
||||||
|
|
||||||
|
# --- PUSH INITIAL VALUES ON HA START / PANEL ONLINE -----------------------
|
||||||
|
- id: hasp_push_on_ha_start
|
||||||
|
alias: "HASP: push texts on HA start"
|
||||||
|
trigger:
|
||||||
|
- platform: homeassistant
|
||||||
|
event: start
|
||||||
|
action:
|
||||||
|
- service: script.hasp_push_all_texts
|
||||||
|
|
||||||
|
- id: hasp_push_on_plate_birth
|
||||||
|
alias: "HASP: push texts on panel birth"
|
||||||
|
trigger:
|
||||||
|
- platform: mqtt
|
||||||
|
topic: "hasp/openhasp_1/state"
|
||||||
|
action:
|
||||||
|
- service: script.hasp_push_all_texts
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# SCRIPT: Push all texts to buttons
|
||||||
|
###############################################################################
|
||||||
|
script:
|
||||||
|
hasp_push_all_texts:
|
||||||
|
alias: "HASP: push all texts"
|
||||||
|
mode: queued
|
||||||
|
sequence:
|
||||||
|
- service: mqtt.publish
|
||||||
|
data:
|
||||||
|
topic: "hasp/openhasp_1/command/p1b1.text"
|
||||||
|
payload: "{{ states('sensor.lounge_inside_temperature')|float(0)|round(1) }} C"
|
||||||
|
- service: mqtt.publish
|
||||||
|
data:
|
||||||
|
topic: "hasp/openhasp_1/command/p1b2.text"
|
||||||
|
payload: "Set: {{ states('input_number.lounge_setpoint')|float(0)|round(1) }} C"
|
||||||
|
- service: mqtt.publish
|
||||||
|
data:
|
||||||
|
topic: "hasp/openhasp_1/command/p1b5.text"
|
||||||
|
payload: >
|
||||||
|
{% if is_state('sensor.gas_heater_operating','ON') %}
|
||||||
|
HEAT ON
|
||||||
|
{% else %}
|
||||||
|
HEAT OFF
|
||||||
|
{% endif %}
|
||||||
Reference in New Issue
Block a user