My code below copied from reddit, sorry for formatting. Am on mobile.
Sure!
So in my case, I use it for my door bell. I get several pulses when the doorbell is rang.
So automation is called, and does what it is supposed to do. After that it calls a script, that will block the automation from being called (5 seconds in my case).
I think so, looks like the shiny metal part is attracted by the electromagnet. Pretty sure it would influence the reed switch in the Xiaomi contact. It may be oscillating, if so you can expect multiple triggers, but that can be negated with the code posted earlier .
That sucks, maybe the shielding is the problem? Any way of removing that? Or maybe try to take the unit from the wall to test if it works from the back?
I cut the metal and placed it at the top. When the doorbell rings it’s turns the state to off but it doesn’t set it back to on. I have to use the xiaomi magnet to reset it.
Hi, today received the door-sensor.
I have it working. but not as good as expected.
What happened;
I use zigbee2mqtt. Doorbell rings, xiaomi sensor -> state true to mqtt -> payload ‘contact’: true.
But sometimes after a while i receive another payload with ‘contact’: false. (payload ‘{“contact”:false,“linkquality”:118,“battery”:80,“voltage”:2965}’)
The automation has a optional field payload. But don’t know what to fill in there to have it only reacting on the true-state?
Have tried ‘true’, “contact”: “true” etc. But that doesn’t work.
EDIT:
Okay, solved that. Filled in the template-value inside condition.
But saw that true from the contact-field was written without quotation marks. It was not possible to delete them inside the gui. Edited that in the automations.yaml.
Thanks for you great idea! I have bought the Xiaomi wireless door sensor and tried to place it somewhere near the electro-magnets but no luck so far. Do you think it is possible to place it somewhere without removing the top from the sensor or the top of the case of the electro-magnets? Or is the signal to weak to make it work? Otherwise I have to try to crack it and look what’s inside