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…
thing:
//11
rule "tuya_rotary_up"
when
Item dimbutton_rotary_up changed
then
if (test_dimmer.state!=100) {
if (test_dimmer.state<90) {
val Number upDim10 = (test_dimmer.state as DecimalType) + 10
test_dimmer.sendCommand(upDim10)
}
else {
val Number upDim1 = (test_dimmer.state as DecimalType) + 1
test_dimmer.sendCommand(upDim1)
}
}
logInfo( "testdimmer", test_dimmer.state.toString)
end
//12
rule "tuya_rotary_down"
when
Item dimbutton_rotary_down changed
then
if (test_dimmer.state!=0) {
if (test_dimmer.state>10) {
val Number downDim10 = (test_dimmer.state as DecimalType) - 10
test_dimmer.sendCommand(downDim10)
}
else {
val Number downDim1 = (test_dimmer.state as DecimalType) - 1
test_dimmer.sendCommand(downDim1)
}
}
logInfo( "testdimmer", test_dimmer.state.toString)
end
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 .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'