Last active
March 22, 2025 23:58
-
-
Save MagicMicky/a863100b509100df94d32c96910ec0f8 to your computer and use it in GitHub Desktop.
Plant Soil Moisture LED Indicator Blueprint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Plant Soil Moisture LED Indicator | |
description: > | |
Monitors a plant's soil moisture and controls an LED to provide visual feedback. | |
The LED will turn red when moisture is too low, yellow when moisture is too high, | |
and turn off when moisture is in the optimal range. | |
domain: automation | |
input: | |
plant_entity: | |
name: Plant Entity | |
description: The plant entity to monitor (e.g., plant.window_tv_peace_lily) | |
selector: | |
entity: | |
domain: plant | |
led_entity: | |
name: LED Light | |
description: The LED light to control as an indicator | |
selector: | |
entity: | |
domain: light | |
# Automation template | |
trigger: | |
# This will trigger when the plant entity state changes | |
- platform: state | |
entity_id: !input plant_entity | |
id: "plant_state_change" | |
# Also trigger when the soil moisture sensor changes | |
- platform: template | |
id: "moisture_status_change" | |
value_template: > | |
{% set plant_id = this.attributes.get('entity_id').split('.')[1] %} | |
{% set moisture_sensor = 'sensor.' + plant_id + '_soil_moisture' %} | |
{{ is_state_attr(this.attributes.get('entity_id'), 'moisture_status', 'low') | |
or is_state_attr(this.attributes.get('entity_id'), 'moisture_status', 'high') | |
or is_state_attr(this.attributes.get('entity_id'), 'moisture_status', 'ok') }} | |
# Also trigger when Home Assistant starts | |
- platform: homeassistant | |
event: start | |
id: "ha_start" | |
condition: | |
# Only run when the entities have valid values | |
- condition: template | |
value_template: > | |
{{ not is_state(input.plant_entity, 'unavailable') | |
and not is_state(input.plant_entity, 'unknown') }} | |
action: | |
- variables: | |
plant_base_id: "{{ input.plant_entity.split('.')[1] }}" | |
soil_moisture_sensor: "sensor.{{ plant_base_id }}_soil_moisture" | |
min_soil_moisture: "number.{{ plant_base_id }}_min_soil_moisture" | |
max_soil_moisture: "number.{{ plant_base_id }}_max_soil_moisture" | |
moisture_status: "{{ state_attr(input.plant_entity, 'moisture_status') }}" | |
- choose: | |
# Condition 1: Moisture too low - LED red at 100% | |
- alias: "Moisture Too Low (Need Water)" | |
conditions: | |
- condition: or | |
conditions: | |
- condition: template | |
value_template: "{{ moisture_status == 'low' }}" | |
- condition: and | |
conditions: | |
- condition: template | |
value_template: "{{ states(soil_moisture_sensor) != 'unknown' and states(soil_moisture_sensor) != 'unavailable' }}" | |
- condition: template | |
value_template: "{{ states(min_soil_moisture) != 'unknown' and states(min_soil_moisture) != 'unavailable' }}" | |
- condition: template | |
value_template: > | |
{{ states(soil_moisture_sensor) | float < | |
states(min_soil_moisture) | float }} | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input led_entity | |
data: | |
rgb_color: [255, 0, 0] # Red | |
brightness_pct: 100 | |
# Condition 2: Moisture too high - LED yellow at 100% | |
- alias: "Moisture Too High (Overwatered)" | |
conditions: | |
- condition: or | |
conditions: | |
- condition: template | |
value_template: "{{ moisture_status == 'high' }}" | |
- condition: and | |
conditions: | |
- condition: template | |
value_template: "{{ states(soil_moisture_sensor) != 'unknown' and states(soil_moisture_sensor) != 'unavailable' }}" | |
- condition: template | |
value_template: "{{ states(max_soil_moisture) != 'unknown' and states(max_soil_moisture) != 'unavailable' }}" | |
- condition: template | |
value_template: > | |
{{ states(soil_moisture_sensor) | float > | |
states(max_soil_moisture) | float }} | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input led_entity | |
data: | |
rgb_color: [255, 255, 0] # Yellow | |
brightness_pct: 100 | |
# Default: Moisture is normal - Turn LED off | |
default: | |
- alias: "Moisture Normal (Optimal)" | |
service: light.turn_off | |
target: | |
entity_id: !input led_entity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment