Skip to content

Commit

Permalink
Allow RGB LED to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
hostcc committed Oct 2, 2024
1 parent 6a61160 commit 8d5ef39
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
24 changes: 20 additions & 4 deletions controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ sprinkler:
}
${display_backlight_id}->turn_on();
#endif
- light.turn_on: ${led_id}
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_on();
call.perform();
#endif
on_turn_off:
- !include
file: script_refill_tank.yaml
Expand All @@ -30,7 +34,11 @@ sprinkler:
condition: >-
!id(disable_water_tank_refill).state
&& !id(water_tank_refill_after_each_valve).state
- light.turn_off: ${led_id}
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_off();
call.perform();
#endif
- lambda: |-
#ifdef HAS_DISPLAY
${display_backlight_id}->turn_off();
Expand Down Expand Up @@ -118,7 +126,11 @@ sprinkler:
}
${display_backlight_id}->turn_on();
#endif
- light.turn_on: ${led_id}
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_on();
call.perform();
#endif
on_turn_off:
- !include
file: script_refill_tank.yaml
Expand All @@ -128,7 +140,11 @@ sprinkler:
condition: >-
!id(disable_water_tank_refill).state
&& !id(water_tank_refill_after_each_valve).state
- light.turn_off: ${led_id}
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_off();
call.perform();
#endif
- lambda: |-
#ifdef HAS_DISPLAY
${display_backlight_id}->turn_off();
Expand Down
5 changes: 5 additions & 0 deletions indicators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
esphome:
# Required for 'rp2040_pio_led_strip' component
min_version: '2023.6.2'
platformio_options:
build_flags:
# Define the preprocessor macro indicating presence of RGB led so that
# dependent code could be conditional
- '-DHAS_RGB_LED'

light:
- platform: rp2040_pio_led_strip
Expand Down
2 changes: 1 addition & 1 deletion main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ packages:
inputs: !include inputs.yaml
schedule: !include schedule.yaml # Optional
display: !include display.yaml # Optional
indicators: !include indicators.yaml
indicators: !include indicators.yaml # Optional

Check warning on line 34 in main.yaml

View workflow job for this annotation

GitHub Actions / lint

34:40 [comments] too few spaces before comment
controllers: !include controllers.yaml
status_sensors: !include status_sensors.yaml
time: !include time.yaml # Optional
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 @@ -33,8 +33,10 @@
// Explicitly shutdown any running operation in case of rain, also turn on
// LED indicating the condition
#ifdef TRIGGERED_BY_${rain_sensor_id}
auto call = id(${led_id}).turn_on();
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_on();
call.perform();
#endif
id(flowerbed_sprinklers).shutdown();
id(lawn_sprinklers).shutdown();
#endif
Expand Down Expand Up @@ -74,9 +76,11 @@

// Turn off LED indicating that rain is detected
#ifdef TRIGGERED_BY_${rain_sensor_id}
auto call = id(${led_id}).turn_off();
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_off();
call.perform();
#endif
#endif

// Resume any operation if any once water tank is full
// NOTE: should be called after moving controller out of standby otherwise
Expand Down

0 comments on commit 8d5ef39

Please sign in to comment.