Extract all Attributes from an Entity

Hi all,

there is an awesome weather information integration by the German Weather Service, DWD (Deutscher Wetterdienst (DWD) Weather Warnings - Home Assistant). Unfortunately, they are saving all information inside a single entity’s attribute. It looks like this:

Now, today there are 2 warnings, so they just add “Warning 2” to the “Warning 1”:

Now, what I would like to do is to have a dashboard in HA that shows:

  • Warning x Name
  • Warning x Description
  • Warning x Level
  • Warning x Headline
  • Warning x start + Warning x end

The problem is, as you can probably see, that this must be adaptive to the amount of warnings that are currently set.

I have never done anything like this, so I don’t even know where to start here :frowning:

I found this thread, though:

But I cannot find the custom card in HACS. There is only 1 card that matches the string “auto”:

Any other idea?

Add as a custom repository in hacs.

I do not know what you mean. Please add 1 or more sentences to your explanation.

3 sentences:

  1. Select “custom repositories” in a menu on HACS page.
  2. In a displayed popup: add a path to a custom github repo for a particular custom card, select “Lovelace” as a category.
  3. Search again and add the auto-entities card.

I know how to add repos in hacs, but thanks.

It appears the following is the github repo in question:

Then next time consider adding more sentences when asking questions.

Auto-entities card is a default HACS card. I just searched and it’s in there

Your hacs looks different to mine ?

or even more specifically you might be able to use the entity attributes card:

But I generally do the same thing with my NWS alerts integration (adding all the info as attributes) so you could look at the examples I use to extract the data and display it on a Lovelace page. Of course you’ll need to just use it as a framework tho and change it to meet your needs.

I had the same problem with the BOM Australia Intergration.
See this link and it will give you the answers.

Using Brisbane as the location as it currently has 2 flood alerts…

`response_timestamp: 2022-05-18T00:11:45Z
copyright: This Application Programming Interface (API) is owned by the Bureau of Meteorology (Bureau). You must not use, copy or share this API without express permission from the Bureau. Please contact us for more information. Follow this link http://www.bom.gov.au/inside/contacts.shtml to view our contact details.
attribution: Data provided by the Australian Bureau of Meteorology
warnings:

id: QLD_RC097_IDQ20805
type: flood_warning
title: Flood Warning for Brisbane River downstream of Wivenhoe Dam
short_title: Flood Warning
state: QLD
warning_group_type: major
issue_time: ‘2022-05-17T22:51:08Z’
expiry_time: ‘2022-05-19T01:51:08Z’
phase: renewal
id: QLD_RC099_IDQ20815
type: flood_warning
title: Flood Warning for Logan River downstream of Yarrahappini
short_title: Flood Warning
state: QLD
warning_group_type: major
issue_time: ‘2022-05-16T23:49:51Z’
expiry_time: ‘2022-05-18T02:49:51Z’
phase: final
friendly_name: Brisbane Warnings`

This will list all warnings…

{%- for state in state_attr('sensor.brisbane_warnings', 'warnings') -%}
{{state.phase | upper}} - {{ state.title}}
{% endfor %}

RENEWAL - Flood Warning for Brisbane River downstream of Wivenhoe Dam
FINAL - Flood Warning for Logan River downstream of Yarrahappini

This will list only those that match a particular string in the title in this case. I have chosen “Brisbane” to distinguish the two, but you could search instead for “Thunderstorm” or choose another attribute to match by e.g. warning_group_type.

{% for state in state_attr('sensor.brisbane_warnings', 'warnings') -%}
{%- if 'Brisbane' in state.title %}
{{state.phase | upper}} - {{ state.title}}
{%- endif -%}
{%- endfor -%}

RENEWAL - Flood Warning for Brisbane River downstream of Wivenhoe Dam

Below is a Template Sensor. It shows “No Warning” if there is no matching warnings, & lists the warnings if they match. This one checks for a match of “Thunderstorm” in the title. Make sure you fix the indenting. :slight_smile:

sensor:
name: Brisbane_Thunderstorm_Warning
state: >
{%- set ns = namespace(result=[]) -%}
{% for state in state_attr('sensor.brisbane_warnings', 'warnings') -%}
{%- if 'Thunderstorm' in state.title %}
{% set ns.result = ns.result + [state.title + "\n"] %}
{%- endif -%}
{%- endfor -%}
{% if ns.result|count == 0 %}
{{"No Warnings"}}
{% else %}
{{ ns.result | list | join() }}
{% endif %}

The below gives me a sensor for the weather warning phase output in words. ‘new’ NEW and RENEWAL, ‘update’ UPDATE, ‘downgrade’ DOWNGRADE, ‘final’ FINAL, ‘cancelled’ CANCELLED

  - platform: template
    sensors:
        weather_warning_phase:
              entity_id: sensor.devonport_warnings
              friendly_name: "Weather Warning Phase"
              value_template: >-
                {%- for state in state_attr('sensor.devonport_warnings', 'warnings') -%}
                {%- if 'new' in state.phase %}
                {{state.phase | upper}}
                {%- elif 'update' in state.phase %}
                {{state.phase | upper}}
                {%- elif 'downgrade' in state.phase %}
                {{state.phase | upper}}
                {%- elif 'final' in state.phase %}
                {{state.phase | upper}}
                {%- elif 'cancelled' in state.phase %}
                {{state.phase | upper}}
                {%- endif -%}
                {%- endfor -%}