Skip to content

Instantly share code, notes, and snippets.

@GuySie
Created December 13, 2021 20:36
Show Gist options
  • Save GuySie/d60984c58aa1e5b1ac2dfe75c070e3f9 to your computer and use it in GitHub Desktop.
Save GuySie/d60984c58aa1e5b1ac2dfe75c070e3f9 to your computer and use it in GitHub Desktop.
Night State template for Home Assistant's configuration.yaml to create a 1/0 night entity
sensor:
- platform: template
sensors:
nightstate:
friendly_name: Night State
value_template: "{% if is_state('sun.sun', 'below_horizon') %}1{% else %}0{% endif %}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment