Xiaomi devices tutorial

I’m trying to learn something about generating automation xiaomi devices in hassio/nodered but it is very difficult. I cannot create a single flow.
I watched few YT videos and does not understand how to make a simple automation.
eg.

- id: '0000000001'
  alias: toggle lamp
  trigger:
  - platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d0001d62ab9
      click_type: single
  - platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.wall_switch_158d00013ff70e
      click_type: single
  action:
    service: switch.toggle
    entity_id: switch.plug_158d0001deb3bb

Does someone can show me step by step how to recreate this super simple automation in node-red?

I have found: https://flows.nodered.org/node/node-red-contrib-xiaomi-devices
but i don’t know how to install this in hass.io node red version (not showing in palette)

Hello jojoro,

I also have Xiaomi switches and these are also read via an automation in HA. In general, I have the feeling that a “direct” automation in HA is more stable than a flow in Node-RED, but maybe it’s just my feeling. I tried to create a tutorial for you. Maybe it will take you further. I have not installed the “Xiaomi Palette” and I do not need it.
On the first picture you can see an overview of the complete flow.

The first node is “events: all” and here “xiaomi_aqara.click” is entered for “Event Type”.

Next, a “switch” is created to get the “Xiaomi Switches” displayed individually!

Next, I created two “switch” nodes to read the “single” or “double” click on each button …

Finally, I turn a “plug” with a “single” click on and off …

Maybe this will help you! There may be an easier way, but that’s the way it works. If a simpler or better way is shown here, I am also trying to try and learn something new. I am not a professional and have received much help here in the forum …
Good luck!!!

10 Likes

Very useful, thank you for sharing!

This was enormously helpful. Your diagrams/instructions helped me to get my deCONZ-ified Tradfri Remotes to work via Node Red. Many thanks.

Thank you for this.

If I output the payload to a debug node, I’m seeing multiple events for each click. Any idea why?

I’m also seeing a fourth click_type - “hold”, which I didn’t expect.