Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Removed status indicator, ensure display is ready before updating #17

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ sprinkler:
on_turn_on:
- lambda: |-
#ifdef HAS_DISPLAY
id(${display_id}).show_page(${display_page_when_active});
id(${display_backlight_id}).turn_on();
if (${display_id}->is_ready()) {
${display_id}->show_page(${display_page_when_active});
}
${display_backlight_id}->turn_on();
#endif
- light.turn_on: ${led_id}
on_turn_off:
Expand All @@ -31,7 +33,7 @@ sprinkler:
- light.turn_off: ${led_id}
- lambda: |-
#ifdef HAS_DISPLAY
id(${display_backlight_id}).turn_off();
${display_backlight_id}->turn_off();
#endif
auto_advance_switch: "Lawn sprinklers Auto Advance"
standby_switch:
Expand Down Expand Up @@ -111,8 +113,10 @@ sprinkler:
on_turn_on:
- lambda: |-
#ifdef HAS_DISPLAY
id(${display_id}).show_page(${display_page_when_active});
id(${display_backlight_id}).turn_on();
if (${display_id}->is_ready()) {
${display_id}->show_page(${display_page_when_active});
}
${display_backlight_id}->turn_on();
#endif
- light.turn_on: ${led_id}
on_turn_off:
Expand All @@ -127,7 +131,7 @@ sprinkler:
- light.turn_off: ${led_id}
- lambda: |-
#ifdef HAS_DISPLAY
id(${display_backlight_id}).turn_off();
${display_backlight_id}->turn_off();
#endif
auto_advance_switch: "Flowerbed sprinklers Auto Advance"
standby_switch:
Expand Down
12 changes: 7 additions & 5 deletions display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ display:
// Day of week and time
it.strftime(
84, 0, primary, TextAlign::TOP_RIGHT, "%a %H:%M",
id(${rtc_id}).now()
${rtc_id}->now()
);

// Symbol indicating if a client is connected over API
Expand All @@ -116,10 +116,11 @@ display:
);

// Run time remaining
#ifdef HAS_SCHEDULE
auto time_remaining =
max(
id(lawn_sprinklers).time_remaining_active_valve().value_or(0),
id(flowerbed_sprinklers).time_remaining_active_valve().value_or(0)
lawn_sprinklers->time_remaining_active_valve().value_or(0),
flowerbed_sprinklers->time_remaining_active_valve().value_or(0)
);

if (time_remaining > 0) {
Expand All @@ -139,9 +140,9 @@ display:
it.print(0, 12, material_small, TextAlign::TOP_LEFT, "\U0000e089");

auto lawn_next_schedule =
id(lawn_schedule).get_next_schedule();
lawn_schedule->get_next_schedule();
auto flowerbed_next_schedule =
id(flowerbed_schedule).get_next_schedule();
flowerbed_schedule->get_next_schedule();

if (!lawn_next_schedule.has_value()
&& !flowerbed_next_schedule.has_value()) {
Expand All @@ -163,6 +164,7 @@ display:
);
}
}
#endif

- id: display_page2
lambda: |-
Expand Down
5 changes: 0 additions & 5 deletions indicators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,3 @@ light:
return;
};
id(${led_id}).turn_on();

status_led:
pin:
number: LED
inverted: true
2 changes: 1 addition & 1 deletion main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ substitutions:
packages:
outputs: !include outputs.yaml
inputs: !include inputs.yaml
schedule: !include schedule.yaml
schedule: !include schedule.yaml # Optional
display: !include display.yaml # Optional
indicators: !include indicators.yaml
controllers: !include controllers.yaml
Expand Down
8 changes: 6 additions & 2 deletions script_rain_water_tank_sensors_action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
id(lawn_sprinklers_standby_switch).turn_on();

#ifdef HAS_DISPLAY
id(${display_id}).update();
if (${display_id}->is_ready()) {
${display_id}->update();
}
#endif

// Any active condition above is terminating, i.e. if one sensor is active
Expand Down Expand Up @@ -86,7 +88,9 @@
#endif

#ifdef HAS_DISPLAY
id(${display_id}).update();
if (${display_id}->is_ready()) {
${display_id}->update();
}
#endif

// Preprocessor macros lack scope so undefine the macro for another script
Expand Down
8 changes: 6 additions & 2 deletions script_refill_tank.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ if:
- switch.turn_on: ${relay}
- lambda: |-
#ifdef HAS_DISPLAY
id(${display_id}).update();
if (${display_id}->is_ready()) {
${display_id}->update();
}
#endif
- delay: ${peripherals_power_refill_pulse_duration}
- switch.turn_off: ${relay}
- lambda: |-
#ifdef HAS_DISPLAY
id(${display_id}).update();
if (${display_id}->is_ready()) {
${display_id}->update();
}
#endif
4 changes: 2 additions & 2 deletions status_sensors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ text_sensor:
entity_category: diagnostic
lambda: |-
#ifdef HAS_SCHEDULE
auto next_schedule = id(lawn_schedule).get_next_schedule();
auto next_schedule = lawn_schedule->get_next_schedule();
if (next_schedule.has_value())
return { next_schedule.value().strftime("%c") };
#endif
Expand All @@ -61,7 +61,7 @@ text_sensor:
entity_category: diagnostic
lambda: |-
#ifdef HAS_SCHEDULE
auto next_schedule = id(flowerbed_schedule).get_next_schedule();
auto next_schedule = flowerbed_schedule->get_next_schedule();
if (next_schedule.has_value())
return { next_schedule.value().strftime("%c") };
#endif
Expand Down
2 changes: 1 addition & 1 deletion time.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ time:
on_time_sync:
- lambda: |-
#ifdef HAS_RTC
id(${rtc_id}).write_time();
${rtc_id}->write_time();
#endif
Loading