mcu-trainer: training state in input_boolean.training, one start/stop toggle, status from automation.training

This commit is contained in:
randy committed 2026-12-03 23:59:10 +01:00
1 parent 9a158bab19
commit 6591b47c01
1 file changed
+25 -34
+25 -34
View File
@@ -25,6 +25,9 @@ substitutions:
light_workbench: light.mcu_basement_2_workbench_light light_workbench: light.mcu_basement_2_workbench_light
light_exercise: light.exercise_room light_exercise: light.exercise_room
fan: light.trainer_fan_exercise_room_fan fan: light.trainer_fan_exercise_room_fan
# Home Assistant: the training state and the automation that runs the lights and the fan from it
training: input_boolean.training
training_automation: automation.training
# Pages (480x320, navigation bar at the bottom): # Pages (480x320, navigation bar at the bottom):
# clock, lights, training, fan, stopwatch, status # clock, lights, training, fan, stopwatch, status
@@ -145,6 +148,11 @@ packet_transport:
- name: mcu-trainer-ant - name: mcu-trainer-ant
binary_sensor: binary_sensor:
- platform: homeassistant
id: training_on
entity_id: ${training}
on_state:
- script.execute: update_training_status
- platform: homeassistant - platform: homeassistant
id: basement_light id: basement_light
entity_id: ${light_basement} entity_id: ${light_basement}
@@ -456,14 +464,8 @@ text_sensor:
value: !lambda return *parse_number<float>(x); value: !lambda return *parse_number<float>(x);
# a running automation (e.g. its delay) has current > 0 # a running automation (e.g. its delay) has current > 0
- platform: homeassistant - platform: homeassistant
id: training_start_running id: training_running
entity_id: automation.zwift_enable_fan entity_id: ${training_automation}
attribute: current
on_value:
- script.execute: update_training_status
- platform: homeassistant
id: training_stop_running
entity_id: automation.zwift_disable_fan
attribute: current attribute: current
on_value: on_value:
- script.execute: update_training_status - script.execute: update_training_status
@@ -518,14 +520,17 @@ script:
- id: update_training_status - id: update_training_status
then: then:
- lambda: |-
const bool on = id(training_on).state;
lv_label_set_text(id(training_btn_label), on ? "Stop" : "Štart");
lv_obj_set_style_bg_color(id(training_btn), lv_color_hex(on ? 0xB71C1C : 0x1E7D32), LV_PART_MAIN);
- lvgl.label.update: - lvgl.label.update:
id: training_status_label id: training_status_label
text: !lambda |- text: !lambda |-
if (id(training_start_running).state != "0" && !id(training_start_running).state.empty()) const bool running = !id(training_running).state.empty() && id(training_running).state != "0";
return std::string("Tréning sa spúšťa, ventilátor sa zapne o 10 min"); if (id(training_on).state)
if (id(training_stop_running).state != "0" && !id(training_stop_running).state.empty()) return std::string(running ? "Tréning beží, ventilátor sa zapne o 10 min" : "Tréning beží");
return std::string("Tréning sa ukončuje, ventilátor sa vypne o 2 min"); return std::string(running ? "Tréning skončil, ventilátor sa vypne o 2 min" : "");
return std::string("");
- id: update_stopwatch - id: update_stopwatch
then: then:
@@ -814,42 +819,28 @@ lvgl:
entity_id: ${light_exercise} entity_id: ${light_exercise}
color_temp_kelvin: !lambda return (int) x; color_temp_kelvin: !lambda return (int) x;
# 3: training start / stop # 3: training start / stop, one toggle showing input_boolean.training
- id: training_page - id: training_page
pad_all: 10 pad_all: 10
widgets: widgets:
- button: - button:
align: TOP_LEFT id: training_btn
align: TOP_MID
y: 10 y: 10
width: 222 width: 460
height: 150 height: 150
bg_color: 0x1E7D32 bg_color: 0x1E7D32
widgets: widgets:
- label: - label:
id: training_btn_label
align: CENTER align: CENTER
text_font: font_button text_font: font_button
text: "Štart" text: "Štart"
on_click: on_click:
- homeassistant.action: - homeassistant.action:
action: automation.trigger action: input_boolean.toggle
data: data:
entity_id: automation.zwift_enable_fan entity_id: ${training}
- button:
align: TOP_RIGHT
y: 10
width: 222
height: 150
bg_color: 0xB71C1C
widgets:
- label:
align: CENTER
text_font: font_button
text: "Stop"
on_click:
- homeassistant.action:
action: automation.trigger
data:
entity_id: automation.zwift_disable_fan
- label: - label:
id: training_status_label id: training_status_label
align: TOP_MID align: TOP_MID