From 4ff90ea60a9367ba7bd93bd3ebb275c4b164e7c9 Mon Sep 17 00:00:00 2001 From: ESPHome Device Builder Date: Mon, 20 Jul 2026 19:59:40 +1200 Subject: [PATCH] Edit esp-breakfastbarleds.yaml --- esphome/esp-breakfastbarleds.yaml | 84 +++++++++++++++---------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/esphome/esp-breakfastbarleds.yaml b/esphome/esp-breakfastbarleds.yaml index da74da5..f21c8ab 100644 --- a/esphome/esp-breakfastbarleds.yaml +++ b/esphome/esp-breakfastbarleds.yaml @@ -6,6 +6,7 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-breakfastbarleds.yaml #:########################################################################################:# # VERSIONS: +# V2.1 2026-07-20 Simplified local MQTT command and status topics to the device root # V2.0 2025-09-15 A bunch of fixes and made it more standard across my devices # V1.0 2025-08-17 First setup (and replacement of Tasmota) #:########################################################################################:# @@ -47,10 +48,10 @@ #:########################################################################################:# # MQTT COMMANDS: # Local MQTT light control: -# - ${mqtt_local_command_topic}/light/set -> ON,OFF +# - ${mqtt_local_command_topic} -> ON,OFF # # Local MQTT light status: -# - ${mqtt_local_status_topic}/light/state -> ON,OFF +# - ${mqtt_local_status_topic} -> ON,OFF #:########################################################################################:# # OFFLINE NOTES: # a) Home Assistant OFFLINE, but Network and MQTT ONLINE @@ -80,7 +81,7 @@ substitutions: # Project Naming project_name: "Magichome Single Colour V1.1 LED Controller.Generic ESP8266" # Manufacturer before the dot, device after the dot. - project_version: "v2.0" # Project version denotes release of the YAML file, allowing checking of deployed vs latest version + project_version: "v2.1" # Project version denotes release of the YAML file, allowing checking of deployed vs latest version # Passwords & Secrets (Unfortunately, you can't use substitutions inside secret names) api_key: !secret esp-api_key @@ -130,8 +131,7 @@ packages: local_current_ip_address: "${current_ip_address}" #### HOME ASSISTANT API (choose encryption or no encryption options) #### - common_api: !include - #file: common/api_common.yaml + common_api: !include #file: common/api_common.yaml file: common/api_common_noencryption.yaml vars: local_api_key: "${api_key}" @@ -178,32 +178,32 @@ esphome: # Mode 0: Fade up to full (obeys fade settings; no on/off flicker) - if: condition: - lambda: 'return id(restart_mode) == 0;' + lambda: "return id(restart_mode) == 0;" then: - - lambda: 'id(ramp_switch_target_on) = true;' + - lambda: "id(ramp_switch_target_on) = true;" - script.execute: ramp_on_script # Mode 1: Restore Brightness (deferred to avoid races) - if: condition: - lambda: 'return id(restart_mode) == 1;' + lambda: "return id(restart_mode) == 1;" then: - script.execute: deferred_restore_brightness # Mode 2: Remain Off (no blip; stays off) - if: condition: - lambda: 'return id(restart_mode) == 2;' + lambda: "return id(restart_mode) == 2;" then: - script.stop: ramp_on_script - script.stop: ramp_off_script - - lambda: 'id(ramp_switch_target_on) = false;' + - lambda: "id(ramp_switch_target_on) = false;" - light.turn_off: id: mosfet_leds transition_length: 0s # Boot complete: allow OFF handlers again - - lambda: 'id(booting) = false;' + - lambda: "id(booting) = false;" #:########################################################################################:# # ESP PLATFORM AND FRAMEWORK: @@ -345,13 +345,13 @@ status_led: mqtt: on_message: # Light control to ramp up - - topic: "${mqtt_local_command_topic}/light/set" + - topic: "${mqtt_local_command_topic}" payload: "${mqtt_local_device_command_ON}" then: - switch.turn_on: mosfet_ramp_switch # Light control to ramp down - - topic: "${mqtt_local_command_topic}/light/set" + - topic: "${mqtt_local_command_topic}" payload: "${mqtt_local_device_command_OFF}" then: - switch.turn_off: mosfet_ramp_switch @@ -482,7 +482,7 @@ binary_sensor: on_press: - if: condition: - lambda: 'return id(ramp_switch_target_on);' + lambda: "return id(ramp_switch_target_on);" then: # Target is currently ON -> press should go OFF (start ramp-down) - lambda: |- @@ -584,7 +584,7 @@ light: on_turn_on: - output.turn_on: green_led_out - mqtt.publish: - topic: "${mqtt_local_status_topic}/light/state" + topic: "${mqtt_local_status_topic}" payload: "${mqtt_local_device_command_ON}" retain: true - lambda: |- @@ -595,7 +595,7 @@ light: - script.stop: max_on_watchdog - if: condition: - lambda: 'return id(max_on_hours) > 0;' + lambda: "return id(max_on_hours) > 0;" then: - script.execute: max_on_watchdog @@ -605,13 +605,13 @@ light: - output.turn_off: green_led_out - if: condition: - lambda: 'return !id(booting);' + lambda: "return !id(booting);" then: - mqtt.publish: - topic: "${mqtt_local_status_topic}/light/state" + topic: "${mqtt_local_status_topic}" payload: "${mqtt_local_device_command_OFF}" retain: true - - lambda: 'id(ramp_switch_target_on) = false;' + - lambda: "id(ramp_switch_target_on) = false;" - script.stop: max_on_watchdog - lambda: |- id(last_brightness_pct) = 0.0f; @@ -699,9 +699,9 @@ number: set_action: - if: condition: - lambda: 'return x <= 0.0f;' + lambda: "return x <= 0.0f;" then: - - lambda: 'id(suppress_slider_sync) = true;' + - lambda: "id(suppress_slider_sync) = true;" - script.stop: ramp_on_script - script.stop: ramp_off_script - light.turn_off: @@ -713,7 +713,7 @@ number: id(last_brightness_pct) = 0.0f; id(last_set_pos) = 0; - delay: 400ms - - lambda: 'id(suppress_slider_sync) = false;' + - lambda: "id(suppress_slider_sync) = false;" else: - lambda: |- id(suppress_slider_sync) = true; @@ -744,7 +744,7 @@ number: if (out_pct > maxp) out_pct = maxp; id(last_brightness_pct) = out_pct; - delay: 400ms - - lambda: 'id(suppress_slider_sync) = false;' + - lambda: "id(suppress_slider_sync) = false;" - platform: template id: cfg_max_on_hours @@ -767,12 +767,12 @@ number: id(cfg_max_on_hours).publish_state((float) hrs); - if: condition: - lambda: 'return id(mosfet_leds).current_values.is_on();' + lambda: "return id(mosfet_leds).current_values.is_on();" then: - script.stop: max_on_watchdog - if: condition: - lambda: 'return id(max_on_hours) > 0;' + lambda: "return id(max_on_hours) > 0;" then: - script.execute: max_on_watchdog @@ -785,7 +785,7 @@ script: - id: ramp_on_script mode: restart then: - - lambda: 'id(is_ramping) = true;' + - lambda: "id(is_ramping) = true;" - script.stop: ramp_off_script # Ensure we start at at least the floor without a visible "pop". @@ -798,13 +798,13 @@ script: then: - light.turn_on: id: mosfet_leds - brightness: !lambda 'return id(min_brightness_pct) / 100.0f;' + brightness: !lambda "return id(min_brightness_pct) / 100.0f;" transition_length: 80ms # Ramp from current (>= floor) to cap over a fraction of ramp_up_ms. - light.turn_on: id: mosfet_leds - brightness: !lambda 'return id(max_brightness_pct) / 100.0f;' + brightness: !lambda "return id(max_brightness_pct) / 100.0f;" transition_length: !lambda |- const auto &cv = id(mosfet_leds).current_values; const float floor = id(min_brightness_pct) / 100.0f; @@ -825,7 +825,7 @@ script: id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac); 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);" - lambda: |- id(is_ramping) = false; const auto &cv = id(mosfet_leds).current_values; @@ -838,7 +838,7 @@ script: - id: ramp_to_target_script mode: restart then: - - lambda: 'id(is_ramping) = true;' + - lambda: "id(is_ramping) = true;" - script.stop: ramp_off_script # Ensure we start at the floor cleanly. @@ -851,7 +851,7 @@ script: then: - light.turn_on: id: mosfet_leds - brightness: !lambda 'return id(min_brightness_pct) / 100.0f;' + brightness: !lambda "return id(min_brightness_pct) / 100.0f;" transition_length: 80ms # Ramp from current (>= floor) to restore_target_pct over a fraction of ramp_up_ms. @@ -884,7 +884,7 @@ script: id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac); 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);" - lambda: |- id(is_ramping) = false; const auto &cv = id(mosfet_leds).current_values; @@ -904,7 +904,7 @@ script: - light.turn_on: id: mosfet_leds - brightness: !lambda 'return id(min_brightness_pct) / 100.0f;' + brightness: !lambda "return id(min_brightness_pct) / 100.0f;" transition_length: !lambda |- const auto &cv = id(mosfet_leds).current_values; const float floor = id(min_brightness_pct) / 100.0f; @@ -918,7 +918,7 @@ script: id(last_ramp_ms) = (int) (id(ramp_down_ms) * frac); 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);" - light.turn_off: id: mosfet_leds transition_length: 150ms @@ -935,12 +935,12 @@ script: then: - if: condition: - lambda: 'return id(max_on_hours) > 0;' + lambda: "return id(max_on_hours) > 0;" then: - - delay: !lambda 'return (uint32_t) (id(max_on_hours) * 3600000UL);' + - delay: !lambda "return (uint32_t) (id(max_on_hours) * 3600000UL);" - if: condition: - lambda: 'return id(mosfet_leds).current_values.is_on();' + lambda: "return id(mosfet_leds).current_values.is_on();" then: - lambda: |- id(ramp_switch_target_on) = false; @@ -967,18 +967,18 @@ script: - if: condition: - lambda: 'return id(restore_target_pct) > 0.5f;' + lambda: "return id(restore_target_pct) > 0.5f;" then: - lambda: |- id(ramp_switch_target_on) = true; id(suppress_slider_sync) = true; - script.stop: ramp_off_script - script.execute: ramp_to_target_script - - delay: !lambda 'return (uint32_t) id(last_ramp_ms);' - - lambda: 'id(suppress_slider_sync) = false;' + - delay: !lambda "return (uint32_t) id(last_ramp_ms);" + - lambda: "id(suppress_slider_sync) = false;" else: # Exact last was 0 -> remain OFF - - lambda: 'id(ramp_switch_target_on) = false;' + - lambda: "id(ramp_switch_target_on) = false;" - light.turn_off: id: mosfet_leds - transition_length: 0s \ No newline at end of file + transition_length: 0s