ZHA - TS004F Rotary Knob with dual-mode support

Hey everyone,

I made a blueprint for the Tuya TS004F rotary button that fixes the sensitivity issue (where pressing the button accidentally triggers rotation events) and handles both operating modes automatically - the button has two modes (dimmer mode with step events, and scene mode with button press events).

Features:

  • Single press, double press, long press actions
  • Rotation left/right (works in both modes)
  • Configurable debounce delay slider

Tested on my setup with _TZ3000_402vrq2i. Works great after adding the debounce.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Let me know if you have issues with it.

The blueprint works with custom quirk: HomeAssistant/zha_custom_quirks/ts004f_402vrq2i.py at b990e3a63e38a5b718fff2aa17be8a381d6de724 · jrfigura/HomeAssistant · GitHub

there is an open pull request to add correct handling of this device: [Device Support Request] _TZ3000_402vrq2i TS004F Tuya Rotary Button · Issue #3738 · zigpy/zha-device-handlers · GitHub

Hello jrfigura,
Thanks for contributing to the community with a new Blueprint.
I have a suggestion for you. Many people who are not familiar with directory structures will have problems installing this without the Home Assistant MY tools.
Adding a MY link for this Blueprint to your top post would help them a lot.
Here is the link to make that.
Create a link – My Home Assistant
You need to be a trust level ‘member’ to edit a post. Understanding Discourse Trust Levels
If you can’t edit, I would load a link into a second post.

1 Like

When i use it on my TS004F_TZ3000_402vrq2i then i get following error: Message malformed: device does not have trigger (‘remote_button_short_press’, ‘button’)
Didn’t see anything strange myself

1 Like

How do you have your rotary button configured? Since ZHA was not supporting it very well I’m using a local quirk for it. It’s described in the thread: [Device Support Request] _TZ3000_402vrq2i TS004F Tuya Rotary Button · Issue #3738 · zigpy/zha-device-handlers · GitHub

It’s using the below quirk, so i thought that’s OK
Quirk: zhaquirks.tuya.ts004f.TuyaSmartRemote004F

Now just replaced that quirk with the other one, now it seems to work better.
(just tested the toggle)
Do the rest tomorrow

Hello @rene.wolferink
After your message I have realised that my custom quirk was based on the outaded version of TuyaSmartRemote004FROK class. At this momen such simple change no longer worked - I have created a new code for the RotaryDimmer: HomeAssistant/zha_custom_quirks/ts004f_402vrq2i.py at 8f980f9ad6af8a1c09dc78745711b4b23e076cd6 · jrfigura/HomeAssistant · GitHub

Also I pushed the change to the zha-device-handlers

With those changes I had to update the blueprint - please import it one more time

In the end had to change some ‘button’ to ‘button_1’ in the yaml for the single click. No problem.

The Long Press i ended up doing with my own fabricated ZHA_event, then i got it.

So in my case i use the button to toggle lights and rotate for brightness. The double click changes to a certain scene whilst the long click changes to another scene.
All works now… thnx…learned a lot again

1 Like

It was a mode problem I was trying to solve.


I am using this blueprint but one of the devices doesn’t recognise the double press.
I already re-added the device multiple times but I still have the same issue.

I even tried to be next to the ZBT-2 to test if it doesn’t lose connection as it’s farther away from than the other device.

I hope it’s ok to ask in this thread.

Do you have any ides why this would be happening?

Thanks.

@Rick99 since the device I’m working with (_TZ3000_402vrq2i) is not handled well by available zhaquirk I’m using a custom zha quirk

your device is using TuyaSmartRemote004FROK class taht I have based on my custom quirk. Both handle double click in the same way:
(DOUBLE_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: DOUBLE_PRESS},

I’m afraid I cannot help you

1 Like

If you change the blueprint in the UI it will clear your current setup. If you know the blueprint path you could change it in the automations.yaml file

use_blueprint:
  path: path_to_blueprint
1 Like

Hi @jrfigura, I tried testing a new switch (TS004F _TZ3000_402vrq2i) using this blueprint with a bulb (simple config for testing, just selected the switch device and an action / target for short_press of toggle), but whenever I try and save my automation I get an error "Message malformed: device does not have trigger ('remote_short_button_press', 'button')".

description: ""
alias: ZHA - TS004F Rotary Knob (Dual Mode Support)
use_blueprint:
  path: jrfigura/TS004FROtaryKnob.yaml
  input:
    remote: e80ca07253c3b0aa9e5258d1c52d5d91
    button_single_press:
      - action: light.toggle
        metadata: {}
        target:
          entity_id: light.bulb_01
        data: {}

I tried exactly the same thing using a different blueprint (ZHA - Tuya Smart Knob for lights - v1.2) and it worked first go - wondering if there's a problem with this blueprint? Or am I missing entry of a parameter?

Hi @Britespark
I explained the issue 2 comments above yours:

If you use the custom quirk it will work.

1 Like

Ah - apologies, I missed that comment / didn't note the manufacturer code was the same as the device I'm using.

1 Like

Does it work now with the custom quirk?

Hi - have just followed the guide to load custom quirks and recreated my simple button-press automation and can confirm that YES it now works.

Thanks for your help @jrfigura, now to play with added features and functions!

Thanks for the quirk modifaction.
I'm having difficulty getting the knob to change modes though,
can anyone suggest a way to do it please?

Think I got it to work - I had to fast press the button roughly 20 times :-s

1 Like

Have two of these knobs lying in my basement for two years. Now -thanks to the quirk and blueprint- I can finally use them. Thanks.

Edit: In my case the knob only works randomly. Anyone else with issues?