Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Last active March 30, 2024 15:28
Show Gist options
  • Select an option

  • Save Didgeridrew/fe45fccf0ec6343b206bc4963583f7d1 to your computer and use it in GitHub Desktop.

Select an option

Save Didgeridrew/fe45fccf0ec6343b206bc4963583f7d1 to your computer and use it in GitHub Desktop.
HA - Weekly Minimum Temp
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) }}
@Didgeridrew
Copy link
Author

EDIT: Corrected issue with this variable use in action block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment