Skip to content

Commit 2660f3f

Browse files
Brent Saltzmanfabaff
Brent Saltzman
authored andcommitted
Added example for automation based on solar elevation (home-assistant#2760)
* Added example for automation based on solar elevation Added example for automation based on solar elevation angle trigger. * Escape the template
1 parent 6c3476a commit 2660f3f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

source/_docs/automation/trigger.markdown

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,23 @@ automation:
111111
offset: '-00:45:00'
112112
```
113113

114+
Sometimes you may want more grainular control over an automation based on the elevation of the sun. This can be used to layer automations to occur as the sun lowers on the horizon even after when it is below the horizon. This is also useful when the "sunset" event is not dark enough outside and you would like the automation to run later at a precise solar angle instead of the time offset such as turning on exterior lighting.
115+
116+
```yaml
117+
automation:
118+
alias: "Exterior Lighting on when dark outside"
119+
trigger:
120+
platform: numeric_state
121+
entity_id: sun.sun
122+
value_template: "{% raw %}{{ state.attributes.elevation }}{% endraw %}"
123+
# Can be a positive or negetive number
124+
below: -4.0
125+
action:
126+
service: switch.turn_on
127+
entity_id: switch.exterior_lighting
128+
```
129+
The US Naval Observatory has a [tool](http://aa.usno.navy.mil/data/docs/AltAz.php) that will help you estimate what the solar angle will be at any specific time.
130+
114131
### {% linkable_title Template trigger %}
115132

116133
Template triggers work by evaluating a [template] on each state change. The trigger will fire if the state change caused the template to render 'true'. This is achieved by having the template result in a true boolean expression (`{% raw %}{{ is_state('device_tracker.paulus', 'home') }}{% endraw %}`) or by having the template render 'true' (example below).

0 commit comments

Comments
 (0)