Integrate "old fashioned" doorbell into HA with Xiaomi

Sounds like we do the same :grinning:

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).

First, the automation.

# Door Bell

- alias: Door Bell

initial_state: True

trigger:

- platform: state

entity_id: binary_sensor.door_window_sensor_158d00022b3b7f

to: 'off'

condition:

- condition: state

entity_id: input_boolean.xiaomi_doorbell_pulse

state: 'off'

action:

- service: homeassistant.turn_on

data:

entity_id: script.timed_doorbell_off

- service: camera.snapshot

data:

entity_id: camera.front

filename: '/opt/homeassistant/config/www/camera_snapshots/doorbell.jpg'

Then the script,

timer_doorbell_off:

alias: "Turn Off Doorbell Pulse"

sequence:

- service: input_boolean.turn_on

entity_id: input_boolean.xiaomi_doorbell_pulse

- delay: '00:00:05'

- service: input_boolean.turn_off

entity_id: input_boolean.xiaomi_doorbell_pulse

1 Like

Is this solution with a xiaomi door-sensor also possible with this type of doorbell?

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 :slight_smile: .

Worth a try! Let us know how it goes.

Got mine today and no matter where i placed the xiaomi it doesn’t change from open, even when i trigger the doorbell.

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.

What if you turn the sensor to the side. So the side with the arrow is pointing towards the coils?

Had to remove it from its case to get it to fit properly. Found a place that seems to work.

A little more hacky than what I had to do, but I am glad you got it to work :slight_smile:

It’s glitchy though cuz the state changes very quickly from on to off (milliseconds) so i find the automation doesn’t catch it all the time…

OK with the timer_doorbell_off it’s much more stable. Thanks again!

What does this do?

I’m trying to send a snapshot of my blueiris camera to my email or even better as a notification to my mobile device.

aaahh… Dang such an good idea. Sadly I cant cut into mine because I live in a rented flat (btw - this beast is ringing on 230V ) - maybe Ideas?


The “bolt” fires first to the right and then jumps to the left side.

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.

You can specify what triggers it. Any change, only change to on, only change from off to on etc.

Look at my code earlier in this thread. I only trigger when it goes to off.

Ok. But what can i fill in the field payload to only trigger on the true-state of the mqtt payload?

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.

Never worked with the web version of automation, sorry :).

I’m sure you can find the answer in the cookbook.

I can’t get mine to work reliably. Sometimes I get it to report “closed”, but then it doesn’t reset to “open” again.

Has anyone tried a similar hack, but with the vibration sensor? Or is that not sensitive enough?

1 Like


Hello boneless,

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 :frowning:

Hi Maurice,

I think it is a bit of a hit n miss honestly. Opening the sensor is quick, so that would be my first try, but not sure if it would help.

Sorry I can’t be of more help!