home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.06k stars 29.72k forks source link

Templating problem #25577

Closed Dinth closed 5 years ago

Dinth commented 5 years ago

Home Assistant release with the issue:

0.96.5

Operating environment (Hass.io/Docker/Windows/etc.):

Hass in Docker

Component/platform:

template sensor

Description of problem:

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

      meteoalarm_description:
        value_template: "{{ states.binary_sensor.meteoalarm.attributes.description | string }}"
        friendly_name: "Description"

Additional information: "{{ states.binary_sensor.meteoalarm.attributes.description | string }}" works perfectly fine in "Templates" tab of Developer Tools, but if copied and pasted into value_template: field of template sensor, the sensor's value becomes "unknown"

Here are all binary_sensor.meteoalarm attributes:

language: en-GB
category: Met
event: Yellow Rain Warning
responseType: Prepare
urgency: Immediate
severity: Moderate
certainty: Likely
effective: 2019-07-31T00:00:00+00:00
onset: 2019-07-31T00:00:00+00:00
expires: 2019-08-01T00:00:00+00:00
senderName: Go to UK Met Office
headline: Yellow Rain Warning for United Kingdom - East of England
description: ain and some thunderstorms bringing a chance of flooding and travel disruption. Spray and flooding could lead to difficult driving conditions and some road closures. Delays or cancellations to train and bus services are possible. Some communities may be cut off by flooded roads. Homes and businesses could be flooded, causing damage to some buildings. Possible power cuts due to flooding or lightning. There is a slight chance that power cuts could occur and other services to some homes and businesses could be lost.
instruction: BE AWARE of the potential for localised flooding of a small number of properties, with local disruption to outdoor activities. Difficult driving conditions due to reduced visibility and aquaplaning
web: http://meteoalarm.eu/en_UK/0/0/UK012.html
attribution: Information provided by MeteoAlarm
friendly_name: meteoalarm
device_class: safety
Dinth commented 5 years ago

Just wanted to add that all other attributes here work fine. I have also tried changing {{ states.binary_sensor.meteoalarm.attributes.description | string }} to {{ state_attr("binary_sensor.meteoalarm", "description") | string }}' and im seeing exactly same behaviour

Dinth commented 5 years ago

Here's the original XML from meteoalarm website:


<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <atom:link href="http://meteoalarm.eu/documents/rss/uk/UK012.rss" rel="self" type="application/rss+xml"/>
        <title>Meteoalarm United Kingdom, East of England</title>
        <link>https://www.meteoalarm.eu/en_UK/0/0/UK012.html</link>
        <description>Metoalarm actual warnings from United Kingdom, East of England</description>
        <ttl>10</ttl>
        <language>eng</language>
        <item>
            <title>East of England</title>
            <link>https://www.meteoalarm.eu/en_UK/0/0/UK012.html</link>
            <description><![CDATA[<table border="0" cellspacing="0" cellpadding="3"><tr><th colspan="3" align="left">Today</th></tr><tr><td width="28"><img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l2-t3.jpg" alt="awt:3 level:2"></td><td><b>From: </b><i>30.07.2019 04:00 CET</i><b> Until: </b><i>31.07.2019 01:00 CET</i></td></tr><tr><td width="28"></td><td>Thunderstorms bring a chance of flooding in places along with possible travel disruption. There is a small chance that homes and businesses could be flooded quickly, with damage to some buildings from floodwater, lightning strikes, hail or strong winds. There is a small chance of fast flowing or deep floodwater causing danger to life. Where flooding or lightning strikes occur, there is a chance of delays and some cancellations to train and bus services. Spray and sudden flooding could lead to difficult driving conditions and some road closures. There is a slight chance that power cuts could occur and other services to some homes and businesses could be lost.</td></tr><tr><th colspan="3" align="left"><br />Tomorrow</th></tr><tr><td width="28"><img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l2-t10.jpg" alt="awt:10 level:2"></td><td><b>From: </b><i>31.07.2019 01:00 CET</i><b> Until: </b><i>01.08.2019 01:00 CET</i></td></tr><tr><td width="28"></td><td>Heavy rain and some thunderstorms bringing a chance of flooding and travel disruption. Spray and flooding could lead to difficult driving conditions and some road closures. Delays or cancellations to train and bus services are possible. Some communities may be cut off by flooded roads. Homes and businesses could be flooded, causing damage to some buildings. Possible power cuts due to flooding or lightning. There is a slight chance that power cuts could occur and other services to some homes and businesses could be lost</td></tr><tr><td width="28"><img border="1" src="https://www.meteoalarm.eu/documents/rss/wflag-l2-t3.jpg" alt="awt:3 level:2"></td><td><b>From: </b><i>30.07.2019 04:00 CET</i><b> Until: </b><i>31.07.2019 01:00 CET</i></td></tr><tr><td width="28"></td><td>Thunderstorms bring a chance of flooding in places along with possible travel disruption. There is a small chance that homes and businesses could be flooded quickly, with damage to some buildings from floodwater, lightning strikes, hail or strong winds. There is a small chance of fast flowing or deep floodwater causing danger to life. Where flooding or lightning strikes occur, there is a chance of delays and some cancellations to train and bus services. Spray and sudden flooding could lead to difficult driving conditions and some road closures. There is a slight chance that power cuts could occur and other services to some homes and businesses could be lost.</td></tr></table>]]></description>
            <pubDate>Tue, 30 Jul 2019 11:42:02 +0200</pubDate>
            <guid isPermaLink="false">de4ef86dec2f2b4e5cc73b7c20109d3e</guid>
        </item>
    </channel>
</rss>```
Dinth commented 5 years ago

Actually i just realised that description is longer than 255 characters. Truncating it to 250 fixes the issue.