main
Stuart Lamont 3 years ago
parent 32523c106b
commit 3c1ef77eb1

@ -1,5 +1,7 @@
# Notes for creating a morning briefing from my smart home. # Notes for creating a morning briefing from my smart home.
[Back to README](./README.md)
## Determining the data points that we want ## Determining the data points that we want
__Current Temperature:__ `{{ state_attr ('weather.home','temperature') }}` __Current Temperature:__ `{{ state_attr ('weather.home','temperature') }}`

@ -28,15 +28,13 @@ and {{ states('sensor.master_bedroom_purifier_temperature') }} °C in the Master
### But there's a better way! ### But there's a better way!
We're going to crate an Array of Dictionaries, and iterate through the array. We're going to crate an Array of Dictionaries, and iterate through the array.
The Dictionary Key is the `entity_id` of the temperature sensor in Home Assistant.
The Dictionary Value is the Name of the room we want our TTS engine to say.
For the TTS to sound more 'natural' I've added ", and" to the `name` of the second last item in the array
```jinja ```jinja
{% set inside_temps = { {% set inside_temps = {
# A List of Dictionaries
# The Dictionary Key is the `entity_id` of the temperature sensor in Home Assistant
# the Dictionary Value is the Name of the room we want our TTS engine to say.
# For the TTS to sound more 'natural' I've added ", and" to the second last item in the array
'sensor.temperature_dining': 'Dining Room', 'sensor.temperature_dining': 'Dining Room',
'sensor.lounge_ac_inside_temperature': 'Lounge Room', 'sensor.lounge_ac_inside_temperature': 'Lounge Room',
'sensor.temperature_office': 'Office, and', 'sensor.temperature_office': 'Office, and',
@ -44,8 +42,6 @@ We're going to crate an Array of Dictionaries, and iterate through the array.
} %} } %}
Inside it's currently Inside it's currently
{% for sensor, room in inside_temps.items() %} {% for sensor, room in inside_temps.items() %}
{{ states(sensor) }} °C in the {{ room }} {{ states(sensor) }} °C in the {{ room }}

