Created
June 7, 2021 11:45
-
-
Save elden1337/ba391b49f263dd0b0adee4156be8ac72 to your computer and use it in GitHub Desktop.
Circadian lighting calculator fit for Scandianvian countries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- id: '12345' | |
alias: Light - Circadian lights | |
description: '' | |
trigger: | |
- platform: time_pattern | |
minutes: /10 | |
condition: | |
- condition: template | |
value_template: '{{ states.light|selectattr(''state'',''eq'',''on'')|list|count | |
> 0 }} | |
' | |
action: | |
- service: light.turn_on | |
data_template: | |
color_temp: '{{ states.sensor.colortemp.state }}' | |
entity_id: '{{ states.light|selectattr(''state'',''=='',''on'')|rejectattr(''entity_id'', | |
''=='', ''light.GROUPS_OR_LIGHTS_YOU_WANT_TO_EXCLUDE_EVEN_IF_THEY_ARE_ON'')|map(attribute=''entity_id'')|join('','') | |
}} | |
' | |
mode: queued | |
max: 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- platform: template | |
sensors: | |
colortemp: | |
friendly_name: 'circadian light - color temperature' | |
unit_of_measurement: 'mired' | |
value_template: > | |
{%if states.sun.sun.attributes.elevation > 0%} | |
{%set nightlenPow = ((as_timestamp(states.sun.sun.attributes.next_rising) - as_timestamp(states.sun.sun.attributes.next_setting)) / 3600 / 24)**1.6 %} | |
{%set altitudefactor = states.sun.sun.attributes.elevation * nightlenPow%} | |
{{ (450 - (altitudefactor * 44))|int}} | |
{%else%} | |
{{450}} | |
{%endif%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment