Basically the UpdateCoordinator handles the data grabbing and removes the need to do the old @Throttle method.
It also gives you neat info like:
2021-07-16 12:57:23 DEBUG (MainThread) [custom_components.nws_alerts] Data will be update every 0:05:00
2021-07-16 14:07:37 DEBUG (MainThread) [custom_components.nws_alerts] Finished fetching NWS Alerts data in 0.854 seconds
From what I understand it keeps from bogging down the main HA loop as well. (You might have to confirm this with balloob or frenck tho)
EDIT: Feel free to hit me up on discord if you want to discus further.
deleted the integration from the UI config and tried a yaml config:
2021-07-16 17:36:12 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up nws_alerts platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/nws_alerts/sensor.py", line 44, in async_setup_platform
async_add_entities([NWSAlertSensor(hass, config)], True)
File "/config/custom_components/nws_alerts/sensor.py", line 57, in __init__
super().__init__(hass.data[DOMAIN][entry.entry_id][COORDINATOR])
KeyError: 'nws_alerts'
Formatting of the weather alert.
This is my code for an ALEXA announcement.
service: media_player.play_media
- data:
data:
method: speak
type: announce
message:
I've detected a change in national weather service advisories for the East Valley.
{% for i in range(states('sensor.nws_alert_count') | int) %}
{%- if i > 0 -%}
---------
{%- endif %}
{{ state_attr('sensor.nws_alert_event', 'features')[0].properties.headline }}
{{ state_attr('sensor.nws_alert_event', 'features')[0].properties.description }}
{% endfor %}
service: notify.alexa_media_everywhere
Hi There,
I've detected a change in national weather service advisories for the East Valley.
Flash Flood Watch issued July 21 at 2:01PM MDT until July 25 at 12:00AM MDT by NWS Phoenix AZ
The Flash Flood Watch continues for
* A portion of south central Arizona, including the following areas,
Aguila Valley, Apache Junction/Gold Canyon, Buckeye/Avondale, Cave
Creek/New River, Central Phoenix, Deer Valley, East Valley,
Fountain Hills/East Mesa, Gila Bend, New River Mesa, North
Phoenix/Glendale, Northwest Pinal County, Northwest Valley,
Scottsdale/Paradise Valley, Sonoran Desert Natl Monument, South
Mountain/Ahwatukee, Southeast Valley/Queen Creek, Tonopah Desert
and West Pinal County.
The ALEXA automation works but is quirky in it message.
For example it will say
“Buckeye/ (slash)Avondale, Cave (it will pause because of the line break in the message, then it will say) Creek/New River”
Is there anyway to prevent the pause at the end of the line?