Xiaomi Wireless Switch DoorBell

I have updated the original question to example thread:

Essentially you need wireless switch (Xiaomi Mijia Smart Switch) which is based on zigbee. Plus any supported device which support audio playback for notification.

I have included a example automation for both Zigbee2Mqtt and also if you have local lan access to your xiaomi gateway. I have found using Zigbee2Mqtt was much more reliable than using xiaomi gateway v2 in my use case. Currently my gateway is only used as hallway light and doorbell.

Essentially I have automation for day time which will send audible doorbell and also notification to my phone using signal, you can use your notification of choice. While other is essentially just condition time is inverse with only notification.

Automation with Stock gateway

- id: Door_Bell_Single
  initial_state: 'on'
  alias: '[Doorbell] Single'
  trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_"device id"
        click_type: single"
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: "{{ 'single' == trigger.payload_json.click }}"
      - after: '08:00:00'
        before: '18:00:00'
        condition: time
  action:
  - data:
      gw_mac: !xiaomi_gw_mac
      ringtone_id: 10
      ringtone_vol: 80
    service: xiaomi_aqara.play_ringtone
  - data:
      message: "[DoorBell] Someone Press the doorbell"
    service: notify.signal

Automation with zigbee2mqtt

- id: Door_Bell_Single
  initial_state: 'on'
  alias: '[Doorbell] Single'
  trigger:
    platform: mqtt
    topic: zigbee2mqtt/"device id"
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: "{{ 'single' == trigger.payload_json.click }}"
      - after: '08:00:00'
        before: '18:00:00'
        condition: time
  action:
  - data:
      gw_mac: !xiaomi_gw_mac
      ringtone_id: 10
      ringtone_vol: 80
    service: xiaomi_aqara.play_ringtone
  - data:
      message: "[DoorBell] Someone Press the doorbell"
    service: notify.signal
1 Like

Have a look at the conditions docs. You can set conditions with time so that your automation will only work between certain times

https://home-assistant.io/docs/automation/condition/

1 Like

Thank!

Great help :slight_smile:

For some reason, my configuration is not working. When i reload the automation it seem to give me this error about the trigger (mapping value not allowed) and if i reboot hassio it won’t sucessful reboot up again. I have go back and clear the automation config.

automation:
 -alias: DoorBell
   trigger:
     platform: event
     event_type: click
     event_data:
       entity_id: binary_sensor.switch_158d0001ae7587
       click_type: single
   condition:
     condition: time
     after: '09:00:00'
     before: '17:00:00'
     weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
        - sat
        - sun
   action:
     service: xiaomi_aqara.play_ringtone
     data:
       gw_mac: 
       ringtone_id: 2
       ringtone_vol: 10
 -alias: DoorBell Speical 
   trigger:
     platform: event
     event_type: click
     event_data:
       entity_id: binary_sensor.switch_158d0001ae7587
       click_type: double
   condition:
     condition: time
     after: '09:00:00'
     before: '17:00:00'
     weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
   action:
     service: xiaomi_aqara.play_ringtone
     data:
       gw_mac: 
       ringtone_id: 2
       ringtone_vol: 11

you made an error in the intent, number of spaces is important. Test your config on a site like yamllint.com

this should work:

automation:
  - alias: DoorBell
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0001ae7587
        click_type: single
    condition:
      condition: time
      after: '09:00:00'
      before: '17:00:00'
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
        - sat
        - sun
    action:
      service: xiaomi_aqara.play_ringtone
      data:
        gw_mac: 
        ringtone_id: 2
        ringtone_vol: 10
1 Like

Ok after a reboot here what i get:

Invalid config for [automation]: [automation] is an invalid option for [automation]. Check: automation->automation. (See /config/configuration.yaml, line 181). Please check the docs at https://home-assistant.io/components/automation/

image

Do you know why this is clausing it? I mean here is my groups configuration

automations_scripts:
    name: Automation & Scripts
    view: yes
    entities:
        - scene.tv_time
        - scene.bedtime
Bedroom_1:
    name: Bedroom
    view: yes
    entities:
        - light.bedroom_light
        - scene.bedtime

leave out the first line “automation:”, you allready declared it by using automation: !include automations.yaml

