Make MQTT Switch work with Xiaomi gateway

Hello Everyone,

Iam trying to use a 433mhz Switch (sonoff Switch) conneted to Rf bridge to work as a calling bell with Xiaomi Gateway

This is the configuration i have

Switch configuration in config.yaml

  • name: “Bell Switch”
    platform: mqtt
    state_topic: RFBridge/relay/0
    command_topic: RFBridge/relay/0/set
    payload_on: 1
    payload_off: 0
    availability_topic: RFBridge/status
    payload_available: 1
    payload_not_available: 0

Automation Code :

  • alias: Bell Ringing
    hide_entity: True
    trigger:
    platform: mqtt
    topic: RFBridge/relay/0
    payload: ‘1’
    action:
    • service: xiaomi_aqara.play_ringtone
      data:
      gw_mac: f0b429xxxxxx
      ringtone_id: 10
      ringtone_vol: 10
    • delay: ‘00:00:10’
    • service: mqtt.publish
      data:
      topic: RFBridge/relay/0
      payload: ‘0’

The problem that iam facing is once i press the switch it stays on and does not go off.
So the next time if i have to use the bell i have to press the button twice once to turn it off and the next time to turn it on

Can someone please guide me where am i going wrong.

You may want to use that blue bar to format your code :wink:
Change your trigger to use the event platform
This is what I have for my doorbell

- alias: Doorbell Notification
  trigger:
    - platform: event
      event_type: signal_received
      event_data:
        entity_id: sensor.doorbell_sound
1 Like

Is this for the xiaomi Gateway?
How can i send a code to turn off theMQTT Switch after the first code is executed?

Which door bell are you using ?

This is for any sensor. As soon as you can catch info from a sensor you can use this.
I personally have a 433MHz simple doorbell from Byron

Ok issue is resolved
i has a string missing in the MQTT message

The correct code is

  • alias: Bell Ringing
    hide_entity: True
    trigger:
    platform: mqtt
    topic: RFBridge/relay/0
    payload: ‘1’
    action:
    • service: xiaomi_aqara.play_ringtone
      data:
      gw_mac: f0b4xxxxxxxx
      ringtone_id: 10
      ringtone_vol: 30
    • delay: ‘00:00:05’
    • service: mqtt.publish
      data:
      topic: RFBridge/relay/0/set
      payload: ‘0’