Tuya Local Pairing (Zigbee)

I have for my sins bought a 4 button Zigbee - Tuya Scene Switch. I have tried all sorts and still I cannot pair it.

I am running containerised HA, with HACS, z2m running on the host. I have numerous other Zigbee devices working happily, MQTT is setup in promiscuous mode, so anything that pops up is in theory paired.

I’m running a SonOff Universal Zigbee 3, USB Dongle Plus Gateway.

I have created an account on Tuya, via their website. I have found the IOT authorization key. I have added my phone app, I have fought the password war to get the phone app to log in to the Tuya account. ( It seems the password rules are not applied consistently across the platforms, and it’s possible to set a password that the App will not allow. The errors are unhelpful.)

I have tried to setup the HA Tuya Integration, but it refuses to let me login. (1106 Permission Denied) There seems to be some talk about this. In theory… I don’t need Tuya, only Tuya Local.

I have installed HACS, I have updated the Tuya local to the latest version, and I have restarted the HA. I have Enable Newly added entities selected. I have verified the Zigbee chain is working by looking at current data from other sensors.

The Tuya local doesn’t detect the button when you try to add devices, even when it’s flashing in pairing mode. The MQTT shows no sign of detecting a new device either. If I listen in the MQTT integration debug by listening to channel “#” it all seems normal and existing traffic, nothing obviously related to the pairing attempt.

Looking on the Z2M site, buttons that look the same are listed as compatible. Yet it doesn’t pop up. If I’m to add it manually, I need the “local key”. This can be attained from the Tuya account, if you have the device paired through some other path. However, my phone can’t pair to zigbee, and the button won’t pair with the z2m-MQTT-HA chain. So I can’t get the local key. I don’t understand how the Tuya account is supposed to get that, without first pairing with something… So I need to pair it, to be able to pair it to Tuya local, and it’s not playing ball.

Am I missing something? It seems the only way to get this key would be to have a Tuya gateway, which kinda defeats the purpose of having a generic gateway. Z2m indicates it should work…

Do I walk away from this one?

Are you sure it’s a zigbee device?

If the device is supported by z2m, it should pair in z2m just like any other zigbee device. No keys required. Even if not supported, it should still pair and be reflected in the z2m device list as “unsupported.”

The Tuya and LocalTuya integration/addon are both meant for the Tuya wifi devices. I think the official Tuya integration might support zigbee devices via a Tuya zigbee hub, but I don’t think LocalTuya supports zigbee (might be wrong - it’s been awhile and I haven’t really kept up with LocalTuya).

Thanks for getting back, I was just about to edit my question.

I was trawling the MQTT in my dying bout of desperation before getting a whisky, and discovered I had gained a device. Not local Tuya, as you say, it didn’t care about it and counter to everything else I’d found it didn’t want the key. As you say…

However, under the MQTT I discovered a TS004F Tuya switch! I thought I was winning… I installed the blueprint that supports said switch, but despite my now being able to see traffic from it, the action is always null. I’ve not actually been able to prove it works yet. The 10 most recently received messages are all apparently QOS, no signals sent as a result of pressing the buttons.


* * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:09:50

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:09:54

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:20:18

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:20:19

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:20:47

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:24:18

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 25 voltage: 3000
* Received 22:24:19

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:24:21

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 21 voltage: 3000
* Received 22:24:22

  * QoS: 0
  * Payload:

action: null battery: 100 linkquality: 25 voltage: 3000

You seem to be confusing Tuya Zigbee with Tuya WIFI devices.

You only need Z2M for Zigbee.
If oyu go to hte devices page of the switch in HA you should see the changes in the logbook like below.

Hi @at9, yeah that’s what @jerrm was saying. It’s been a long slog this, but as of last night I actually had a device detected on the HA. That was progress… However, I’m not seeing the actions. I only seem to get battery reports and it seems to be eating it’s battery.

I pondered whether it had failed to pair correctly so I deleted the device in HA and went through the pairing process again having removed Tuya local. It doesn’t seem to want to pair now. Not sure if that’s because I removed Tuya Local or because it’s being argumentative. This switch has been an expensive investment of time!

The ts004f works perfectly under Z2M, I have 4 of them. You do not need any tuna integrations, only z2m.

In z2m, does it show up as a paired device? If yes,
In HA, is the device shown as a MQTT device, if yes,

Then it should work.

It will only show battery as entity. The button press arrives in HA as events. If you use the gui, it will learn the button presses Wien you Press the buttons, and you can chose them on the device page.
If you want to use blueprints, there are several for the switch.

I found out how to get into z2m’s console and frontend. I purged the device and repaired it, niggling it to complete it’s interview.

It’s definitely paired with z2m. The same details are up on the HA, but still no actions. I know it’s a new device, but what do they do when the batteries are dead?

FIXED IT: The device had got into “Dimmer Mode”. you have to hold down buttons 2+4 for 6 seconds until button 3 flashes.

As soon as I did that the Blueprint I have listed above responded and the light I had linked it to responded.

So the solution was ultimately, TuYa Zigbee devices (TS004F Scene Switch specifically) do not need TuYa Local, or any TuYa integration. They will work with the SonOff generic Zigbee 3 - USB Gateway when used with z2m and MQTT. There is NO need for a TuYa Router or access point.

When devices show up incomplete in the HA device list, remove them. Start up z2m, enable the z2m frontend in the configuration.yaml file and enter via the web portal to see the z2m state. Remove the offending device from HA and force removal in z2m. Re-pair it. Make sure it completes it’s interview process by niggling it pressing buttons when it stops flashing, to prevent it entering sleep mode. If it doesn’t complete interview, remove it again. Make sure it comes up as happy in z2m. If it still doesn’t make the blueprint respond, try changing dimmer mode.

(There does seem to be an unrelated issue with which buttons work, another day…)