your automation.yaml file should only include:

  - alias: DoorBell
    trigger:
      platform: event
      event_type: click
      event_data:
        entity_id: binary_sensor.switch_158d0001ae7587
        click_type: single
    condition:
      condition: time
      after: '09:00:00'
      before: '17:00:00'
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
        - sat
        - sun
    action:
      service: xiaomi_aqara.play_ringtone
      data:
        gw_mac: 
        ringtone_id: 2
        ringtone_vol: 10
3 Likes

OMG! Thanks. It just there is alot of configuration out there, i got kinda confused. Its all working now. Thanks

good luck! Keep trying, you’ll be amazed at what is possible!

Hello everyone ! Maybe somebody will be able to help me on that.

I try to make a Xiaomi Wireless Swich Doorbell as well and this automation work perfectly, but i want add some specification.

I would like to add a time condition and also add notification via html 5 android (notification already work).

I explain more, when my little daughter may sleep (common sleep time for her and night), i only want notification, if someone push the doorbell between hour that i now she will not sleep, i would like to ring and notification !

Automations a try so far :

- alias: DoorBell_notification_ringtone
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d00016c1301
      click_type: single
      condition:
        condition: and
        conditions:
          - condition: time
            after: '09:00:00'
            before: '13:00:00'
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
          - condition: time
            after: '16:00:00'
            before: '19:30:00'
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
  action:
  - service: notify.html5_notify
    data:
      message: "Il y a quelqu'un qui sonne !" 
      title: "Sonnette 3.0"
  - service: xiaomi_aqara.play_ringtone
    data:
      gw_mac: !secret xiaomi_mac
      ringtone_id: '10'
      ringtone_vol: '60'
- alias: DoorBell2_notification_only
  trigger:
    platform: event
    event_type: click
    event_data:
      entity_id: binary_sensor.switch_158d00016c1301
      click_type: single
      condition:
        condition: and
        conditions:
          - condition: time
            before: '09:00:00'
            after: '13:00:00'
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
          - condition: time
            before: '16:00:00'
            after: '19:30:00'
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
  action:
  - service: notify.html5_notify
    data:
      message: "Il y a quelqu'un qui sonne !" 
      title: "Sonnette 3.0"

The problem is, it’s still ring after 19:30 :thinking: . And maybe there is way to do it in only 1 automation and not 2 ?

Thanks

Hello,
Please tell me, does this device work without a Xiaomi gateway? Directly through the Rapberry Pi?

Have look at MQTTZigbee (https://www.zigbee2mqtt.io/)

I can confirm that it works with zigbee2mqtt. Not using this automation, but the button works just fine

Understood. Xiaomi has a complicated classification. I meant Xiaomi Linptech Wireless Doorbell. There is no zigbee

It not supported yet. You can check status here: https://github.com/rytilahti/python-miio/issues/521

Yeah, I have changed my automation a bit. The action will trigger pretty much all my audio device to play a message or a doorbell sound.

Xiaomi DoorBell wifi version is coming to me from gearbest store. Meanwhile quick question - I have gateway ver 3 (the one with bluetooth/zigbee/wifi, without light, powered by USB charger, not the one pluggable directly to socket). What I want to achieve is to connect doorbell with HA so pushing button will trigger event which will download snapshot from camera and send it on telegram.

From reading automation codes quoted above I see that it should be possible, but I am wondering how this bell is connected to HA in those examples? Directly via wifi? Via zigbee gateway ver.2 (the one pluggable to socket) ? My gateway doesn’t have developer/lan mode, so I can use it only as homekit integration in HA, I have however plugged CC2531 zigbee module in my raspberry and I already have few devices connected with it via zigbee2mqtt - f. e. magic cube, few temperature/humidity sensors. WIll it work with doorbell for me or I need to modify my setup once again?

I don’t think Xiaomi Doorbell wifi version is supported, it much easier to just install one wireless switch as doorbell with zigbee2mqtt and toggle automation based off that.

Hi.

thank you for this!

Can you help me please.

What do I have to do if I want it to also ring when I double-click the button and hold it down. Can I combine these into one or do I have to create an individual automation for each event

thank you

Sorry about the late, reply. Not sure if this information is still helpful.

If you using latest home assistant, you can just copy the trigger and modify the action/trigger to double/long etc.

I personally don’t, as I have long and double press performing difference actions, so it separated automation.

1 Like