mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
[mqtt.generic] Fix ClassCastException when receiving ON/OFF on a dimmer channel (#17980)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
parent
2f2cf22332
commit
d049995e56
@ -75,7 +75,7 @@ public class PercentageValue extends Value {
|
||||
|
||||
@Override
|
||||
public Command parseCommand(Command command) throws IllegalArgumentException {
|
||||
PercentType oldvalue = (state instanceof UnDefType) ? new PercentType() : (PercentType) state;
|
||||
PercentType oldvalue = (state instanceof UnDefType) ? new PercentType() : state.as(PercentType.class);
|
||||
// Nothing do to -> We have received a percentage
|
||||
if (command instanceof PercentType percent) {
|
||||
return percent;
|
||||
|
@ -313,6 +313,8 @@ public class ValueTests {
|
||||
assertThat(v.parseCommand(new DecimalType(10.0)), is(PercentType.ZERO));
|
||||
assertThat(v.getMQTTpublishValue(PercentType.ZERO, null), is("10"));
|
||||
|
||||
v.update(OnOffType.OFF);
|
||||
|
||||
assertThat(v.parseCommand(OnOffType.ON), is(OnOffType.ON));
|
||||
assertThat(v.getMQTTpublishValue(OnOffType.ON, null), is("110"));
|
||||
assertThat(v.parseCommand(OnOffType.OFF), is(OnOffType.OFF));
|
||||
|
Loading…
Reference in New Issue
Block a user