defaules in substitutions now V1.2

This commit is contained in:
root
2025-08-21 20:01:39 +12:00
parent c76ca83932
commit c73e41496d
3 changed files with 78 additions and 24 deletions

View File

@@ -67,9 +67,29 @@ text_sensor:
- platform: template - platform: template
name: "Last Reset Reason" name: "Last Reset Reason"
update_interval: 30s update_interval: 30s
lambda: |-
return { ESP.getResetReason().c_str() };
entity_category: diagnostic entity_category: diagnostic
lambda: |-
#if defined(USE_ESP8266)
return { ESP.getResetReason().c_str() };
#elif defined(USE_ESP32)
auto r = esp_reset_reason();
switch (r) {
case ESP_RST_POWERON: return { "Power-on" };
case ESP_RST_EXT: return { "External pin" };
case ESP_RST_SW: return { "Software reset" };
case ESP_RST_PANIC: return { "Exception/Panic" };
case ESP_RST_INT_WDT: return { "Interrupt WDT" };
case ESP_RST_TASK_WDT: return { "Task WDT" };
case ESP_RST_WDT: return { "Other WDT" };
case ESP_RST_DEEPSLEEP: return { "Deep sleep wake" };
case ESP_RST_BROWNOUT: return { "Brownout" };
case ESP_RST_SDIO: return { "SDIO" };
default: return { "Unknown" };
}
#else
return { "Unknown" };
#endif
################################################################################################### ###################################################################################################
# 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

View File

