I’m a bit lost with where to start with this one.
I have a sun awning controls by a time based cover via esphome.
Controlling it manually is fine.
However I’d like to automate a few things.
Firstly: I’d like it to open out half way on hot days to shade the patio doors.
However this shouldn’t happen if it’s windy or wet.
Ideally I’d like it to notify me beforehand so I can object , with the default action being that it opens.
Secondly, if it is open and the weather changes, gets windy, wet or the sun sets, I’d like it to go in, but again notify me first so I can object. Maybe I’m sheltering under it from the rain?
I started setting up some automations checking conditions every 15 minutes, and then wondered if I was going about it the right way, or weather some sensors checking conditions and triggering automations would be better.
thanks nick.
wind is probably something that should be acted on straight away, the 15 minutes was more for opening
as for notifications, mobile app seems like the best idea for me.
this is what i have so far.
I’ll tweak the trigger and condition values as needed after i can test them, but just want to get something in place to work from.
alias: Sun Awning Auto Open / Close
description: ''
trigger:
- platform: time_pattern
minutes: /15
- platform: numeric_state
entity_id: weather.home
attribute: wind_speed
above: '25'
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
above: '10'
- condition: state
entity_id: cover.garden_sun_awning
state: closed
- condition: numeric_state
entity_id: weather.home
attribute: temperature
above: '20'
- condition: numeric_state
entity_id: weather.home
attribute: wind_speed
below: '20'
sequence:
- service: input_select.select_option
data:
option: open
entity_id: input_select.sun_awning_auto_actions
- service: notify.mobile_app_ac2003
data:
message: Sun Awning Wants to Open
data:
timeout: 300
tag: awning
actions:
- action: open
title: Open
- action: standby
title: Don't Open
- conditions:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
above: '10'
- condition: state
entity_id: cover.garden_sun_awning
state: open
- condition: numeric_state
entity_id: weather.home
attribute: temperature
above: '15'
- condition: numeric_state
entity_id: weather.home
attribute: wind_speed
below: '25'
sequence:
- service: input_select.select_option
data:
option: standby
entity_id: input_select.sun_awning_auto_actions
- conditions:
- condition: state
entity_id: cover.garden_sun_awning
state: open
sequence:
- service: input_select.select_option
data:
option: close
entity_id: input_select.sun_awning_auto_actions
- service: notify.mobile_app_ac2003
data:
message: Sun Awning Wants to Close
data:
timeout: 300
tag: awning
actions:
- action: close
title: Close
- action: standby
title: Don't Close
default:
- service: input_select.select_option
data:
option: standby
entity_id: input_select.sun_awning_auto_actions
mode: single
then another automation will be triggered by the input select changing, see if i respond to the notification and take a default action if i dont reply.
Just so I’ve got this clear with choose: they work in sequencial order.
For example,
If 1 do A
Else if 2 do B
Else if 3 do C
If none of the above do default.
So if 1 and 2 were both true a would be actioned but not b?
I realised i made some big mistakes with the choose actions, i set up seperate chooses rather than options within a choose.
I’ve also combined the two automations into one.
alias: Sun Awning Auto Open / Close Combined
description: ''
trigger:
## check conditions every 15 minutes
- platform: time_pattern
minutes: /15
## trigger on high winds
- platform: numeric_state
entity_id: weather.home
attribute: wind_speed
above: '25'
condition: []
action:
- choose:
## are conditions ok to open a closed awning?
- conditions:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
above: '10'
- condition: state
entity_id: cover.garden_sun_awning
state: closed
- condition: numeric_state
entity_id: weather.home
attribute: temperature
above: '20'
- condition: numeric_state
entity_id: weather.home
attribute: wind_speed
below: '20'
## if so set the requested value and ask for permission
sequence:
- service: input_select.select_option
data:
option: open
entity_id: input_select.sun_awning_auto_actions
- service: notify.mobile_app_ac2003
data:
message: Sun Awning Wants to Open
data:
timeout: 300
tag: awning
actions:
- action: open
title: Open
- action: standby
title: Don't Open
## are conditions ok to leave open the awning?
- conditions:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
above: '10'
- condition: state
entity_id: cover.garden_sun_awning
state: open
- condition: numeric_state
entity_id: weather.home
attribute: temperature
above: '15'
- condition: numeric_state
entity_id: weather.home
attribute: wind_speed
below: '25'
## if so take no action (is there a way to end the automation at this point?)
sequence:
- service: input_select.select_option
data:
option: standby
entity_id: input_select.sun_awning_auto_actions
## if neither of the above are true, then the awning could be open in non optimal conditions
- conditions:
- condition: state
entity_id: cover.garden_sun_awning
state: open
## if so set the recommended value ask for permission to close
sequence:
- service: input_select.select_option
data:
option: close
entity_id: input_select.sun_awning_auto_actions
- service: notify.mobile_app_ac2003
data:
message: Sun Awning Wants to Close
data:
timeout: 300
tag: awning
actions:
- action: close
title: Close
- action: standby
title: Don't Close
## if it wasnt open, no action is required, (again is it possible to end the automation)
default:
- service: input_select.select_option
data:
option: standby
entity_id: input_select.sun_awning_auto_actions
## if permission was sort we need to wait for a reply, or if one isnt received go ahead with the action
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
tag: awning
timeout: '600'
- choose:
- conditions:
## if reply received to standby then reset the input select (is it possible to end the automation here)
- condition: template
value_template: '{{ wait.trigger.event.data.action == "standby" }}'
sequence:
- service: input_select.select_option
data:
option: standby
entity_id: input_select.sun_awning_auto_actions
## if reply other than standby or no reply go ahead with the recommended actions, is it an open action?
- condition: state
entity_id: input_select.sun_awning_auto_actions
state: open
## if so open
sequence:
- service: cover.open_cover
entity_id: cover.garden_sun_awning
## or a close action
- conditions:
- condition: state
entity_id: input_select.sun_awning_auto_actions
state: close
## if so close
sequence:
- service: cover.close_cover
entity_id: cover.garden_sun_awning
then reset the input select to standby
default:
- service: input_select.select_option
data:
option: standby
entity_id: input_select.sun_awning_auto_actions
mode: single
the wait happens even if theres nothing its waiting for…
this wouldnt be a problem as the wait is shorter than the time between triggers, but if it was currently waiting and then triggered by wind, it wouldnt run and the awning would stay out in wind. (not great)
Is there a way to end the run of the automation at points that require no further actions. see my commented code above for these points, or do i need to nest the lower half into another choose?