mirror of
https://github.com/Anashost/HA-Animated-cards.git
synced 2026-10-15 07:46:57 +00:00
Update climate_collection.md
This commit is contained in:
1 parent
5bb0b01b3d
commit
25f81ff96c
1 file changed
+20
-4
+20
-4
@@ -583,14 +583,30 @@ custom_fields:
|
||||
unique_id: temptrend_24h
|
||||
state: >
|
||||
{% set target = 'sensor.openweathermap_temperature' %}
|
||||
{{ (state_attr(target, 'temperature') if target.startswith('weather.') else states(target)) | float(0) | round(1) }}
|
||||
{% set raw_val = state_attr(target, 'temperature') if target.startswith('weather.') else states(target) %}
|
||||
{% if is_number(raw_val) %}
|
||||
{{ raw_val | float | round(1) }}
|
||||
{% else %}
|
||||
{{ this.state | default(0, true) }}
|
||||
{% endif %}
|
||||
attributes:
|
||||
last_update: "{{ now().timestamp() }}"
|
||||
history: >
|
||||
{% set target = 'sensor.openweathermap_temperature' %}
|
||||
{% set current = (state_attr(target, 'temperature') if target.startswith('weather.') else states(target)) | float(0) | round(1) %}
|
||||
{% set past = state_attr('sensor.temptrend_24h', 'history') | default([current] * 24, true) %}
|
||||
{{ (past + [current])[-24:] }}
|
||||
{% set raw_val = state_attr(target, 'temperature') if target.startswith('weather.') else states(target) %}
|
||||
{% set past = state_attr('sensor.temptrend_24h', 'history') %}
|
||||
|
||||
{% if is_number(raw_val) %}
|
||||
{% set current = raw_val | float | round(1) %}
|
||||
{% else %}
|
||||
{% set current = past[-1] if past is not none and past | length > 0 else 0 %}
|
||||
{% endif %}
|
||||
|
||||
{% if past is none or past | length == 0 %}
|
||||
{{ [current] * 24 }}
|
||||
{% else %}
|
||||
{{ (past + [current])[-24:] }}
|
||||
{% endif %}
|
||||
```
|
||||
</details>
|
||||
|
||||
|
||||
Reference in new issue
Block a user