- trigger:
- platform: state
entity_id: counter.reload_tradfri_integration
to: 0
how then can we reset the state if the existing trigger template sensor? Only trying to reset the state, the list of attributes can remain untouched, that is, it could log the time of the reset, but need whipe the complete history
I am in for anything easyā¦ so if a button would work, that would be great.
fwiw, I just tried that trigger in the counter (I have that available, so I figured to align all of these counter entities ) but it rendered both of my trigger template sensors unavailable ā¦
btw config checker errored on the to: 0, and made me use to: '0' which surprised me, as a counter would indicate a number and not a stringā¦?
You may have misunderstood my suggestion. I didnāt suggest to use an Event Trigger to detect an Input Buttonās state-changes (or a counter reset by an Input Button). A State Trigger would be simpler for that purpose (see petroās example above).
I suggested to use an Event Trigger to detect when a counter is reset via its button in the UI.
no, I got that,
sorry for the miscommunication here, it was indeed getting a bit mixed-up.
I have the 2 options working now:
reset via the counter, and the emitted event trigger
reset via an input_button, and itās state change
even a third, but using an event on the input_button press.
Or as a distant 4th, state change on the counter to 0ā¦ but since that failed in my first experiment, that is a very distant 4th
now up for the next challenge and rewrite those attributesā¦
attributes:
herlaad_overzicht: >
{% set triggered = trigger.to_state.attributes.last_triggered %}
{% set op = as_local(triggered).strftime('%D %X') %}
{% set current = this.attributes.get('herlaad_overzicht', []) %}
{% set new = [{'op': op }] %}
{{ (new + current)[:5] }}
last_triggered: >
{{trigger.to_state.attributes.last_triggered}}
have to split it up because there is no to_state in case of the button press, or counter resetā¦
but, rather being lazy than tired, this suffices after all, as you said all along
attributes:
herlaad_overzicht: >
{% set op = now().strftime('%D %X') %}
{% set current = this.attributes.get('herlaad_overzicht', []) %}
{% set new = [{'op': op }] %}
{{ (new + current)[:5] }}
last_triggered: >
{{now()}}
the reload automation also holds a counter, and when that gets reset, it also resets these 2 trigger template sensors, as you can see in the listed triggers:
I would like the trigger sensor to keep track of the number of times the automation is triggered, specifically when the automation activates the action block.