mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
mcu-trainer: training state in input_boolean.training, one start/stop toggle, status from automation.training
This commit is contained in:
1 parent
9a158bab19
commit
6591b47c01
1 file changed
+25
-34
+25
-34
@@ -25,6 +25,9 @@ substitutions:
|
||||
light_workbench: light.mcu_basement_2_workbench_light
|
||||
light_exercise: light.exercise_room
|
||||
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):
|
||||
# clock, lights, training, fan, stopwatch, status
|
||||
@@ -145,6 +148,11 @@ packet_transport:
|
||||
- name: mcu-trainer-ant
|
||||
|
||||
binary_sensor:
|
||||
- platform: homeassistant
|
||||
id: training_on
|
||||
entity_id: ${training}
|
||||
on_state:
|
||||
- script.execute: update_training_status
|
||||
- platform: homeassistant
|
||||
id: basement_light
|
||||
entity_id: ${light_basement}
|
||||
@@ -456,14 +464,8 @@ text_sensor:
|
||||
value: !lambda return *parse_number<float>(x);
|
||||
# a running automation (e.g. its delay) has current > 0
|
||||
- platform: homeassistant
|
||||
id: training_start_running
|
||||
entity_id: automation.zwift_enable_fan
|
||||
attribute: current
|
||||
on_value:
|
||||
- script.execute: update_training_status
|
||||
- platform: homeassistant
|
||||
id: training_stop_running
|
||||
entity_id: automation.zwift_disable_fan
|
||||
id: training_running
|
||||
entity_id: ${training_automation}
|
||||
attribute: current
|
||||
on_value:
|
||||
- script.execute: update_training_status
|
||||
@@ -518,14 +520,17 @@ script:
|
||||
|
||||
- id: update_training_status
|
||||
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:
|
||||
id: training_status_label
|
||||
text: !lambda |-
|
||||
if (id(training_start_running).state != "0" && !id(training_start_running).state.empty())
|
||||
return std::string("Tréning sa spúšťa, ventilátor sa zapne o 10 min");
|
||||
if (id(training_stop_running).state != "0" && !id(training_stop_running).state.empty())
|
||||
return std::string("Tréning sa ukončuje, ventilátor sa vypne o 2 min");
|
||||
return std::string("");
|
||||
const bool running = !id(training_running).state.empty() && id(training_running).state != "0";
|
||||
if (id(training_on).state)
|
||||
return std::string(running ? "Tréning beží, ventilátor sa zapne o 10 min" : "Tréning beží");
|
||||
return std::string(running ? "Tréning skončil, ventilátor sa vypne o 2 min" : "");
|
||||
|
||||
- id: update_stopwatch
|
||||
then:
|
||||
@@ -814,42 +819,28 @@ lvgl:
|
||||
entity_id: ${light_exercise}
|
||||
color_temp_kelvin: !lambda return (int) x;
|
||||
|
||||
# 3: training start / stop
|
||||
# 3: training start / stop, one toggle showing input_boolean.training
|
||||
- id: training_page
|
||||
pad_all: 10
|
||||
widgets:
|
||||
- button:
|
||||
align: TOP_LEFT
|
||||
id: training_btn
|
||||
align: TOP_MID
|
||||
y: 10
|
||||
width: 222
|
||||
width: 460
|
||||
height: 150
|
||||
bg_color: 0x1E7D32
|
||||
widgets:
|
||||
- label:
|
||||
id: training_btn_label
|
||||
align: CENTER
|
||||
text_font: font_button
|
||||
text: "Štart"
|
||||
on_click:
|
||||
- homeassistant.action:
|
||||
action: automation.trigger
|
||||
action: input_boolean.toggle
|
||||
data:
|
||||
entity_id: automation.zwift_enable_fan
|
||||
- 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
|
||||
entity_id: ${training}
|
||||
- label:
|
||||
id: training_status_label
|
||||
align: TOP_MID
|
||||
|
||||
Reference in new issue
Block a user