Last active
March 30, 2024 15:28
-
-
Save Didgeridrew/fe45fccf0ec6343b206bc4963583f7d1 to your computer and use it in GitHub Desktop.
HA - Weekly Minimum Temp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template: | |
| - trigger: | |
| - platform: state | |
| not_to: | |
| - unknown | |
| - unavailable | |
| entity_id: sensor.temp | |
| - platform: template | |
| value_template: "{{ now().weekday() == 0 }}" | |
| action: | |
| - variables: | |
| source: "{{ states('sensor.temp') | float }}" | |
| now: "{{ now() }}" | |
| sensor: | |
| - name: Temp Min | |
| unique_id: ute_temp_min_v | |
| unit_of_measurement: "°C" | |
| device_class: temperature | |
| icon: mdi:thermometer-chevron-down | |
| state: | | |
| {% set current = (this.state or trigger.to_state.state) | float(source) %} | |
| {{ source if trigger.platform == 'template' else [source, current] | min }} | |
| attributes: | |
| datetime: | | |
| {% set current = (this.state or trigger.to_state.state) | float(source) %} | |
| {{ now if (trigger.platform == 'template' or source < current) else this.attributes.datetime|default(now) }} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EDIT: Corrected issue with
thisvariable use in action block.