Skip to content
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] Fix ClassCastException when receiving ON/OFF on a dimmer channel #17980

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public PercentageValue(@Nullable BigDecimal min, @Nullable BigDecimal max, @Null

@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ public void percentCalc() {
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));
Expand Down