@ -3,46 +3,60 @@ announce_weather_details:
sequence: sequence:
- service: notify.alexa_media - service: notify.alexa_media
data: data:
message: "\n{% set current_temp = state_attr ('weather.home','temperature') message: >_
| float %} {% set wind_bearing = state_attr('weather.home', 'wind_bearing') {% set current_temp = state_attr ('weather.home','temperature') | float %}
| float %} {% set wind_speed = state_attr('weather.home','wind_speed') | float {% set current_condition = states('weather.home') %}
%} {% set current_condition = states('weather.home') %}\n\n{% if current_condition
== 'partlycloudy' %} \n {% set current_condition = 'Partly Cloudy' %}\n{% {% if current_condition == 'partlycloudy' %}
endif %}\n{% set directions = { (0.0, 11.25): 'North', (11.25, 33.75): 'North {% set current_condition = 'Partly Cloudy' %}
North East', (33.75, 56.25): 'North East', (56.25, 78.75): 'East North East', {% endif %}
(78.75, 101.25): 'East', (101.25, 123.75): 'East South East', (123.75, 146.25):
'South Eeast', (146.25, 168.75): 'South South East', (168.75, 191.25): 'South', Outside, It's {{ current_condition }} and {{ current_temp }} degrees Celsius.
(191.25, 213.75): 'South South West', (213.75, 236.25): 'South West', (236.25,
258.75): 'West South West', (258.75, 281.25): 'West', (281.25, 303.75): 'West {% set weather = state_attr('weather.home', 'forecast') %}
North West', (303.75, 326.25): 'North West', (326.25, 348.75): 'North Nort {% set high_temp = weather[0].temperature %}
West', (348.75, 360.0): 'North' } %}\nOutside, It's {{ current_condition }} {% set low_temp = weather[0].templow %}
and {{ current_temp }} °C.\n{% set weather = state_attr('weather.home', 'forecast')
%} {% set high_temp = weather[0].temperature %} {% set low_temp = weather[0].templow {% for entry in weather %}
%}\n{% for entry in weather %}\n {% if entry.temperature > high_temp %}\n {% if entry.temperature > high_temp %}
\ {% set high_temp = entry.temperature %}\n {% endif %}\n {% if entry.templow {% set high_temp = entry.temperature %}
< low_temp %}\n {% set low_temp = entry.templow %}\n {% endif %}\n {% {% endif %}
if entry.condition == 'rainy'%} \n It looks like there's rain expected {% if entry.templow < low_temp %}
at around {{ entry.datetime.split('T')[1][:2] }} o'clock. \n You might {% set low_temp = entry.templow %}
want to take an umbrella if you're planning on leaving the house.\n {% endif {% endif %}
%}\n{% endfor %}\n{% if high_temp > 30 %} \n It's going to be a hot one \n{% {% if entry.condition == 'rainy'%}
elif 20 < high_temp < 30 %} \n It should be a warm day \n{% elif 15 < high_temp It looks like there's rain expected at around {{ entry.datetime.split('T')[1][:2] }} o'clock. You might want to take an umbrella if you're leaving the house.
< 20 %} \n It's going to be a pretty mild temperature today \n{% elif 10 {% endif %}
< high_temp < 15 %} \n It seems like it'll be a bit chilly today\n{% elif {% endfor %}
0 < high_temp < 10 %} \n It's going to be a cold day \n{% else %} \n It's
going to be freezing today \n{% endif %}\nThe forecast high is {{ high_temp {% if high_temp > 30 %}
}} °C.\nWith a Low of {{ low_temp }} °C . {% if low_temp > 30 %} \n Wow. It's going to be a hot one
That's hot! \n{% elif 20 < low_temp < 30 %}\n it's not going to go below {% elif 20 < high_temp < 30 %}
20 degrees today. \n{% elif 10 < low_temp < 20 %} \n it might get a little It should be a warm day
bit chilly. \n{% elif 0 < low_temp < 10 %} \n That's cold. \n{% else %} \n {% elif 15 < high_temp < 20 %}
\ Absolutely freezing! \n{% endif %}\n{% if wind_speed > 50 %}\n Its very It's going to be a pretty mild temperature today
windy outside.\n{% elif 40 < wind_speed < 50 %}\n It's pretty windy at the {% elif 10 < high_temp < 15 %}
moment\n{% elif 30 < wind_speed < 40 %}\n Theres a strong breeze right now\n{% It seems like it'll be a bit chilly today
elif 20 < wind_speed < 30 %}\n It's a bit breezy outside\n{% elif 10 < wind_speed {% elif 0 < high_temp < 10 %}
< 20 %}\n There's a light breeze\n{% else %}\n it's quite still\n{% endif It's going to be a cold day
%} {% for rng, direction in directions.items() %} \n {% if wind_bearing >= {% else %}
rng[0] and wind_bearing < rng[1] %} \n The wind is currently blowing from It's going to be freezing today
the {{ direction }} direction, at {{ wind_speed }} kilometres per hour \n {% endif %}
\ {% endif %}\n{% endfor %} "
The forecast high is {{ high_temp }} °C.
With a Low of {{ low_temp }} °C .
{% if low_temp > 30 %}
Wow. That's hot!
{% elif 20 < low_temp < 30 %}
it's not going to go below 20 degrees today.
{% elif 10 < low_temp < 20 %}
it might get a little bit chilly.
{% elif 0 < low_temp < 10 %}
That's cold.
{% else %}
Absolutely freezing!
{% endif %}
target: target:
- media_player.dining_room_echo_plus - media_player.dining_room_echo_plus
mode: single mode: single
@ -51,53 +65,58 @@ announce_time:
sequence: sequence:
- service: notify.alexa_media - service: notify.alexa_media
data: data:
message: '" {% set current_time = states(''sensor.time'') %} {% set hour = current_time.split('':'')[0] message: >_
| int %} {% set minute = current_time.split('':'')[1] %} {% set current_time = states('sensor.time') %}
{% set hour = current_time.split(':')[0] | int %}
{% if hour >= 6 and hour < 12 %} Good morning! {% elif hour >= 12 and hour {% set minute = current_time.split(':')[1] %}
< 18 %} Good afternoon! {% elif hour >= 18 or hour < 6 %} Good evening! {%
endif %}
{% set suffix = ''AM'' if hour < 12 else ''PM'' %} {% set hour_12 = hour if {% if hour >= 6 and hour < 12 %}
hour <= 12 else hour - 12 %} Good morning!
{% elif hour >= 12 and hour < 18 %}
Good afternoon!
{% elif hour >= 18 or hour < 6 %}
Good evening!
{% endif %}
It''s currently {{ hour_12 }}:{{ minute }} {{ suffix }}." {% set suffix = ''AM'' if hour < 12 else 'PM' %}
{% set hour_12 = hour if hour <= 12 else hour - 12 %}
' It's currently {{ hour_12 }}:{{ minute }} {{ suffix }}.
target: target:
- media_player.dining_room_echo_plus - media_player.dining_room_echo_plus
mode: single mode: single
announce_internal_temperatures: announce_quote_of_the_day:
alias: Announce Quote of the Day alias: Announce Quote of the Day
sequence: sequence:
- service: notify.alexa_media - service: notify.alexa_media
data: data:
message: ' The {{ state_attr( ''sensor.quote_sensor'', ''category'' ) }} Quote message: >_
of the day is by {{ state_attr( ''sensor.quote_sensor'', ''author'' ) }}. They The {{ state_attr( ''sensor.quote_sensor'', ''category'' ) }} \
said. {{ states(''sensor.quote_sensor'') }} ' Quote of the day is by {{ state_attr( ''sensor.quote_sensor'', ''author'' ) }}.
They said. {{ states(''sensor.quote_sensor'') }}
target: target:
- media_player.dining_room_echo_plus - media_player.dining_room_echo_plus
mode: single mode: single
icon: mdi:comment-quote icon: mdi:comment-quote
announce_dad_joke_of_the_day: announce_pending_updates:
alias: Announce Pending Updates alias: Announce Pending Updates
sequence: sequence:
- service: notify.alexa_media - service: notify.alexa_media
data: data:
message: '{% if states(''update.home_assistant_operating_system_update'') == message: >_
''on'' %} There''s a Home Assistant O S Update pending. The Installed version {% set entities = {
is {{ state_attr(''update.home_assistant_operating_system_update'', ''installed_version'') 'update.home_assistant_operating_system_update': 'Home Assistant OS Update',
}}. The Available version is {{ state_attr(''update.home_assistant_operating_system_update'', 'update.home_assistant_core_update': 'Home Assistant Core',
''latest_version'') }}. {% endif %} {% if states(''update.home_assistant_core_update'') 'update.esphome_update': 'E S P Home',
== ''on'' %} There''s a Home Assistant Core Update pending. The Installed } %}
version is {{ state_attr(''update.home_assistant_core_update'', ''installed_version'')
}}. The Available version is {{ state_attr(''update.home_assistant_core_update'', {% for entity, name in entities.items() %}
''latest_version'') }}. {% endif %} {% if states(entity) == 'on' %}
There's a {{ name }} pending.
{% if states(''update.esphome_update'') == ''on'' %} There''s an E S P Home The Installed version is {{ state_attr( entity, 'installed_version') }}
Update pending. The Installed version is {{ state_attr(''update.esphome_update'', The Available version is {{ state_attr(entity, 'latest_version') }}
''installed_version'') }}. The Available version is {{ state_attr(''update.esphome_update'', {% endif %}
''latest_version'') }}. {% endif %} ' {% endfor %}
target: target:
- media_player.dining_room_echo_plus - media_player.dining_room_echo_plus
mode: single mode: single
@ -130,32 +149,77 @@ announce_end_of_briefing:
target: target:
- media_player.dining_room_echo_plus - media_player.dining_room_echo_plus
mode: single mode: single
test_everywhere_announcement: announce_inside_temperatures:
alias: Test Everywhere Announcement alias: Announce Inside Temperatures
sequence: sequence:
- service: notify.alexa_media - service: notify.alexa_media
data: data:
data: data:
type: tts type: tts
message: '" This is a Test "' message: >_
{% set inside_temps = {
'sensor.temperature_dining': 'Dining Room',
'sensor.lounge_ac_inside_temperature': 'Lounge Room',
'sensor.temperature_office': 'Office, and',
'sensor.master_bedroom_purifier_temperature': 'Master Bedroom'
} %}
Inside it's currently
{% for sensor, room in inside_temps.items() %}
{{ states(sensor) }} °C in the {{ room }}
{% endfor %}
target: target:
- media_player.dining_room_echo_plus - media_player.dining_room_echo_plus
- media_player.bedroom_echo_dot
- media_player.office_echo_dot
- media_player.spare_room_echo_dot
mode: single mode: single
announce_inside_temperatures: announce_wind_details:
alias: Announce Inside Temperatures alias: Announce Wind Details
sequence: sequence:
- service: notify.alexa_media - service: notify.alexa_media
data: data:
data: message: >_
type: tts {% set wind_bearing = state_attr('weather.home', 'wind_bearing') | float %}
message: ' Inside it''s currently {{ states(''sensor.temperature_dining'') }} {% set wind_speed = state_attr('weather.home','wind_speed') | float %}
°C in the Dining Room, {{ states(''sensor.lounge_ac_inside_temperature'')
}} °C in the Lounge, {{ states(''sensor.temperature_office'')}} °C in the {% set directions = {
office, and {{ states(''sensor.master_bedroom_purifier_temperature'') }} °C (0.0, 11.25): 'North',
in the Master Bedroom. ' (11.25, 33.75): 'North North East',
target: (33.75, 56.25): 'North East',
- media_player.dining_room_echo_plus (56.25, 78.75): 'East North East',
(78.75, 101.25): 'East',
(101.25, 123.75): 'East South East',
(123.75, 146.25): 'South Eeast',
(146.25, 168.75): 'South South East',
(168.75, 191.25): 'South',
(191.25, 213.75): 'South South West',
(213.75, 236.25): 'South West',
(236.25, 258.75): 'West South West',
(258.75, 281.25): 'West',
(281.25, 303.75): 'West North West',
(303.75, 326.25): 'North West',
(326.25, 348.75): 'North Nort West',
(348.75, 360.0): 'North'
} %}
{% if wind_speed > 50 %}
Its very windy outside.
{% elif 40 < wind_speed < 50 %}
It's pretty windy at the moment
{% elif 30 < wind_speed < 40 %}
Theres a strong breeze right now
{% elif 20 < wind_speed < 30 %}
It's a bit breezy outside
{% elif 10 < wind_speed < 20 %}
There's a light breeze
{% else %}
it's quite still
{% endif %}
{% for rng, direction in directions.items() %}
{% if wind_bearing >= rng[0] and wind_bearing < rng[1] %}
The wind is currently blowing from the {{ direction }} direction, at {{ wind_speed }} kilometres per hour
{% endif %}
{% endfor %}
target: media_player.dining_room_echo_plus
mode: single mode: single
icon: mdi:wind-power

