Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Created February 6, 2024 16:43
Show Gist options
  • Select an option

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

Select an option

Save Didgeridrew/442b77bf10473a6ded877922099699b0 to your computer and use it in GitHub Desktop.
HA - Times opened, like History stats but without time
template:
- trigger:
- platform: state
entity_id: input_boolean.test_bool_1
to: "on"
- platform: event
event_type: custom_reset_times_opened
- platform: event
event_type: event_template_reloaded
sensor:
- name: times_opened
state: |
{% set current = this.state | int(0) if this is defined else 0 %}
{% if trigger.id == 'reset' %}
0
{% else %}
{{ current + 1 }}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment