Hi everybody,
I have an automation (code below) to control my rain water pump and connected valves in order to irrigate my garden. I thought it’d work the way I have it (it used to), but when adding code to it, it must have broken. However, I decided to change things up and create a template sensor as a condition.
Conditions
-
input_boolean.bewasserung_ein
must beon
(I set this manually; in the future, it will be automated depending on whether or not there is a sufficient amount of water in the rain water bins) -
sensor.wetter_sensor_rain
must benot raining
-
sensor.wetter_sensor_condition
must not containRegen
(I am not sure what states can be set for this sensor; it is currently not actually raining, but the sensor states light rainLeichter Regen
; I assume there is alsoStarker Regen
etc., so hopefully the automation should work if the state for this sensor just does not contain the wordRegen
alltogether) -
sensor.season
must be eithersummer
orspring
If possible, I’d check all these conditions with a single template sensor, but I do not know how. This way, I could use this single template sensor as condition instead of having all these conditions in multiple automations (at least two, an hour after sunrise and half an hour before sunset).
This is my current automation, which I must have broken when adding things (the switch.valve_<n>
entities; it worked fine before).
automation:
- alias: "[Timer] Bewässerung Morgens"
trigger:
platform: sun
event: sunrise
offset: "+00:30:00"
condition:
condition: and
conditions:
- condition: state
entity_id: sensor.wetter_sensor_rain
state: "not raining"
- condition: or
conditions:
- condition: state
entity_id: sensor.season
state: "spring"
- condition: state
entity_id: sensor.season
state: "summer"
action:
- service: switch.turn_off
entity_id: switch.valve_01, switch.valve_02, switch.valve_03
- service: switch.turn_on
entity_id: switch.dr_wasser
- delay: "00:00:02"
- service: switch.turn_on
entity_id: switch.valve_01
- delay: "{{ states('input_datetime.dauer_bewaesserung_morgens') }}"
- service: switch.turn_off
entity_id: switch.valve_01
- service: switch.turn_on
entity_id: switch.valve_02
- delay: "{{ states('input_datetime.dauer_bewaesserung_morgens') }}"
- service: switch.turn_off
entity_id: switch.dr_wasser, switch.valve_01, switch.valve_02, switch.valve_03
Instead, I’d like something like this
automation:
- alias: "[Timer] Bewässerung Morgens"
trigger:
platform: sun
event: sunrise
offset: "+00:30:00"
condition:
- condition: state
entity_id: <the_template_sensor_with_all_the_stuff_from_above>
state: true
action:
# ...
How can I combine all those conditions above into one template sensor? When I do something like this {{ is_state("sensor.season", "summer") or is_state("sensor.season", "spring") }}
, I’ll get true
, but I don’t know how to do and and or conditions etc.
Thank you for your ideas