@@ -5,6 +5,7 @@
# https://devices.esphome.io/devices/Sinilink-XY-VFMS # https://devices.esphome.io/devices/Sinilink-XY-VFMS
# Repo: https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-downstairskitchleds.yaml # Repo: https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-downstairskitchleds.yaml
# #
# V1.2 - 2025-08-21 Added some defaults to "Device Specific settings" in substitutions & a PWM % View
# V1.1 - 2025-08-18 Full tidyup as general purpose LED strip controller # V1.1 - 2025-08-18 Full tidyup as general purpose LED strip controller
# V1.0 - 2025-08-17 First Setup (and replacement of Tasmota) # V1.0 - 2025-08-17 First Setup (and replacement of Tasmota)
# #
@@ -17,7 +18,7 @@
# GPIO13 Green LED (We'll use this to display fading status) # GPIO13 Green LED (We'll use this to display fading status)
# #
# ------------------------------------------ # ------------------------------------------
# OPERATION (as at V1.1) # OPERATION (as at V1.2)
# ------------------------------------------ # ------------------------------------------
# 1. General Purpose LED controller # 1. General Purpose LED controller
# 2. Designed for a Sinilink XY-VFMS board that has a mosfet output and supposedly will handle # 2. Designed for a Sinilink XY-VFMS board that has a mosfet output and supposedly will handle
@@ -45,7 +46,7 @@
# - A fade up/fade down switch # - A fade up/fade down switch
# - Normal on/off switch (quick ramp up/down) # - Normal on/off switch (quick ramp up/down)
# - Setting for fade up and fade times (0-60 seconds) # - Setting for fade up and fade times (0-60 seconds)
# - Output display of % PWM output # - Output display of % output (before gamma), and the PWM % output (after gamma)
# - Ability to set output to any value (1-100, but respects min/max) # - Ability to set output to any value (1-100, but respects min/max)
# - Default has a bunch of device diagnostic in the PACKAGE included (Sensors_Common) # - Default has a bunch of device diagnostic in the PACKAGE included (Sensors_Common)
# #
@@ -65,7 +66,7 @@ substitutions:
# Project Naming # Project Naming
project_name: "Sinilink.XY-WFMS" # Project Details project_name: "Sinilink.XY-WFMS" # Project Details
project_version: "v1.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version project_version: "v1.2" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
# Passwords & Secrets # Passwords & Secrets
api_key: !secret esp-api_key api_key: !secret esp-api_key
@@ -74,10 +75,6 @@ substitutions:
mqtt_local_command_main_topic: !secret mqtt_local_command_main_topic mqtt_local_command_main_topic: !secret mqtt_local_command_main_topic
mqtt_local_status_main_topic: !secret mqtt_local_status_main_topic mqtt_local_status_main_topic: !secret mqtt_local_status_main_topic
# Device Settings
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
update_interval: "20s" # update time for for general sensors etc
# MQTT LOCAL Controls # MQTT LOCAL Controls
mqtt_local_device_name: "downstairskitchen-pantryleds" mqtt_local_device_name: "downstairskitchen-pantryleds"
mqtt_local_command_topic: "${mqtt_local_command_main_topic}/${mqtt_local_device_name}" # Topic we will use to command this locally without HA mqtt_local_command_topic: "${mqtt_local_command_main_topic}/${mqtt_local_device_name}" # Topic we will use to command this locally without HA
@@ -85,17 +82,13 @@ substitutions:
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 # Device Specific Settings
#mqtt_remote_device_name: "downstairskitchen-pantryleds" log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
#mqtt_remote_device_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device_name}/light/set" update_interval: "20s" # update time for for general sensors etc
#mqtt_remote_device_command1: "+" led_gamma: "1.2" # Gamma from 1.2 - 3 is sensible to normalise the lED fading vs PWM
#mqtt_remote_device_command2: "-" minimum_led_output: "1" # % If at this value or below, we'll switch it completely off
#mqtt_remote_device_command3: "0" maximum_led_output: "90" # % Maximum output, it is sometimes nice to limit the output for longevity or aesthetic
#mqtt_local_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device_name}/speed/state" # Topic we will use to view status locally without HA
# Button Naming & Icons
# Switch/Relay Naming & Icons
########################################################################################## ##########################################################################################
# PACKAGES: Included Common Packages # PACKAGES: Included Common Packages
@@ -207,8 +200,8 @@ esp8266:
board: esp01_1m board: esp01_1m
restore_from_flash: true # restore some values on reboot restore_from_flash: true # restore some values on reboot
preferences: #preferences:
flash_write_interval: 5min # flash_write_interval: 5min
mdns: mdns:
disabled: false # Disabling will make the build file smaller (and it is still available via static IP) disabled: false # Disabling will make the build file smaller (and it is still available via static IP)
@@ -222,12 +215,12 @@ globals:
- id: min_brightness_pct - id: min_brightness_pct
type: int type: int
restore_value: true restore_value: true
initial_value: '3' # start/finish at X% initial_value: "${minimum_led_output}" # start/finish at X%
# Maximum Brightness % for LEDs (should never go beyond this) # Maximum Brightness % for LEDs (should never go beyond this)
- id: max_brightness_pct - id: max_brightness_pct
type: int type: int
restore_value: false restore_value: false
initial_value: '90' # hard cap; never exceed this initial_value: "${maximum_led_output}" # hard cap; never exceed this
# 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
type: int type: int
@@ -481,6 +474,23 @@ sensor:
id(led_output_set_pct).publish_state(pos_i); id(led_output_set_pct).publish_state(pos_i);
} }
} }
- platform: template
id: mosfet_output_pwm_pct
name: "${friendly_name} Output PWM (%)"
unit_of_measurement: "%"
icon: mdi:square-wave
accuracy_decimals: 1
update_interval: 100ms
lambda: |-
const auto &cv = id(mosfet_leds).current_values;
if (!cv.is_on()) return 0.0f;
const float lin = cv.get_brightness(); // 0..1 (linear)
const float gamma = ${led_gamma}; // from substitutions
float pwm = powf(lin, gamma); // approximate PWM duty after gamma
if (pwm < 0.0f) pwm = 0.0f;
if (pwm > 1.0f) pwm = 1.0f;
return pwm * 100.0f;
########################################################################################## ##########################################################################################
# OUTPUT COMPONENT # OUTPUT COMPONENT
@@ -512,7 +522,7 @@ light:
restore_mode: RESTORE_DEFAULT_OFF restore_mode: RESTORE_DEFAULT_OFF
default_transition_length: 2s default_transition_length: 2s
icon: mdi:led-strip-variant icon: mdi:led-strip-variant
gamma_correct: 1.2 gamma_correct: "${led_gamma}"
on_turn_on: on_turn_on:
- mqtt.publish: - mqtt.publish:
topic: "${mqtt_local_status_topic}/light/state" topic: "${mqtt_local_status_topic}/light/state"

View File

@@ -0,0 +1,24 @@
binary_sensor:
- platform: rest
name: Node-RED Panda Up
resource: http://192.168.3.200:1880/healthz
method: GET
device_class: connectivity
value_template: "{{ value_json.status == 'ok' }}"
scan_interval: 30
mqtt:
binary_sensor:
- name: "Node-RED Panda Up"
unique_id: "nodered_myhost_up"
state_topic: "nodered/panda/status"
payload_on: "online"
payload_off: "offline"
device_class: connectivity
qos: 1
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:1880/healthz"]
interval: 30s
timeout: 3s
retries: 3