[SOLVED] TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Post Reply
joostvanderlinde
Posts: 46
Joined: Tuesday 23 June 2015 23:06
Target OS: Linux
Domoticz version: 2023.2
Location: NL + SE
Contact:

[SOLVED] TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Post 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?
Last edited by joostvanderlinde on Monday 24 April 2023 20:27, edited 2 times in total.
Domoticz on BPI-M2-Pro (compiled on Ubuntu 22.04) and RPI (binary on Raspian 10)
RFXCom, Sonoff Zigbee stick, eBusd Adapter 5, P1, S0, Husdata H60 integration
Zigbee2MQTT AD, MQTT local, AirconWithMe, Ebusd, VolvoRecharge, PSA Car Controller
joostvanderlinde
Posts: 46
Joined: Tuesday 23 June 2015 23:06
Target OS: Linux
Domoticz version: 2023.2
Location: NL + SE
Contact:

Re: TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Post by joostvanderlinde »

Mmmm, apparently a bad search. Found something VERY similar: viewtopic.php?t=37950
Domoticz on BPI-M2-Pro (compiled on Ubuntu 22.04) and RPI (binary on Raspian 10)
RFXCom, Sonoff Zigbee stick, eBusd Adapter 5, P1, S0, Husdata H60 integration
Zigbee2MQTT AD, MQTT local, AirconWithMe, Ebusd, VolvoRecharge, PSA Car Controller
joostvanderlinde
Posts: 46
Joined: Tuesday 23 June 2015 23:06
Target OS: Linux
Domoticz version: 2023.2
Location: NL + SE
Contact:

Re: TuYa TS0041 momentary switch via Zigbee2MQTTAutodiscover

Post 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'  }
Domoticz on BPI-M2-Pro (compiled on Ubuntu 22.04) and RPI (binary on Raspian 10)
RFXCom, Sonoff Zigbee stick, eBusd Adapter 5, P1, S0, Husdata H60 integration
Zigbee2MQTT AD, MQTT local, AirconWithMe, Ebusd, VolvoRecharge, PSA Car Controller
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest