Weather Report - Node-RED
One of the most important things we find in our house is the ability to check the weather to make sure that we can spend time outside. With Home Automation, especially in Home Assistant, we are given so much data that sometimes it's hard to figure out what to do. This also requires to to pass the WAF Rating (Wife Approval Factor) and this one did it, not only did it pass, it passed with flying colors.
Here is the link to Github where you will find the flow.
For how small this is, there is a lot to unpack here. First off, I'm using the amazon-echo-device node to detect the phrase when said to my Alexa device.
Next, I have created in Home Assistant a sensor called last_alexa
to detect which device was last spoken to, so that these can be used by any device in my home. Here is the YAML for Home Assistant to make this sensor.
sensor:
- platform: template
sensors:
last_alexa:
friendly_name: 'Last Alexa'
value_template: >-
{% if is_state_attr('media_player.family_room','last_called', true) %}
media_player.family_room
{% elif is_state_attr('media_player.bedroom','last_called', true) %}
media_player.bedroom
{% elif is_state_attr('media_player.office','last_called', true) %}
media_player.office
{% else %}
none
{% endif %}
Next, it runs through a function that I called Beginning Messages
which is just a list of random phrases so that it can be a little more playful and not so static on its responses. The Say Something node takes the two items: last_alexa
and the return of the Beginning Messages
to send the notification to the Alexa device to respond. Just a side note, that wouldn't need to be used as the following pieces are what make up the message to have Alexa reply with.
Within Home Assistant I use the Weatherbit's weather data to be able to gather weather data, and to my surprise, it actually offers 16 days worth of forecast data. This passes the data to the Compile weather data function which then passes the array of messages to the Alexa device to respond with a Weather Forecast with something like the following:
Here is your 16 day weather forecast... Today, Monday, March 8th will be partly cloudy with a high of 58 degrees and a low of 41 degrees... Tuesday, March 9th will be rainy with a high of 56 degrees and a low of 43 degrees with a 90% chance of rain...