diff --git a/include/automations/doerklokke_bag2.yaml b/include/automations/doerklokke_bag2.yaml index d59e6a1..9c96049 100644 --- a/include/automations/doerklokke_bag2.yaml +++ b/include/automations/doerklokke_bag2.yaml @@ -10,6 +10,19 @@ topic: '{{''shellies/shellybutton1-'' ~ button_id ~ ''/input_event/0''}}' condition: [] action: + # Gem gammel og ny event_cnt + - variables: + new_cnt: "{{ trigger.payload_json.event_cnt | int(0) }}" + old_cnt: "{{ states('input_number.shelly_bagdor_event_cnt') | int(-1) }}" + # Opdater counter ALTID (ogsaa ved wake-up) + - service: input_number.set_value + target: + entity_id: input_number.shelly_bagdor_event_cnt + data: + value: "{{ new_cnt }}" + # Stop hvis: foerste sync efter restart (old=-1) eller samme cnt (periodisk wake-up) + - condition: template + value_template: "{{ old_cnt >= 0 and new_cnt != old_cnt }}" - choose: - conditions: - condition: template diff --git a/include/automations/doerklokke_for.yaml b/include/automations/doerklokke_for.yaml index 4666b60..f767a1f 100644 --- a/include/automations/doerklokke_for.yaml +++ b/include/automations/doerklokke_for.yaml @@ -11,6 +11,19 @@ topic: '{{''shellies/shellybutton1-'' ~ button_id ~ ''/input_event/0''}}' condition: [] action: + # Gem gammel og ny event_cnt + - variables: + new_cnt: "{{ trigger.payload_json.event_cnt | int(0) }}" + old_cnt: "{{ states('input_number.shelly_fordor_event_cnt') | int(-1) }}" + # Opdater counter ALTID (ogsaa ved wake-up) + - service: input_number.set_value + target: + entity_id: input_number.shelly_fordor_event_cnt + data: + value: "{{ new_cnt }}" + # Stop hvis: foerste sync efter restart (old=-1) eller samme cnt (periodisk wake-up) + - condition: template + value_template: "{{ old_cnt >= 0 and new_cnt != old_cnt }}" - choose: - conditions: - condition: template diff --git a/include/input/number/shelly_buttons.yaml b/include/input/number/shelly_buttons.yaml new file mode 100644 index 0000000..4f624bf --- /dev/null +++ b/include/input/number/shelly_buttons.yaml @@ -0,0 +1,15 @@ +shelly_bagdor_event_cnt: + name: Shelly bagdoer event count + min: -1 + max: 99999 + step: 1 + mode: box + initial: -1 + +shelly_fordor_event_cnt: + name: Shelly fordoer event count + min: -1 + max: 99999 + step: 1 + mode: box + initial: -1