-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mqtt.generic] Percentage range fix #10587
[mqtt.generic] Percentage range fix #10587
Conversation
Signed-off-by: Rogier Hofboer <[email protected]>
Note, the reported step should probably be stepPercent, but this didn't work when just trying (inoperable slider without scale). It should also be clear what step is specified, the dimmer steps (in the range 0..100) or the steps on the mqtt channel, which might have a different range. When stepping multiple times down, the stepper runs into a an infinite loop now. |
@@ -154,7 +154,7 @@ public String getMQTTpublishValue(@Nullable String pattern) { | |||
|
|||
@Override | |||
public StateDescriptionFragmentBuilder createStateDescription(boolean readOnly) { | |||
return super.createStateDescription(readOnly).withMaximum(max).withMinimum(min).withStep(step) | |||
return super.createStateDescription(readOnly).withMaximum(HUNDRED).withMinimum(BigDecimal.ZERO).withStep(step) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The step
now seems wrong to me.
When the we have new PercentageValue (0,1000, 100, null, null)
, then we do not want a step of 100
here, right?
I think, the step here should be stepPercent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, but it didn't work for me at first try.
I think we'll need to define / document how the percentage type is expected to behave and what the fields are defining.And then review / adapt all the code to get this behaviour.
On a side note: when doing a custom transformation with JavaScript, I first needed to have 0..1 as range for the input (to get 0..254 as output range), which I could not explain, but then after a restart it was 0..100 like expected, so for me there are still some strange things / things I don't understand going on with the percentage type...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also a lot of things unclear to me going from the Value
towards the UI.
I would want to cleanup the values in the sense, that we separate the changes from the UI from those comming from the device.
Currently a change from the UI is going through ChannelState.publishValue
, which then calls update
on the value.
A change from the device is going through ChannelState.processMessage', which then also calls
updateon the value. Therefor in
update` there is no way to know, from where the change originated. So setting an absolute value can cause a problem, because the base [min...max] or [0...100] is not clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Independent of what's the right strategy for the step
, this fix is worthwhile on it's own, so let us merge it. Many thanks, @rogierhofboer!
Signed-off-by: Rogier Hofboer <[email protected]>
Signed-off-by: Rogier Hofboer <[email protected]> Signed-off-by: Luca Calcaterra <[email protected]>
Signed-off-by: Rogier Hofboer <[email protected]> Signed-off-by: Luca Calcaterra <[email protected]>
Signed-off-by: Rogier Hofboer <[email protected]> Signed-off-by: Luca Calcaterra <[email protected]>
Signed-off-by: Rogier Hofboer <[email protected]>
Signed-off-by: Rogier Hofboer <[email protected]>
Signed-off-by: Rogier Hofboer <[email protected]>
Signed-off-by: Rogier Hofboer [email protected]
Configure mqtt.generic percentage channel value as 0..100
Fixes #10586