Move sunrise/sunset status to a macro #196
This commit is contained in:
@ -168,4 +168,36 @@ It is {{ now().strftime("%I:%M %p") }}.
|
|||||||
"Collin, your bedroom lights are now on."
|
"Collin, your bedroom lights are now on."
|
||||||
] | random }} Goodnight!
|
] | random }} Goodnight!
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro sun_status() %}
|
||||||
|
{% if is_state('sun.sun','below_horizon') %}
|
||||||
|
You have
|
||||||
|
{% set seconds = as_timestamp(states.sun.sun.attributes.next_rising)-now().timestamp() %}
|
||||||
|
{% set hours = seconds / 60 %}
|
||||||
|
{% if seconds / ( 60 * 60 ) > 1 %}
|
||||||
|
{{ (seconds // ( 60 * 60 )) | int }} hours
|
||||||
|
{% else %}
|
||||||
|
{{ (seconds // 60) | int }} minutes
|
||||||
|
{% endif %}
|
||||||
|
{{ [
|
||||||
|
'until the sun rises.',
|
||||||
|
'until the sun is up',
|
||||||
|
'before the sun officially rises.'
|
||||||
|
] | random }}
|
||||||
|
{% else %}
|
||||||
|
You have
|
||||||
|
{% set seconds = as_timestamp(states.sun.sun.attributes.next_setting)-now().timestamp() %}
|
||||||
|
{% set hours = seconds / 60 %}
|
||||||
|
{% if seconds / ( 60 * 60 ) > 1 %}
|
||||||
|
{{ (seconds // ( 60 * 60 )) | int }} hours
|
||||||
|
{% else %}
|
||||||
|
{{ (seconds // 60) | int }} minutes
|
||||||
|
{% endif %}
|
||||||
|
{{ [
|
||||||
|
'until the sun sets for the day.',
|
||||||
|
'until the sun slips below the horizon.',
|
||||||
|
'before the sun officially sets. '
|
||||||
|
]|random }}
|
||||||
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{% from 'formatting.jinja' import cleanup %}
|
{% from 'formatting.jinja' import cleanup %}
|
||||||
{%- macro getReport() -%}
|
{%- macro getReport() -%}
|
||||||
{% from 'speech.jinja' import greeting, today_is %}
|
{% from 'speech.jinja' import greeting, today_is, sun_status %}
|
||||||
{% from 'weather.jinja' import weatherReport %}
|
{% from 'weather.jinja' import weatherReport %}
|
||||||
{% from 'sports.jinja' import sports_updates %}
|
{% from 'sports.jinja' import sports_updates %}
|
||||||
<p>
|
<p>
|
||||||
@ -13,6 +13,10 @@
|
|||||||
{{ today_is() }}
|
{{ today_is() }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{{ sun_status() }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ weatherReport('full','tts') }}
|
{{ weatherReport('full','tts') }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{# Daily Briefing #}
|
{# Daily Briefing #}
|
||||||
{% from 'formatting.jinja' import cleanup %}
|
{% from 'formatting.jinja' import cleanup %}
|
||||||
{%- macro getReport() -%}
|
{%- macro getReport() -%}
|
||||||
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote, today_is %}
|
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote, today_is, sun_status %}
|
||||||
{% from 'status.jinja' import houseStatusReport, tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
|
{% from 'status.jinja' import houseStatusReport, tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
|
||||||
{% from 'easy_time.jinja' import count_the_days %}
|
{% from 'easy_time.jinja' import count_the_days %}
|
||||||
{% from 'weather.jinja' import weatherReport %}
|
{% from 'weather.jinja' import weatherReport %}
|
||||||
@ -20,35 +20,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% if is_state('sun.sun','below_horizon') %}
|
{{ sun_status() }}
|
||||||
You have
|
|
||||||
{% set seconds = as_timestamp(states.sun.sun.attributes.next_rising)-now().timestamp() %}
|
|
||||||
{% set hours = seconds / 60 %}
|
|
||||||
{% if seconds / ( 60 * 60 ) > 1 %}
|
|
||||||
{{ (seconds // ( 60 * 60 )) | int }} hours
|
|
||||||
{% else %}
|
|
||||||
{{ (seconds // 60) | int }} minutes
|
|
||||||
{% endif %}
|
|
||||||
{{ [
|
|
||||||
'until the sun rises.',
|
|
||||||
'until the sun is up',
|
|
||||||
'before the sun officially rises.'
|
|
||||||
] | random }}
|
|
||||||
{% else %}
|
|
||||||
You have
|
|
||||||
{% set seconds = as_timestamp(states.sun.sun.attributes.next_setting)-now().timestamp() %}
|
|
||||||
{% set hours = seconds / 60 %}
|
|
||||||
{% if seconds / ( 60 * 60 ) > 1 %}
|
|
||||||
{{ (seconds // ( 60 * 60 )) | int }} hours
|
|
||||||
{% else %}
|
|
||||||
{{ (seconds // 60) | int }} minutes
|
|
||||||
{% endif %}
|
|
||||||
{{ [
|
|
||||||
'until the sun sets for the day.',
|
|
||||||
'until the sun slips below the horizon.',
|
|
||||||
'before the sun officially sets. '
|
|
||||||
]|random }}
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% set dow = as_timestamp(now()) | timestamp_custom('%A') %}
|
{% set dow = as_timestamp(now()) | timestamp_custom('%A') %}
|
||||||
|
Reference in New Issue
Block a user