Hello there,
I have the following automation that I have created/adapted it from previous inspirations that I have seen around here, although, I’m not trying to make a newer version, and having an issue that I’m not getting.
I’m on 2024.9.0.
Could it be due to the new changes over the service/action?
blueprint:
name: Sun Protection vAug24
description: close cover when sun is shining and open when stops
domain: automation
input:
cover_entity:
name: cover
selector:
entity:
domain: cover
sun_position_start:
name: sun azimuth position start
description: Sun azimuth. when sun is below this value, shutter could be triggered
selector:
entity:
domain: input_number
sun_position_end:
name: sun azimuth position end
description: Sun azimuth. when sun is over this value, shutter could be triggered
selector:
entity:
domain: input_number
sun_elevation_start:
name: sun elevation to start
description: Sun elevation. when sun is over this value, shutter could be triggered
selector:
entity:
domain: input_number
weather:
name: Weather service
selector:
entity:
domain: weather
sensor:
name: Outdoor Sensor
selector:
entity:
domain: sensor
outdoor_temp_1:
name: Pos1 - Outdoor temperature (Low)
description: Temperature above which the shutters will close
selector:
entity:
domain: input_number
outdoor_temp_2:
name: Pos2 - Outdoor temperature (Medium)
description: Second temperature threshold above which the shutters will close
selector:
entity:
domain: input_number
outdoor_temp_3:
name: Pos3 - Outdoor temperature (High)
description: Third temperature threshold above which the shutters will close
selector:
entity:
domain: input_number
alarm_to_override:
name: Alarm that will override Sunrise
description: Automation will only run when time is after than this input_datetime value.
default:
selector:
entity:
domain: input_datetime
alarm_weekend_to_override:
name: Weekend Alarm that will override Sunrise
description: Automation will only run when time is after than this input_datetime value.
default:
selector:
entity:
domain: input_datetime
home_temperature:
name: Temperature Inside
description: Automation will compare the outside temperature with the inside to only open if it is lower.
default:
selector:
entity:
domain: sensor
homews_isinstalled:
name: Home WS Installed
description: Validator of the status
default:
selector:
entity:
domain: input_boolean
homews_temperature:
name: Outside Temperature to be based on Home Weather Station
description: Automation will compare the outside temperature with the inside to only open if it is lower.
default:
selector:
entity:
domain: sensor
homews_rainrate:
name: Rain Rate to be based on Home Weather Station
description: Rain Rate to be based on Home Weather Station
default:
selector:
entity:
domain: sensor
rainrate_pouring:
name: Pouring Rain Rate
description: Rain Rate to be compared with
default:
selector:
entity:
domain: input_number
rainrate_rainy:
name: Rainy Rain Rate
description: Rain Rate to be compared with
default:
selector:
entity:
domain: input_number
nelsonws_temperature:
name: Outside Temperature to be based on Nelson's Weather Station
description: Automation will compare the outside temperature with the inside to only open if it is lower.
default:
selector:
entity:
domain: sensor
nelsonws_rainrate:
name: Rain Rate to be based on Nelson's Weather Station
description: Automation will compare the outside temperature with the inside to only open if it is lower.
default:
selector:
entity:
domain: sensor
variables:
cover_e: !input cover_entity
var_e: "{{ 'var.' + cover_e[6:] }}"
protection_begin: !input sun_position_start
protection_end: !input sun_position_end
elevation_begin: !input sun_elevation_start
outdoor_temp: !input outdoor_temp_1
outdoor_temp_2: !input outdoor_temp_2
outdoor_temp_3: !input outdoor_temp_3
intermediate_position: "{{ 'var.intermediate_position'}}"
fully_closed_position: "{{ 'var.fully_closed_position'}}"
mid_afternoon_position: "{{ 'var.mid_afternoon_position'}}"
open_position_rainy: "{{ 'var.open_position_rainy'}}"
open_position: "{{ 'var.open_position'}}"
weather_service: !input weather
alarm_to_override: !input alarm_to_override
alarm_weekend_to_override: !input alarm_weekend_to_override
home_temperature: !input home_temperature
sensor: !input sensor
homews_isinstalled: !input homews_isinstalled
homews_temperature: !input homews_temperature
homews_rainrate: !input homews_rainrate
rainrate_pouring: !input rainrate_pouring
rainrate_rainy: !input rainrate_rainy
nelsonws_temperature: !input nelsonws_temperature
nelsonws_rainrate: !input nelsonws_rainrate
mode: parallel
trace:
stored_traces: 300
trigger:
- platform: time_pattern
minutes: "/5"
condition:
- condition: or
conditions:
- condition: template
value_template: >
{% set current_time = now().strftime("%H:%M") %}
{{ current_time > states[alarm_to_override].state and (now().weekday() in (1,2,3,4,5)) }}
- condition: template
value_template: >
{% set current_time = now().strftime("%H:%M") %}
{{ current_time > states[alarm_weekend_to_override].state and (now().weekday() in (0,6))}}
- condition: sun
before: sunset
after: sunrise
action:
- choose:
##########################################################.
# close cover - third temperature threshold
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: template
value_template: "{{ states(var_e) != '1' }}"
- condition: template
value_template: "{{ state_attr('sun.sun', 'azimuth') > states(protection_begin) |float and state_attr('sun.sun', 'azimuth') < states(protection_end) |float and state_attr('sun.sun', 'elevation') > states(elevation_begin) |float }}"
- condition: or
conditions:
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(open_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(intermediate_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(fully_closed_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(mid_afternoon_position) |float }}"
- condition: or
conditions:
- condition: template
value_template: "{{ states(weather_service) == 'partlycloudy' }}"
- condition: template
value_template: "{{ states(weather_service) == 'sunny' }}"
- condition: template
value_template: >-
{{ (is_state(homews_isinstalled , 'on') and states(outdoor_temp_3) |int > states(home_temperature) |int and states(homews_temperature) |int >= states(outdoor_temp_3) |int )
or (state_attr(weather_service, 'temperature') != None and is_state(homews_isinstalled , 'off') and states(outdoor_temp_3) |int > states(home_temperature) |int and state_attr(weather_service, 'temperature') |int >= states(outdoor_temp_3) |int) }}
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(fully_closed_position) |float }}"
service: cover.set_cover_position
##########################################################
# close cover - second temperature threshold
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: template
value_template: "{{ states(var_e) != '1' }}"
- condition: template
value_template: "{{ state_attr('sun.sun', 'azimuth') > states(protection_begin) |float and state_attr('sun.sun', 'azimuth') < states(protection_end) |float and state_attr('sun.sun', 'elevation') > states(elevation_begin) |float }}"
- condition: or
conditions:
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(open_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(intermediate_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(fully_closed_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(mid_afternoon_position) |float }}"
- condition: or
conditions:
- condition: template
value_template: "{{ states(weather_service) == 'partlycloudy' }}"
- condition: template
value_template: "{{ states(weather_service) == 'sunny' }}"
- condition: template
value_template: "{{ state_attr(weather_service, 'temperature') != None and is_state(homews_isinstalled , 'off') and states(outdoor_temp_2) |int > states(home_temperature) |int and states(outdoor_temp_3) |int <= states(home_temperature) |int }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(intermediate_position) |float }}"
service: cover.set_cover_position
##########################################################
# close cover - first temperature threshold
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: template
value_template: "{{ states(var_e) != '1' }}"
- condition: template
value_template: "{{ state_attr('sun.sun', 'azimuth') > states(protection_begin) |float and state_attr('sun.sun', 'azimuth') < states(protection_end) |float and state_attr('sun.sun', 'elevation') > states(elevation_begin) |float }}"
- condition: or
conditions:
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(open_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(intermediate_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(fully_closed_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(mid_afternoon_position) |float }}"
- condition: or
conditions:
- condition: template
value_template: "{{ states(weather_service) == 'partlycloudy' }}"
- condition: template
value_template: "{{ states(weather_service) == 'sunny' }}"
- condition: template
value_template: >-
{{ (is_state(homews_isinstalled , 'on') and states(outdoor_temp_3) |int > states(home_temperature) |int and states(homews_temperature) |int >= states(outdoor_temp_3) |int)
or (state_attr(weather_service, 'temperature') != None and states(outdoor_temp_3) |int > states(home_temperature) |int and state_attr(weather_service, 'temperature') |int >= states(outdoor_temp_3) |int) }}
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(mid_afternoon_position) |float }}"
service: cover.set_cover_position
##########################################################
# set cover if rainy
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: sun
before: sunset
after: sunrise
# - condition: template
# value_template: "{{ state_attr('sun.sun', 'azimuth') > states(protection_begin) |float and state_attr('sun.sun', 'azimuth') < states(protection_end) |float and state_attr('sun.sun', 'elevation') > states(elevation_begin) |float }}"
- condition: template
value_template: >-
{{ states(weather_service) == 'rainy' and ( ( is_state(homews_isinstalled , 'on') and states(homews_rainrate) | float >= states(rainrate_rainy) | float and states(homews_rainrate) | float < states(rainrate_pouring) | float) or is_state(homews_isinstalled , 'off') ) }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(open_position_rainy) |float }}"
service: cover.set_cover_position
##########################################################
# set cover if pouring
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: sun
before: sunset
after: sunrise
# - condition: template
# value_template: "{{ state_attr('sun.sun', 'azimuth') > states(protection_begin) |float and state_attr('sun.sun', 'azimuth') < states(protection_end) |float and state_attr('sun.sun', 'elevation') > states(elevation_begin) |float }}"
- condition: template
value_template: "{{ states(weather_service) == 'pouring' and ( ( is_state(homews_isinstalled , 'on') and states(homews_rainrate) | float >= states(rainrate_pouring) | float ) or is_state(homews_isinstalled , 'off') ) }} "
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(fully_closed_position) |float }}"
service: cover.set_cover_position
##########################################################
# open cover before sunset
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: sun
before: sunset
after: sunrise
- condition: template
value_template: "{{ (state_attr('sun.sun', 'azimuth') < states(protection_begin) |float or state_attr('sun.sun', 'azimuth') > states(protection_end) |float or state_attr('sun.sun', 'elevation') < states(elevation_begin) |float) }}"
- condition: or
conditions:
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(open_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(intermediate_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(fully_closed_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(mid_afternoon_position) |float }}"
- condition: template
value_template: >-
{{ (is_state(homews_isinstalled , 'on') and states(homews_temperature) |int < states(home_temperature) |int)
or (state_attr(weather_service, 'temperature') != None and state_attr(weather_service, 'temperature') |int < states(home_temperature) |int)
or (state_attr(weather_service, 'temperature') == None and states(outdoor_temp) |int <= states(home_temperature) |int) }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(mid_afternoon_position) |float }}"
service: cover.set_cover_position
##########################################################
# open cover
##########################################################
- conditions:
- condition: template
value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
- condition: sun
before: sunset
after: sunrise
- condition: template
value_template: "{{ (state_attr('sun.sun', 'azimuth') < states(protection_begin) |float or state_attr('sun.sun', 'azimuth') > states(protection_end) |float or state_attr('sun.sun', 'elevation') < states(elevation_begin) |float) }}"
- condition: or
conditions:
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(open_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(intermediate_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(fully_closed_position) |float }}"
- condition: template
value_template: "{{ state_attr(cover_e, 'current_position') == states(mid_afternoon_position) |float }}"
- condition: template
value_template: "{{ (state_attr(weather_service, 'temperature') != None and state_attr(weather_service, 'temperature') |int < states(home_temperature) |int) or (state_attr(weather_service, 'temperature') == None and states(outdoor_temp) |int <= states(home_temperature) |int) }}"
sequence:
- data_template:
entity_id: "{{ cover_e }}"
position: "{{ states(open_position) |float }}"
service: cover.set_cover_position
Here is the new version, and the error I’m getting.
New not working automation
blueprint:
name: Sun Protection vAug24 Enhanced
description: Enhanced blueprint to control cover based on sun position,
temperature, weather conditions, and seasonal adjustments.
domain: automation
input:
cover_entity:
name: Cover
selector:
entity:
domain: cover
sun_position_start:
name: Sun Azimuth Start
description: Start azimuth value to trigger cover control
selector:
entity:
domain: input_number
sun_position_end:
name: Sun Azimuth End
description: End azimuth value to trigger cover control
selector:
entity:
domain: input_number
sun_elevation_start:
name: Sun Elevation Start
description: Minimum elevation to trigger cover control
selector:
entity:
domain: input_number
weather:
name: Weather Service
selector:
entity:
domain: weather
sensor:
name: Outdoor Sensor
selector:
entity:
domain: sensor
outdoor_temp_low:
name: Low Temperature Threshold
description: Shutters will close if outdoor temp is above this value
selector:
entity:
domain: input_number
outdoor_temp_medium:
name: Medium Temperature Threshold
description: Second temperature threshold for cover control
selector:
entity:
domain: input_number
outdoor_temp_high:
name: High Temperature Threshold
description: Third temperature threshold for cover control
selector:
entity:
domain: input_number
alarm_to_override:
name: Alarm Override for Weekdays
description: Time after which automation is active on weekdays
selector:
entity:
domain: input_datetime
alarm_weekend_to_override:
name: Alarm Override for Weekends
description: Time after which automation is active on weekends
selector:
entity:
domain: input_datetime
home_temperature:
name: Indoor Temperature Sensor
description: Sensor to compare indoor and outdoor temperature
selector:
entity:
domain: sensor
homews_isinstalled:
name: Home Weather Station Installed
description: Boolean to indicate if home weather station is available
selector:
entity:
domain: input_boolean
homews_temperature:
name: Home Weather Station Outdoor Temperature
selector:
entity:
domain: sensor
homews_rainrate:
name: Home Weather Station Rain Rate
selector:
entity:
domain: sensor
rainrate_pouring:
name: Pouring Rain Rate Threshold
selector:
entity:
domain: input_number
rainrate_rainy:
name: Rainy Rain Rate Threshold
selector:
entity:
domain: input_number
season_selector:
name: Season Selector
description: Select the current season to adjust thresholds accordingly
selector:
entity:
domain: sensor
light_sensor:
name: Optional Light Sensor
description: (Optional) Light sensor to measure ambient light levels
selector:
entity:
domain: sensor
default: none
variables:
cover_e: !input cover_entity
sun_azimuth: "{{ state_attr('sun.sun', 'azimuth') | float }}"
sun_elevation: "{{ state_attr('sun.sun', 'elevation') | float }}"
is_sunny: "{{ states(weather) in ['partlycloudy', 'sunny'] }}"
is_rainy: "{{ states(weather) == 'rainy' }}"
is_pouring: "{{ states(weather) == 'pouring' }}"
indoor_temp: "{{ states[home_temperature].state | float }}"
outdoor_temp: |-
{% if is_state('input_boolean.homews_isinstalled', 'on') %}
{{ states[homews_temperature].state | float }}
{% else %}
{{ state_attr(weather, 'temperature') | float }}
{% endif %}
rain_rate: |-
{% if is_state('input_boolean.homews_isinstalled', 'on') %}
{{ states[homews_rainrate].state | float }}
{% else %}
0
{% endif %}
current_season: "{{ states(season_selector) }}"
ambient_light: |-
{% if light_sensor != 'none' and states(light_sensor) %}
{{ states(light_sensor).state | float }}
{% else %}
1000 # Default value if no light sensor is provided
{% endif %}
trigger:
- platform: time_pattern
minutes: /15
- platform: template
value_template: "{{ sun_elevation > states.sun_elevation_start | float }}"
- platform: state
entity_id:
- weather
- platform: state
entity_id: season_selector
condition:
- condition: or
conditions:
- condition: template
value_template: '{% set current_time = now().strftime("%H:%M") %} {{
current_time > states[alarm_to_override].state and now().weekday() in
(1, 2, 3, 4, 5) }}'
- condition: template
value_template: '{% set current_time = now().strftime("%H:%M") %} {{
current_time > states[alarm_weekend_to_override].state and
now().weekday() in (0, 6) }}'
- condition: sun
before: sunset
after: sunrise
action:
- variables:
adjusted_outdoor_temp_low: >-
{% if current_season == 'summer' %}
{{ states.outdoor_temp_low | float * 1.1 }} # Example: Increase threshold by 10%
{% else %}
{{ states.outdoor_temp_low | float }}
{% endif %}
adjusted_outdoor_temp_medium: |-
{% if current_season == 'summer' %}
{{ states.outdoor_temp_medium | float * 1.1 }}
{% else %}
{{ states.outdoor_temp_medium | float }}
{% endif %}
adjusted_outdoor_temp_high: |-
{% if current_season == 'summer' %}
{{ states.outdoor_temp_high | float * 1.1 }}
{% else %}
{{ states.outdoor_temp_high | float }}
{% endif %}
light_level_threshold: 500
- choose:
- conditions:
- condition: template
value_template: "{{ sun_azimuth > states.sun_position_start | float and
sun_azimuth < states.sun_position_end | float and sun_elevation >
states.sun_elevation_start | float }}"
- condition: template
value_template: "{{ is_sunny }}"
- condition: template
value_template: "{{ outdoor_temp >= adjusted_outdoor_temp_high and outdoor_temp
> indoor_temp }}"
- condition: template
value_template: "{{ ambient_light > light_level_threshold }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.fully_closed_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ sun_azimuth > states.sun_position_start | float and
sun_azimuth < states.sun_position_end | float and sun_elevation >
states.sun_elevation_start | float }}"
- condition: template
value_template: "{{ is_sunny }}"
- condition: template
value_template: "{{ outdoor_temp >= adjusted_outdoor_temp_medium and
outdoor_temp < adjusted_outdoor_temp_high and outdoor_temp >
indoor_temp }}"
- condition: template
value_template: "{{ ambient_light > light_level_threshold }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.intermediate_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ sun_azimuth > states.sun_position_start | float and
sun_azimuth < states.sun_position_end | float and sun_elevation >
states.sun_elevation_start | float }}"
- condition: template
value_template: "{{ is_sunny }}"
- condition: template
value_template: "{{ outdoor_temp >= adjusted_outdoor_temp_low and outdoor_temp <
adjusted_outdoor_temp_medium and outdoor_temp > indoor_temp }}"
- condition: template
value_template: "{{ ambient_light > light_level_threshold }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.mid_afternoon_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ is_rainy and rain_rate >= states.rainrate_rainy | float and
rain_rate < states.rainrate_pouring | float }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.open_position_rainy'] | float }}"
- conditions:
- condition: template
value_template: "{{ is_pouring and rain_rate >= states.rainrate_pouring | float }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.fully_closed_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ (sun_azimuth < states.sun_position_start | float or
sun_azimuth > states.sun_position_end | float or sun_elevation <
states.sun_elevation_start | float) }}"
- condition: template
value_template: "{{ ambient_light < light_level_threshold }}"
- condition: template
value_template: "{{ (outdoor_temp < indoor_temp and outdoor_temp <=
states.outdoor_temp_low | float) }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.open_position'] | float }}"
- default:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.open_position'] | float }}"
- choose:
- conditions:
- condition: state
entity_id: "{{ cover_e }}"
state: closed
sequence:
- action: logbook.log
data_template:
name: Cover Automation
message: Cover {{ cover_e }} closed due to high temperature or rain.
entity_id: "{{ cover_e }}"
- conditions:
- condition: state
entity_id: "{{ cover_e }}"
state: open
sequence:
- action: logbook.log
data_template:
name: Cover Automation
message: Cover {{ cover_e }} opened as conditions normalized.
entity_id: "{{ cover_e }}"
- action: notify.notify
data_template:
title: Cover Automation Update
message: Cover {{ cover_e }} moved to position {{ state_attr(cover_e, 'current_position') }}.
Any hints?
Cheers