Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106313

When templating a timestamp, what's a correct ELSE fallback?

$
0
0

Hi

I’m using this template:

value_template: >
          {% set dateraw_match = value | regex_findall('1\\-0\\:1\\.6\\.0\\(([0-9]{12})') %}
          {% if dateraw_match %}
            {{ as_timestamp(strptime(dateraw_match[0], '%y%m%d%H%M%S')) | timestamp_local }}
          {% else %}
            {{ "unavailable" }}
          {% endif %}

to read this data:

1-0:1.6.0(241204154500W)(05.473*kW)

from a Youless sensor RAW data page (W peak usage timestamp) with the REST integration.

When templating other data, like the actual W usage or W peak, I fallback to “{% else %} 0 …”
But what is the correct fallback for a timestamp? {{“unavailable”}} generates errors in the log.

“sensor.piekvermogen_tijd rendered invalid timestamp: unavailable”

10 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 106313

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>