Dear all,
I started to use Hassio about a year ago and I am very happy with the system.
I have added the DWD Deutscher Wetterdienst Warnungen and here is where I hit a wall.
I have a value template as follow:
- platform: template
sensors:
warnung_1:
friendly_name: Warnung 1
value_template: "{{ state_attr('sensor.wetterwarnung_em_1_current_warning_level', 'warning_1_headline') }}. Hinweis {{ state_attr('sensor.wetterwarnung_em_1_current_warning_level', 'warning_1_description') }} {{- '\n' -}} Anweisung {{ state_attr('sensor.wetterwarnung_em_1_current_warning_level', 'warning_1_instruction') }} {{- '\n' -}} Gültig bis zum {{ states('sensor.wetter_warnung_1_ende') }}. Klicken auf unteres Element um mehr zu sehen!"
The above code in template-dev(editor) returns the correct results and shows the warning number 1 and a full text as I expected it to be.
However, when I use the sensor in a lovelace card it returns:
Warnung 1: Unbekannt (unknown)
If I click on the relevant sensor, all is good and it shows me the attributes correctly.
Can someone help me identifying my errors.
Home Assistant 0.93.1
Hassio in a docker container
Raspberry Pi 3+
The following errors are reported:
Error doing job: Task exception was never retrieved
17:17 core.py (ERROR) - message first occured at 17:02 and shows up 3 times
Unhandled exception
17:04 /usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py (ERROR) - message first occured at 17:03 and shows up 2 times
Error doing job: Fatal error on transport
17:04 /usr/local/lib/python3.7/site-packages/homeassistant/core.py (ERROR) - message first occured at 17:03 and shows up 3 times
The attributes I am using are mentioned by the sensor:
attribution: Data provided by DWD region_name: xxxx region_state: BW last_update: 2020-01-30T17:06:41+01:00
warning_count: 1
warning_1_name: SCHWERE STURMBÖEN
warning_1_level: 3
warning_1_type: 1
warning_1_headline: Amtliche WARNUNG vor SCHWEREN STURMBÖEN
warning_1_description: Es treten oberhalb 1000 m schwere Sturmböen mit Geschwindigkeiten zwischen 80 km/h (22m/s, 44kn, Bft 9) und 95 km/h (26m/s, 51kn, Bft 10) aus südwestlicher Richtung auf. In exponierten Lagen muss mit orkanartigen Böen bis 105 km/h (29m/s, 56kn, Bft 11) gerechnet werden.
warning_1_instruction: ACHTUNG! Hinweis auf mögliche Gefahren: Vereinzelt können zum Beispiel Bäume entwurzelt und Dächer beschädigt werden. Achten Sie besonders auf herabstürzende Äste, Dachziegel oder Gegenstände.
warning_1_start: 2020-01-30T16:00:00+01:00
warning_1_end: 2020-01-31T10:00:00+01:00
friendly_name: wetterwarnung em 1
Current Warning Level icon: mdi:close-octagon-outline
If I put in a manually created sensor only 1 attribute, it seems to work.
State values are limited to 255 characters only. Any attempt to set it to a string with more than that many characters will cause an error. In my experience, the state value will be the last valid value. In this case, I would expect it to always be ‘unknown’ since it would never have a valid value.
Attributes have no character limit.
I didn’t count, but I’m pretty certain there are more than 255 characters there.
Also, attempting to preserve newlines in a state has never worked for me. The entire state will be a single line, no matter what you do.
If you want to show attributes on a lovelace card, you’ll have to use a custom card.
Bummer,
you are right, I have counted and ended up with 429 characters.
Meanwhile I have bit by bit used the states attributes and it seems to me there is one of the attributes “warning_1_description” which might cause the issue, removing this one it displays everything all right.
I am going to try your suggestion with attributes card.
Thanks for that!
Dietger
Not quite solved, so I leave this one open for now.
But I might have found a bug?
So, what I found is the following:
In the DWD weather attributes, if there is anything after the “warning_1_description:”
such as in the example before, it returns an error as described.
Also in cases where I templated the above as 1 single template.
Playing with the configuration I just had a warning where there was only the “warning_1_description” and nothing following, so no “warning_1_instruction” and then the description shows up. No error message created.
Hey @dimafemabo, i commented the issue you created on github and don’t think it’s an issue. There’s also no ‘codeowner’ in the manifest.json of the componenet so there’s only a litlle chance that someone looks at it.
But you gave me the idea to show the warnings in a markdown card.
Here’s what i have:
Thanks Rainer,
I changed the sensor name and used what you provided.
I am banging my head against the wall here, because I seem to miss some important thing.
My card looks like below:
I am using the Lovelace frontend to generate the card and choose “markdown”, switched to the dev-template editor everything shows up perfectly.
Somehow it doesn’t pick up the template values from within the card.
Do I have to add things to the config yaml?
Many thanks for having a look at it, really appreciated!
Cheers
When I have a quiet moment I migth upgrade to the latest version, see if this solves the issue then.
Might take me a while to get this done.
Thanks so far.
Brilliant and many thanks!
I got a good reason to update, at least to version .99
See what effect it will have on my well established, working environment
Thanks for all your help, great job!