Create a Season Sensor. It reports the season as spring
, summer
, autumn
, and winter
.
Here is an automation that adjusts the watering duration and schedule based on the current season.
- id: '1607725857757'
alias: Riego Zona 1 y 2
description: ''
variables:
season: "{{ states('sensor.season') }}"
seasons:
spring: [1,3,5]
summer: [1,2,3,4,5,6,7]
autumn: [1,3,5]
winter: [1,4]
trigger:
- platform: sun
event: sunrise
offset: '0'
condition: '{{ now().isoweekday() in seasons[season] }}'
action:
- variables:
zona_1:
- switch.bomba_riego
- switch.riego_zona_1
zona_2:
- switch.bomba_riego
- switch.riego_zona_2
seasons:
spring:
z1: 8
z2: 10
summer:
z1: 10
z2: 15
autumn:
z1: 8
z2: 10
winter:
z1: 5
z2: 8
- service: switch.turn_on
target:
entity_id: '{{ zona_1 }}'
- delay:
minutes: '{{ seasons[season].z1 }}'
- service: switch.turn_off
target:
entity_id: '{{ zona_1 }}'
- delay:
minutes: 10
- service: switch.turn_on
target:
entity_id: '{{ zona_2 }}'
- delay:
minutes: '{{ seasons[season].z2 }}'
- service: switch.turn_on
target:
entity_id: '{{ zona_2 }}'
mode: single
How it works
The day of the week is reported by now().isoweekday()
where Monday is 1
and Sunday is 7
.
The scheduling is handled by this dictionary contained by the variable seasons
seasons:
spring: [1,3,5]
summer: [1,2,3,4,5,6,7]
autumn: [1,3,5]
winter: [1,4]
The watering duration for each zone is handled by a slightly more complex dictionary contained by the variable seasons
(the same variable name is used and its value is redefined)
seasons:
spring:
z1: 8
z2: 10
summer:
z1: 10
z2: 15
autumn:
z1: 8
z2: 10
winter:
z1: 5
z2: 8
Let me know if you need more information about how it works.