@ -57,4 +57,54 @@
The wind is currently blowing from the {{ direction }} direction, at {{ wind_speed }} kilometres per hour The wind is currently blowing from the {{ direction }} direction, at {{ wind_speed }} kilometres per hour
{% endif %} {% endif %}
{% endfor %} {% endfor %}
``` ```
## Put it all together
```jinja
{% set wind_bearing = state_attr('weather.home', 'wind_bearing') | float %}
{% set wind_speed = state_attr('weather.home','wind_speed') | float %}
{% set directions = {
(0.0, 11.25): 'North',
(11.25, 33.75): 'North North East',
(33.75, 56.25): 'North East',
(56.25, 78.75): 'East North East',
(78.75, 101.25): 'East',
(101.25, 123.75): 'East South East',
(123.75, 146.25): 'South Eeast',
(146.25, 168.75): 'South South East',
(168.75, 191.25): 'South',
(191.25, 213.75): 'South South West',
(213.75, 236.25): 'South West',
(236.25, 258.75): 'West South West',
(258.75, 281.25): 'West',
(281.25, 303.75): 'West North West',
(303.75, 326.25): 'North West',
(326.25, 348.75): 'North Nort West',
(348.75, 360.0): 'North'
} %}
{% if wind_speed > 50 %}
Its very windy outside.
{% elif 40 < wind_speed < 50 %}
It's pretty windy at the moment
{% elif 30 < wind_speed < 40 %}
Theres a strong breeze right now
{% elif 20 < wind_speed < 30 %}
It's a bit breezy outside
{% elif 10 < wind_speed < 20 %}
There's a light breeze
{% else %}
it's quite still
{% endif %}
{% for rng, direction in directions.items() %}
{% if wind_bearing >= rng[0] and wind_bearing < rng[1] %}
The wind is currently blowing from the {{ direction }} direction, at {{ wind_speed }} kilometres per hour
{% endif %}
{% endfor %}
```

Loading…
Cancel
Save

Powered by TurnKey Linux.