My problem is when the fire detector fires up, 2 or 3 sonoff RF bridges receive the 433mhz signal and then the automation triggers 2 or 3 times in a row instead of once.
How can I avoid that ?
I have heard of Load Balancing With Shared Subscriptions in MQTT but I have yet to understand how to implement that. I am not even sure this applies to my present issue.
I thought of that but then I would lose the opportunity to wander around my house with my Sonoff Remote and always have coverage with at least one of the sonoff RF bridges.
Also, Seting each RF bridge to post to a different mqtt topic would complexify the code.
I am sure there is a way on the MQTT broker to allow that, I just don’t know how to set this up.
I found a workable solution to the problem that is far from perfect but does the job. I set up a condition that checks the last time the automation was triggered and thus avoids multiple automation triggers to one 433mhz signal.
A 1-second interval seems enough.
'{{ as_timestamp(now()) - (as_timestamp(state_attr("automation.feu_chez_moi", "last_triggered")) or 0) > 1 }}'
The automation then looks as such:
- alias: Feu chez moi !
trigger:
- platform: mqtt
topic: "tele/sonoff_rf/RESULT"
condition:
condition: and
conditions:
- condition: template
value_template: '{{ as_timestamp(now()) - (as_timestamp(state_attr("automation.feu_chez_moi", "last_triggered")) or 0) > 1 }}'
- condition: or
conditions:
- condition: template
value_template: "{{ trigger.payload_json['RfReceived']['Data'] == '9B1864' }}"
When your automation triggers, you can turn off that automation as a step in the actions, add a delay (say 30 sec) and then have the automation turn itself back on - all in the same automation
(optional) You could set up the mqtt topic sa an mqtt sensor (or mqtt binary sensor). This would mean you could see history on when the alarm fired etc … although you may need a way to “turn off” the alarm if the sonoff does not send an alarm off confirmation.