From 2660f3f55c24bd43101e471216b35b2d2a126932 Mon Sep 17 00:00:00 2001 From: Brent Saltzman Date: Sun, 4 Jun 2017 15:22:04 -0500 Subject: [PATCH] Added example for automation based on solar elevation (#2760) * Added example for automation based on solar elevation Added example for automation based on solar elevation angle trigger. * Escape the template --- source/_docs/automation/trigger.markdown | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index ac7e7a4ca4d..6f8d346e895 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -111,6 +111,23 @@ automation: offset: '-00:45:00' ``` +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. + +```yaml +automation: + alias: "Exterior Lighting on when dark outside" + trigger: + platform: numeric_state + entity_id: sun.sun + value_template: "{% raw %}{{ state.attributes.elevation }}{% endraw %}" + # Can be a positive or negetive number + below: -4.0 + action: + service: switch.turn_on + entity_id: switch.exterior_lighting +``` +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. + ### {% linkable_title Template trigger %} 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).