diff --git a/controllers.yaml b/controllers.yaml index 7917e03..c3684f0 100644 --- a/controllers.yaml +++ b/controllers.yaml @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/display.yaml b/display.yaml index 98fefb6..641aaab 100644 --- a/display.yaml +++ b/display.yaml @@ -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 @@ -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) { @@ -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()) { @@ -163,6 +164,7 @@ display: ); } } + #endif - id: display_page2 lambda: |- diff --git a/indicators.yaml b/indicators.yaml index bd952b8..f4af540 100644 --- a/indicators.yaml +++ b/indicators.yaml @@ -53,8 +53,3 @@ light: return; }; id(${led_id}).turn_on(); - -status_led: - pin: - number: LED - inverted: true diff --git a/main.yaml b/main.yaml index 58be798..e07f055 100644 --- a/main.yaml +++ b/main.yaml @@ -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 diff --git a/script_rain_water_tank_sensors_action.yaml b/script_rain_water_tank_sensors_action.yaml index 30255cf..7818885 100644 --- a/script_rain_water_tank_sensors_action.yaml +++ b/script_rain_water_tank_sensors_action.yaml @@ -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 @@ -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 diff --git a/script_refill_tank.yaml b/script_refill_tank.yaml index 12d2ac7..258bb78 100644 --- a/script_refill_tank.yaml +++ b/script_refill_tank.yaml @@ -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 diff --git a/status_sensors.yaml b/status_sensors.yaml index cea0b23..c828060 100644 --- a/status_sensors.yaml +++ b/status_sensors.yaml @@ -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 @@ -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 diff --git a/time.yaml b/time.yaml index 86aba48..0f4db9d 100644 --- a/time.yaml +++ b/time.yaml @@ -8,5 +8,5 @@ time: on_time_sync: - lambda: |- #ifdef HAS_RTC - id(${rtc_id}).write_time(); + ${rtc_id}->write_time(); #endif