Fix spontan doorbell efter HA genstart: restart-safe event_cnt
- input_number initial sat til -1 (sentinel for 'aldrig synkroniseret') - condition fjernet, event_cnt check flyttet ind i action blok - counter opdateres ALTID (ogsaa ved wake-up) - doorbell koerer kun naar old_cnt >= 0 OG new_cnt != old_cnt - foerste wake-up efter restart synkroniserer stille uden at ringe
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user