4-gang Tuya Scene switch not pairing with HUSBZB-1

Correct, I updated the firmware myself.
Okay, I’ll try another pairing session next to the controller to see if I can get it to talk.

I’m not familiar with these devices, but I know some of the Chinese sensors and they need to be kept awake - constantly pushing some button about every half second while they are discovered, added to the inbox, and then added as a thing so that it’s awake for all the discovery phases.

I also don’t know what happens now - are they being discovered at all, but then no channels, or? If the device never even shows up in the inbox, then it might be another issue as they should at least be discovered. I’ve got some other Chinese switches here that must be included on channel 26, and can then be manually moved to other channels.

Unfortunately many of these devices don’t follow the Zigbee standards - they use part of the standards, and that’s fine when used with their own gateway, but it can be problematic on others that may not know the finer details of the device.

Progress. I was pressing the wrong button for pairing. It pairs now, but none of the switch channels show. I remember reading about this somewhere, so I need to do some more digging.

I’m not sure how this device works, but there is one switch channel showing here (ie the level control / dimmer channel) - I guess there aren’t more lower down the list. It might be that this device effectively provides a scene trigger rather than individual switch/dimmer channels which might require a custom device definition - hopefully searching around will provide more information.

Okay, after reading up on other threads, this switch has modes that can be set. It can be put into dimmer mode, or four-switch mode. Mine may just need to be configured, and it seems that most are configuring it with the Tuya gateway first.
If I were to do it with the Nortek controller, I think the process would be to flash special firmware, do the configuration, then restore the normal controller firmware. I have the TS004F. Apparently the TS0044 is hardwired for four button control, so I could just try to only get the TS0044’s.

Hi Chris,
I remember @schalli providing a patch to support these switches in this thread ?
AFAIK this is still pending, but from what I tested then this would work fine.
Regards,
Thomas

That thread applies to the TS004x where x is a number, not the TS004F. Apparently the 4F is more flexible and requires a configuration message from the controller to put it in the desired operating mode.

To be honest: Those switches are more a pain in the back than anything else - Tuya (and the various clones) are simply deriving their own “dialect” causing it to be fully compatible only with their own gateway. The required config payload seems to be the reason for the whole mess.
I’d recommend to go for something different - for me Enocean Switches work perfectly (I own a Enocean-knx Gateway) , but there are some ZWave switches as well.

It is always better to provide a PR rather than publishing code in a thread on the forum :wink:

Just some small update here, as I hate to waste money on devices not working and I had some time to play with it:

Using zigbee2mqtt adding this switch is working fine.

It reports the correct buttons and the type of action (single, double, hold), the battery state and the link quality.
What I have not figured out yet is how to setup single channel per button + action, as zigbee2mqtt publishes everything a a single topic. My target would be to have separate channel per button at least,
best would be a channel per button+action.

Example (Single press of button on, from zigbee2mqtt log):

MQTT publish: topic 'zigbee2mqtt/TuyaSwitch1', payload '{"action":"1_single","battery":100,"linkquality":68,"voltage":3000}'

One can have a channel for the actions only, filtering by a JSONPATH expression when the data comes in. But I do not know if it is possible to trigger a channel only if a certain value is contained in the data received without coding. Yes, I could build a rule in code and trigger separate items programmatically. This would allow e.g. to have separate channels per button, reporting e.g. “single”, “double”…

But I’d like to see an option without coding - one thing less to maintain. My impression is, that this is not possible without coding some rules.

Anyone with ideas out there ?

Cheers
Thomas

Hi,

I bought also one tuya 4 gang switch. I tried to pair with zigbee2mqtt. But then I discovered that the default mod in the switch is dimmer mod, so I get one topic the topics: Button on, Button off, dimmer value up, dimmer value down.
But I would like to use it as 4 4 button switch (button 1 on and off, button 2 on and off …)

Can I change de operating mod without a tuya controller?

Thank you in advance.
Joko

Solved it on my own.
The trick is to use a proper transformation of the incoming value.
With a regular expression on the value of interest this can be achieved:
Example (React only on a single button press of button 1):

REGEX:(.*1_single.*)∩JSONPATH:$.action

Maybe this is of use for someone else.
In addition here the channel definition I created for the switch. Remember to adjust the mqtt state topic

zigbee2mqtt/TuyaSwitch1

with your own topic.
Have fun.

channels:
  - id: button1_single
    channelTypeUID: mqtt:trigger
    label: Button 1 Single Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*1_single.*)∩JSONPATH:$.action
  - id: button2_single
    channelTypeUID: mqtt:trigger
    label: Button 2 Single Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*2_single.*)∩JSONPATH:$.action
  - id: button3_single
    channelTypeUID: mqtt:trigger
    label: Button 3 Single Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*3_single.*)∩JSONPATH:$.action
  - id: button4_single
    channelTypeUID: mqtt:trigger
    label: Button 4 Single Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*4_single.*)∩JSONPATH:$.action
  - id: button1_double
    channelTypeUID: mqtt:trigger
    label: Button 1 Double Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*1_double.*)∩JSONPATH:$.action
  - id: button2_double
    channelTypeUID: mqtt:trigger
    label: Button 2 Double Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*2_double.*)∩JSONPATH:$.action
  - id: button3_double
    channelTypeUID: mqtt:trigger
    label: Button 3 Double Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*3_double.*)∩JSONPATH:$.action
  - id: button4_double
    channelTypeUID: mqtt:trigger
    label: Button 4 Double Tap
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*4_double.*)∩JSONPATH:$.action
  - id: battery_level
    channelTypeUID: mqtt:number
    label: Battery Level
    description: null
    configuration:
      unit: "%"
      min: 0
      qos: 1
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*battery.*)∩JSONPATH:$.battery
      max: 100
  - id: anyTap
    channelTypeUID: mqtt:trigger
    label: Any button pressed
    description: Fired when any button press happens
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*action.*)∩JSONPATH:$.action
  - id: button1_hold
    channelTypeUID: mqtt:trigger
    label: Button 1 Long Press
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*1_hold.*)∩JSONPATH:$.action
  - id: button2_hold
    channelTypeUID: mqtt:trigger
    label: Button 2 Long Press
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*2_hold.*)∩JSONPATH:$.action
  - id: button3_hold
    channelTypeUID: mqtt:trigger
    label: Button 3 Long Press
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*3_hold.*)∩JSONPATH:$.action
  - id: button4_hold
    channelTypeUID: mqtt:trigger
    label: Button 4 Long Press
    description: null
    configuration:
      stateTopic: zigbee2mqtt/TuyaSwitch1
      transformationPattern: REGEX:(.*4_hold.*)∩JSONPATH:$.action

I solved it on my own too.

What I have done:

I Upgrades zigbee2mqtt to the newest version. Now I paired the device with z2m.

To change the mode on the switch I pressed button 2 and 4 (the two on the right) till the light at button 2 flashed one time.

Now the topics changed. And it is a 12 value switch.

Cheers
Joko

Thomas,

Can you give an simple example of a rule that uses these triggers?

Here some example.
I have glued one of those switches under our dining table to be able to control the lights and other things in the room from where I am sitting without using Alexa, which can be disturbing during a conversation.
The example toggles the lights above the table using a blockly script (Item linked to the actor is called EG_EZ_Tischleuchte_Switch ) when performing a single short click on button 1 of the Tuya switch.
Your thingUID and channelUID will obviously be different.

Works fine for me, hope it helps.

configuration: {}
triggers:
  - id: "1"
    configuration:
      thingUID: mqtt:topic:8498e3f762:42d229b3b0
      event: 1_single
      channelUID: mqtt:topic:8498e3f762:42d229b3b0:anyTap
    type: core.ChannelEventTrigge.
conditions: []
actions:
  - inputs: {}
    id: "3"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="commonBlocks_toggleItem" id="6NTbz`u$2_-7G1/Z;z-8" x="33"
        y="22"><value name="toggleItem"><shadow type="oh_item"
        id="ayezP5p[dReS}x9p$hnI"><field
        name="itemName">EG_EZ_Tischleuchte_Switch</field></shadow></value></block></xml>
      type: application/javascript
      script: >
        if (itemRegistry.getItem('EG_EZ_Tischleuchte_Switch').getState() ==
        'ON') {
          events.sendCommand('EG_EZ_Tischleuchte_Switch', 'OFF');
        } else {
          events.sendCommand('EG_EZ_Tischleuchte_Switch', 'ON');
        }
    type: script.ScriptAction

Thanks for the additional info. I ended up getting it working in a different way by eliminating the transformations, using only only the universal button press trigger and using a switch statement in Rules-DSL.

UID: mqtt:topic:light_switch_001
label: Switch_001 TuYa 4-way
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:mosquitto
channels:
  - id: buttonPress
    channelTypeUID: mqtt:trigger
    label: Button Press
    description: null
    configuration:
      stateTopic: zigbee2mqtt/light_switch_001/action
  - id: battery_level
    channelTypeUID: mqtt:number
    label: Battery Level
    description: null
    configuration:
      stateTopic: zigbee2mqtt/light_switch_001/battery
      unit: "%"
rule "light switch 001 press"
when
    Channel "mqtt:topic:light_switch_001:buttonPress" triggered
then
    switch(receivedEvent) {
        case "1_single": {
            logInfo("Button Pressed", "1_single")
        }
        case "2_single": {
            logInfo("Button Pressed", "2_single")
        }
        case "3_single": {
            logInfo("Button Pressed", "3_single")
        }
        case "4_single": {
            logInfo("Button Pressed", "4_single")
        }
        case "1_double": {
            logInfo("Button Pressed", "1_double")
        }
        case "2_double": {
            logInfo("Button Pressed", "2_double")
        }
        case "3_double": {
            logInfo("Button Pressed", "3_double")
        }
        case "4_double": {
            logInfo("Button Pressed", "4_double")
        }
        case "1_hold": {
            logInfo("Button Pressed", "1_hold")
        }
        case "2_hold": {
            logInfo("Button Pressed", "2_hold")
        }
        case "3_hold": {
            logInfo("Button Pressed", "3_hold")
        }
        case "4_hold": {
            logInfo("Button Pressed", "4_hold")
        }
    }
end

for these who own this switch,what is the battery life?

I have had mine for maybe two years. Gets used about twice per day. Original battery, so I don’t know how long it lasts.

I’ve change the battery after 2 years, it is used roughly 10 times per week.

i use it for 4 months now and i have change 3 batteries.!!!It is used 3 to 5 times per day…but i dont think that this battery usage is normal.I have it paired with a zigbee2tasmota coordinator like all my devices,about 20,sonoff/aqara/tuya,never had any abnormal battery consumption issue.