custom-components / weatheralerts

A sensor that gives you weather alerts from alerts.weather.gov.
MIT License
123 stars 15 forks source link

Template sensors reporting -- data #76

Open DMEbner opened 1 year ago

DMEbner commented 1 year ago

Hello! When I deploy this integration I get a sensor that is "sensor.county". When I add that to a dashboard, it'll give me the number of current alerts (as expected).

However, when I try and display one of the template sensors (either in an entity card or mushroom template card (or any other template card) all attributes come back as "--".

I tried this one from the instructions without luck: card: content: >


{% set alerts = [ "sensor.weatheralerts_1_alert_1", "sensor.weatheralerts_1_alert_2", "sensor.weatheralerts_1_alert_3", "sensor.weatheralerts_1_alert_4", "sensor.weatheralerts_1_alert_5"] %} {% for alert in alerts if is_state(alert, 'on') %} {% if 'warning' or 'severe' in state_attr( alert, 'display_title')|lower() %} <font color="red"> {% endif %} {{ state_attr( alert, 'display_title') }} {%- if 'warning' or 'severe' in state_attr( alert, 'display_title')|lower() -%} {%- endif %}
{{ state_attr( alert, 'display_message') }} {% if loop.last %} {% else %}
{% endif %} {% endfor %} title: Weather Alerts type: markdown conditions:

I tried something simpler when there were two alerts and still couldn't get anything to display:

type: entities entities:

Can anyone provide a little bit of help displaying the attributes from the alert text?

Cheers!

regularguy01 commented 1 year ago

I get a sensor that is "sensor.county".

did you rename the sensor? from the header of the weatheralerts_1 yaml file. To use this package go to your Home Assistant web interface, go to

#    Configuration, then Entities, and find the new sensor.ZoneName sensor
#    that was created for your location (ZoneName will likely be the name of
#    your county). Rename that sensor Entity ID to sensor.weatheralerts_1 and
#    you shouldn't need to alter anything else in this yaml package to make it
#    all work.