From 8d5ef398973422c33974a32ddd62a8f2d1d0688f Mon Sep 17 00:00:00 2001 From: Ilia Sotnikov Date: Wed, 2 Oct 2024 13:41:22 +0300 Subject: [PATCH 1/4] Allow RGB LED to be optional --- controllers.yaml | 24 ++++++++++++++++++---- indicators.yaml | 5 +++++ main.yaml | 2 +- script_rain_water_tank_sensors_action.yaml | 8 ++++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/controllers.yaml b/controllers.yaml index c3684f0..622f61a 100644 --- a/controllers.yaml +++ b/controllers.yaml @@ -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 @@ -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(); @@ -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 @@ -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(); diff --git a/indicators.yaml b/indicators.yaml index f4af540..41945ce 100644 --- a/indicators.yaml +++ b/indicators.yaml @@ -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 diff --git a/main.yaml b/main.yaml index e07f055..c342a2a 100644 --- a/main.yaml +++ b/main.yaml @@ -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 controllers: !include controllers.yaml status_sensors: !include status_sensors.yaml time: !include time.yaml # Optional diff --git a/script_rain_water_tank_sensors_action.yaml b/script_rain_water_tank_sensors_action.yaml index 7818885..71fa3c8 100644 --- a/script_rain_water_tank_sensors_action.yaml +++ b/script_rain_water_tank_sensors_action.yaml @@ -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 @@ -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 From 03ec53e990a63a7bab6bb7fdb4838782b37133a7 Mon Sep 17 00:00:00 2001 From: Ilia Sotnikov Date: Wed, 2 Oct 2024 13:47:56 +0300 Subject: [PATCH 2/4] * Testing: updated to most recent ESPHome version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 812864f..9a2ae8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -esphome==2024.3.0 +esphome==2024.9.1 pillow==10.2.0 From 962fc21262b37b98a7c1a3718dddbca714decdd2 Mon Sep 17 00:00:00 2001 From: Ilia Sotnikov Date: Wed, 2 Oct 2024 14:03:35 +0300 Subject: [PATCH 3/4] * `tests/rp2040w.yaml`: Pin `platform_version` to `v1.2.0-gcc12` to prevent compilation failure, see https://github.com/esphome/esphome/pull/7514 --- tests/rp2040w.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/rp2040w.yaml b/tests/rp2040w.yaml index aae048f..6de1e07 100644 --- a/tests/rp2040w.yaml +++ b/tests/rp2040w.yaml @@ -15,7 +15,9 @@ esphome: rp2040: board: rpipicow framework: - platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git + # Pinned to specific version to prevent compilation failure, + # see https://github.com/esphome/esphome/pull/7514 + platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git#v1.2.0-gcc12 api: wifi: From b8e4e6a73d5c9ce2cc73dfe8b88d86d93e0c2c27 Mon Sep 17 00:00:00 2001 From: Ilia Sotnikov Date: Wed, 2 Oct 2024 14:08:27 +0300 Subject: [PATCH 4/4] * Linting fixes --- main.yaml | 2 +- tests/rp2040w.yaml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main.yaml b/main.yaml index c342a2a..4858109 100644 --- a/main.yaml +++ b/main.yaml @@ -31,7 +31,7 @@ packages: inputs: !include inputs.yaml schedule: !include schedule.yaml # Optional display: !include display.yaml # Optional - indicators: !include indicators.yaml # Optional + indicators: !include indicators.yaml # Optional controllers: !include controllers.yaml status_sensors: !include status_sensors.yaml time: !include time.yaml # Optional diff --git a/tests/rp2040w.yaml b/tests/rp2040w.yaml index 6de1e07..8992aca 100644 --- a/tests/rp2040w.yaml +++ b/tests/rp2040w.yaml @@ -17,7 +17,8 @@ rp2040: framework: # Pinned to specific version to prevent compilation failure, # see https://github.com/esphome/esphome/pull/7514 - platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git#v1.2.0-gcc12 + platform_version: >- + https://github.com/maxgerhardt/platform-raspberrypi.git#v1.2.0-gcc12 api: wifi: