Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template sensors reporting -- data #76

Open
DMEbner opened this issue Apr 5, 2023 · 1 comment
Open

Template sensors reporting -- data #76

DMEbner opened this issue Apr 5, 2023 · 1 comment

Comments

@DMEbner
Copy link

DMEbner commented Apr 5, 2023

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!

@regularguy01
Copy link

regularguy01 commented May 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants