Page 1 of 1

[SOLVED] TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Posted: Monday 24 April 2023 13:09
by joostvanderlinde
I have a TuYa TS0041 momentary switch.
This switch generates 3 devices in Domoticz that get triggered based on the ' type' of buttonpress: single, double or hold.
The Zigbee2MQTT part and the integration with Domotiocz seem to be OK....

The trouble I seem to have is that the 'on' on the Domoticz switch is within the second overwritten by the following 'off' .

The result of which is:
  • I only see 'off' in the log.
    My events do not seem to trigger either.
What I want to do is to toggle a relay when the button of the TS0041 is pressed once.

Not sure if the behaviour of my TS0041 is different from other momentary switches (Eg TuYa TS0001 or Sonoff SNZB-01)

Should I adapt (is that possible??) the configuration of the switch in Zigbee2MQTT to make sure the 'on' lasts longer than 1 second?

Re: TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Posted: Monday 24 April 2023 13:15
by joostvanderlinde
Mmmm, apparently a bad search. Found something VERY similar: viewtopic.php?t=37950

Re: TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Posted: Monday 24 April 2023 13:39
by joostvanderlinde
Solved:

Created a dzVents event with code:

Code: Select all

return 
{
    on = { devices =  { 445 } }, -- Idx of correct momentary switch

    execute = function(dz)
        dz.devices(210).toggleSwitch() -- Idx of switch to todggle
    end
}
Instead of one value for the Idx of the momentary switch, you can also provided a comma separated list of Idx that should trigger the same behaviour. I used a list with the single, double and hold Domiticz switch linked to the momentary switch

Code: Select all

devices =  { 445, 446, 447 }
Instead of using an ' Idx' in the code, you can also use the name of a Domoticz switch between single quotes:

Code: Select all

devices =  { 'My momentary switch single press'  }