Tuya zigbee rotary button

hi guys,i just got this tuya rotary zigbee button to play with.Paired successfully with my zigbee2tasmota setup and rotating clockwise it reports :


and anticlockwise


The DimmerStepUp/DimmerStepDown value is how much you spin the wheel at once…if i understand right.
Any good ideas to “translate” those values to one dimmer channel?

No without knowing the minimum and maximum values DimmerStepUp/Down can be. Once you have that you just need to convert the current value to a percent. Also need to know if the value is relative or absolute.

If it’s relative, if you move it 10 then move it another 5 the step value will be 5 for the second move. If it’s absolute the second move will be 15.

You will have to experiment to understand the full behavior of the device. Only then can you interpret the messages into an absolute dimmer value (integer between 0 and 100) or INCREASE/DECREASE commands.

the rotation has no accuracy at all,as i turn it random values appear,so i cant use the actual stepup/down values.I thing the simpler approach could be to just use when the up/down items changed so with a rule i can say when up item changed increase the dimmer value by 1 and when the down item changed decrease the dimmer by 1…Just have to research how to do it with a rule.
edit : i am a total noob when writing rules so this is the best i can do ,one rule for stepup and one for stepdown…

UID: mqtt:topic:b94727f5:dimbutton
label: dimbutton
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:b94727f5
  - id: rotary_down
    channelTypeUID: mqtt:number
    label: rotary_down
    description: ""
      stateTopic: tele/zb2mqtt/dimbutton/SENSOR
      transformationPattern: REGEX:(.*DimmerStepDown.*)∩JSONPATH:$.ZbReceived.dimbutton.DimmerStepDown
  - id: rotary_up
    channelTypeUID: mqtt:number
    label: rotary_up
    description: ""
      stateTopic: tele/zb2mqtt/dimbutton/SENSOR
      transformationPattern: REGEX:(.*DimmerStepUp.*)∩JSONPATH:$.ZbReceived.dimbutton.DimmerStepUp
rule "tuya_rotary_up"
    Item dimbutton_rotary_up changed
    if (test_dimmer.state!=100) {
	    if (test_dimmer.state<90) {
	        val Number upDim10 = (test_dimmer.state as DecimalType) + 10
	    else {
	        val Number upDim1 = (test_dimmer.state as DecimalType) + 1
	logInfo( "testdimmer", test_dimmer.state.toString)

rule "tuya_rotary_down"
    Item dimbutton_rotary_down changed
    if (test_dimmer.state!=0) {
	    if (test_dimmer.state>10) {
	        val Number downDim10 = (test_dimmer.state as DecimalType) - 10
	    else {
	        val Number downDim1 = (test_dimmer.state as DecimalType) - 1
	logInfo( "testdimmer", test_dimmer.state.toString)

if anyone has a simpler approach i would like to see it.

Just send INCREASE and DECREASE as commands. Don’t mess with the math.

Especially if you are new I recommend UI rules using Blockly. Although in this case you wouldn’t even need Blockly. You can do it all in the rule since all you need to do is send a command to the Item.

Trigger one rule by changes to the Item linked to rotary_down with and set the Action to be an Item Action that sends DECREASE to your test_dimmer Item. Then do the same for rotary_up but send INCREASE instead. The binding or autoupdate will take care of making sure you don’t go above 100 or below 0 for you.

I think you can further simplify this and completely eliminate the rule by using a dimmer Channel type.

First create a MAP transform that maps DimmerStepDown to DECREASE and DimmerStepUp to INCREASE.

Set the Channel with:

  • is command toggled ON
  • for the incoming transformation set it to REGEX:.*(DimmerStep.*)".*∩MAP:nameofmaptransform

Link this Channel to the same Dimmer Item as is linked to the actual device.

This configuration should extract “DimmerStepUp” or “DimmerStepDown” from the message and convert it to INCREASE/DECREASE through the map.That INCREASE/DECREASEwill get sent to your Dimmer Item as a command which should get forwarded to the actual device where it will be converted into a + or - to the current state of the Dimmer.

thnx ,i am here to learn :slight_smile: .I am trying the simpler approach.After setup i get

2023-11-10 07:15:44.526 [WARN ] [t.generic.ChannelStateTransformation] - Executing the MAP-transformation failed: Target value not found in map for 'DimmerStepUp":13,"Endpoint":1,"LinkQuality'

my map file


and incoming trans


edit : got it ,the right trans is


thnx for the guidance mate!

1 Like