How to pair xiaomi zigbee button and sonoff zigbee relay with cc2531?

Hello!
I am new to home assistant. Spend two days watching video and tutorials. Vaste of time unfortunately (((
Could you help me with my first automation please?

  1. I have raspberry pi 3 and home assistant installed on this
  2. I have zigbee usb stick 3.0 (cc2531). It added to home assistant successfully via zigbee2mqtt addon. I added all my zigbee devices to system successfully!
  3. I don’t understand how to turn on/off my light with my button. Such a simple automation.

How to do it?
What trigger must I write?
What action is suitable for this situation?

My zigbee button is Xiaomi WXKG07LM [sensor.vykliuchatel_kukhnia_action]
My relay switch is Sonoff Zigbee 1-ch Relay [switch.svet_kukhnia]

Give me a piece of code as example pleeease…

Your title is not very correct. Since you have a sensor and a switch in HA, they are paired already. What you want is an automation. I don’t have a Xiaomi WXKG07LM , so post what it sends.

Go to configuration → integrations → mqtt → click on configure

Under listen to a topic, enter zigbee2mqtt/#, click ‘Start Listening’, and push your Xiaomi WXKG07LM a few times.
image

Post what you receive here, then I can show an automation.

1 Like

Thank you for helping!
I listened topic as you asked.
And here is the results:

Message 9 received on 09:54 from zigbee2mqtt/Kitchenbutton/action:

left

Value received=left (I pressed left button). Also values available=right, left_double, right_double,
both, left_long, right_long etc.

In additional I have pressed my Sonoff zigbee relay. And listen to the topic. Here is results:

Message 8 received on 09:58 from zigbee2mqtt/Kitchenlight:

{
“linkquality”: 44,
“state”: “ON”

}

Example of automation

- id: '1565365902539'
  alias: Xiaomi WXKG07LM left
  trigger:
  - payload: 'left'
    platform: mqtt
    topic: zigbee2mqtt/Kitchenbutton/action
  condition: []
  action:
  - data:
      entity_id:switch.svet_kukhnia
    service: switch.toggle

1 Like

Thank you very much! It works!!!
(Were some troubles with spaces, but I understand how to fix it)

- id: '1565365902539'
  alias: Xiaomi WXKG07LM left
  trigger:
  - payload: 'left'
    platform: mqtt
    topic: zigbee2mqtt/Выключатель_кухня/action
  condition: []
  action:
  - data:
      entity_id: switch.moia_komnata_svet_2
    service: switch.toggle