Updated sthome-ut8.yaml making set_heat_indicators script a little bit more generic

This commit is contained in:
Chris Stuurman 2026-01-29 13:41:28 +02:00
parent 6611e6c32f
commit c19a547f58
2 changed files with 14 additions and 18 deletions

View File

@ -1,9 +0,0 @@
# this is just a simple test device setup that's used to compile and test the examples
esphome:
name: custom_components_test
esp32:
board: esp32dev
framework:
type: esp-idf

View File

@ -18,6 +18,8 @@ substitutions:
friendly_name: "sthome-ut8" friendly_name: "sthome-ut8"
MAX_SCHOOL_HOLIDAY_PERIODS: 12 MAX_SCHOOL_HOLIDAY_PERIODS: 12
BATTERY_INFO_TIMEOUT: 30 # 30 sec timeout BATTERY_INFO_TIMEOUT: 30 # 30 sec timeout
GEYSER_HEAT_IND_MIN: 20
GEYSER_HEAT_IND_MAX: 70
esphome: esphome:
name: "${name}" name: "${name}"
@ -3309,19 +3311,22 @@ script:
- id: set_heat_indicators - id: set_heat_indicators
parameters: parameters:
temp_bottom: double low_value: double
temp_top: double high_value: double
then: then:
- lambda: |- - lambda: |-
double led_on = 1.0; double led_on = 1.0;
int led_count = 8; int led_count = 8;
double min_temp = 30.0; double min_value = ${GEYSER_HEAT_IND_MIN};
double max_temp = 70.0; double max_value = ${GEYSER_HEAT_IND_MAX};
double step_size = (max_temp - min_temp) / led_count; if(low_value < min_value) {
double bottom_point = (temp_bottom - min_temp) / step_size; low_value = min_value;
}
double step_size = (max_value - min_value) / led_count;
double bottom_point = (low_value - min_value) / step_size;
int led_bot = static_cast<int>(std::trunc(bottom_point)); int led_bot = static_cast<int>(std::trunc(bottom_point));
double led_bot_int = 1.0 + led_bot - bottom_point; double led_bot_int = 1.0 + led_bot - bottom_point;
double top_point = (temp_top - min_temp) / step_size; double top_point = (high_value - min_value) / step_size;
int led_top = static_cast<int>(std::trunc(top_point)); int led_top = static_cast<int>(std::trunc(top_point));
double led_top_int = top_point - led_top; double led_top_int = top_point - led_top;
double led_0 = 0; double led_0 = 0;
@ -3401,8 +3406,8 @@ script:
id(led_geyser_temp4).turn_on().set_brightness(led_4).perform(); id(led_geyser_temp4).turn_on().set_brightness(led_4).perform();
id(led_geyser_temp5).turn_on().set_brightness(led_5).perform(); id(led_geyser_temp5).turn_on().set_brightness(led_5).perform();
id(led_geyser_temp6).turn_on().set_brightness(led_6).perform(); id(led_geyser_temp6).turn_on().set_brightness(led_6).perform();
id(led_geyser_temp7).turn_on().set_brightness(led_7).perform(); id(led_geyser_temp7).turn_on().set_brightness(led_7).perform();
//ESP_LOGI("geyser","bot: %f, top: %f 0: %0.2f 1: %0.2f 2: %0.2f 3: %0.2f 4: %0.2f 5: %0.2f 6: %0.2f 7: %0.2f ", temp_bottom, temp_top, led_0, led_1, led_2, led_3, led_4, led_5, led_6, led_7); //ESP_LOGI("geyser","bot: %f, top: %f 0: %0.2f 1: %0.2f 2: %0.2f 3: %0.2f 4: %0.2f 5: %0.2f 6: %0.2f 7: %0.2f ", low_value, high_value, led_0, led_1, led_2, led_3, led_4, led_5, led_6, led_7);
# do at 1 second intervals - check if geyser is on, and switch off if required # do at 1 second intervals - check if geyser is on, and switch off if required
- id: reset_geyser_relay - id: reset_geyser_relay