/
briefing.yaml
169 lines (153 loc) · 6.63 KB
/
briefing.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
>
{# Daily Briefing #}
{%- macro getGreeting() -%}
{% if now().strftime('%H')|int < 12 %}
Good morning.
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
{% if when == 'morning' %}
Today is {{states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}.
{% else %}
It is {{ now().strftime("%I:%M %p") }}.
{% endif %}
{%- endmacro -%}
{%- macro getWeather() -%}
The Weather in Zagreb is {{states('sensor.accuweather_apparent_temperature')|round}} degrees
{% if is_state('weather.accuweather', 'rainy') %}
{{ [
'with rain.',
'with showers.'
] | random }}
{% elif is_state('weather.accuweather', 'cloudy') %}
{{ [
'with clouds.',
'with cloudy skies.'
] | random }}
{% elif is_state('weather.accuweather', 'partlycloudy') %}
{{ [
'with some clouds.',
'with partly cloudy skies.',
'with scattered clouds'
] | random }}
{% elif is_state('weather.accuweather', 'sunny') %}
{% if is_state('sun.sun', 'above_horizon') %}
{{ [
'and sunny.',
'with sun.'
] | random }}
{% else %}
{{ [
'and clear.',
'with clear skies.'
] | random }}
{% endif %}
{% else %}
and {{ states.weather.accuweather.state }}
{% endif %}
{%- endmacro -%}
{%- macro getWeatherAlerts() -%}
{% if is_state('binary_sensor.meteoalarm','on') %}
There are currently Meteoalarm active weather alerts for our area.
{% endif %}
{% if when == 'evening' %}
The overnight forecast says we can expect {{ states.weather.accuweather.state }}.
{% else %}
The current forecast says we should expect {{ states.weather.accuweather.state }}.
{% if is_state('input_boolean.freeze_warning','on') %}
And based on the forecasted low, It will be near or below freezing.
{{ [ 'So, Someone might want to bring the lemon tree in. ',
'Like, the turn water solid kind of cold. Do not leave the lemon tree out to die.',
'I suggest bringing in the plants other wise, the temperature might kill them. And that will be on you.',
'I would say winter is coming. But, based on the weather forecast it appears to be here.',
'I would bring in the plants but I lack legs. And Arms. So I am forced to rely on you. Do not let me down.'
] | random }}
{% endif %}
{% endif %}
{%- endmacro -%}
{%- macro getSun() -%}
{% 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 -%}
{%- macro getClimate() -%}
{%- if is_state('climate.living_room','off') %}
The internal heating is off. The temperature inside is {{ states.climate.living_room.attributes.current_temperature }} degrees.
{%- elif is_state('climate.living_room','heat_cool') %}
The internal air condition will try to keep the temperature between {{ states.climate.living_room.attributes.target_temp_low }} and {{ states.climate.living_room.attributes.target_temp_high }}.
{% else %}
The internal heating is set to {{ states.climate.living_room.state }} with a current temperature of {{ states.climate.living_room.attributes.current_temperature }} which is
{%- if states.climate.living_room.attributes.current_temperature | int - states.climate.living_room.attributes.temperature | int |round > 0 %}
{{ states.climate.living_room.attributes.current_temperature | int - states.climate.living_room.attributes.temperature | int }} degrees above
{%- elif states.climate.living_room.attributes.current_temperature | int - states.climate.living_room.attributes.temperature | int |round < 0 %}
{{ (states.climate.living_room.attributes.current_temperature | int - states.climate.living_room.attributes.temperature | int) | abs }} degrees below
{% else %}
right at
{% endif %}
the set point of {{ states.climate.living_room.attributes.temperature }}
degrees.
{%- endif -%}
And The internal humidity is currently {{ states.climate.living_room.attributes.current_humidity }} percent.
The balcony is {{states.sensor.balcony_temperature.state|round}} degrees with a humidity of {{states.sensor.balcony_humidity.state|round}} percent.
{%- endmacro -%}
{%- macro getEvents() -%}
{% if states.sensor.anniversary_wedding.state | int == 1 %}
Tomorrow is our wedding anniversary.
{% endif %}
{%- endmacro -%}
{%- macro getLukaCalendar() -%}
{% if is_state('calendar.luka_school', 'on') %}
Luka has {{ states.calendar.luka_school.attributes.message }} today as well!
{% endif %}
{%- endmacro -%}
{%- macro getZitaCalendar() -%}
{% if is_state('calendar.zita_school', 'on') %}
Zita has {{ states.calendar.zita_school.attributes.message }} today as well!
{% endif %}
{%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
{%- macro cleanup(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }} {% endfor -%}
{%- endmacro -%}
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{{ getGreeting() }}
{{ getEvents() }}
{{ getWeather() }}
{{ getWeatherAlerts() }}
{{ getClimate() }}
{{ getSun() }}
{{ getLukaCalendar() }}
{{ getZitaCalendar() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}