I was able to pair a Tuya switch but how to I assign actions to it?

Hi Everyone!

I just started moving some things from Tuya to Zigbee2mqtt and testing things out.

I have this switch - TuYa TS0041 control via MQTT | zigbee2mqtt.io and when it was paired with Tuya, it was operating a set of lights.

I have two HA instances, my main one, and then one with mqtt and zigbee2mqtt (so I do implode things that are currently working).
I had a few questions -

  1. Where do I set up what the button does? (short press/long press/double press?).
  2. Where should these be setup? zigbee2mqtt? in HA?
  3. If I want to leave a main HA, and have my zigbee seperate, are two pi’s the best way to do this?

Thanks!

I had a couple of questions.

example automation :

- id: '1567689190101'
  alias: example light on
  trigger:
  - platform: mqtt
    topic: zigbee2mqtt/tuyats0041/action
    payload: 'single'
  action:
  - data:
      entity_id: light.your_light
    service: light.turn_on
  mode: single

Replace tuyats0041 with the name of your switch, and your_light with the name of your light.

The possible values are: single, double, hold.

I run my zigbee2mqtt on a separate pi.

Thanks @francisp! The instructions are very spot on, but was a bit advanced for me, but I did figure out how to do it from the GUI if other people are curious.

In Configuration → Devices → I select my switch, and clicked on the + for automation.
The above instructions are correct too, as they are found in automations.yaml.

Your way is what I do now, very quick and easy.