Skip to content

Instantly share code, notes, and snippets.

@swilson
Created November 17, 2018 21:22
Show Gist options
  • Save swilson/7d4b2a4cc6ec28d902c15c8758fd7390 to your computer and use it in GitHub Desktop.
Save swilson/7d4b2a4cc6ec28d902c15c8758fd7390 to your computer and use it in GitHub Desktop.
Home Assistant sunrise/sunset sensors
sensor:
- platform: template
sensors:
sunrise:
value_template: '{% set timestamp = as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom("%I:%M %p") %} {{ timestamp.lstrip("0") }}'
friendly_name: "Sunrise"
sunset:
value_template: '{% set timestamp = as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom("%I:%M %p") %} {{ timestamp.lstrip("0") }}'
friendly_name: "Sunset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment