weatheralerts icon indicating copy to clipboard operation
weatheralerts copied to clipboard

Template sensors reporting -- data

Open DMEbner opened this issue 1 year ago • 1 comments

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() %} {% 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:
  • entity: sensor.weatheralerts_1_alerts_are_active state: 'Yes' type: conditional

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

type: entities entities:

  • type: custom:mushroom-template-card icon: mdi:weather-lightning-rainy icon_color: |- {% if state_attr('sensor.weatheralerts_1', '2') mdi:alert-box {% else %} mdi:alert-circle-check-outline {% endif %} icon: >- {% if state_attr('sensor.weatheralerts_1', '2') red {% else %} green {% endif %}

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

Cheers!

DMEbner avatar Apr 05 '23 18:04 DMEbner

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.

regularguy01 avatar May 03 '23 15:05 regularguy01