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] dimmer channel throws error when receiving ON or OFF #17968

Closed
NickWaterton opened this issue Dec 24, 2024 · 3 comments · Fixed by #17980
Closed

[MQTT] dimmer channel throws error when receiving ON or OFF #17968

NickWaterton opened this issue Dec 24, 2024 · 3 comments · Fixed by #17980
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@NickWaterton
Copy link
Contributor

Dimmer channels used to be able to send ON and OFF, and receive ON and OFF messages. Versions 4.2 and earlier.

Now, on upgrading to OH 4.3, although dimmer channels can still send ON and OFF (for 100% and 0%), the channel throws an error if it receives an ON or OFF event.

This breaks existing configurations.

Expected Behavior

Dimmer channels should be able to receive as well as send ON and OFF.

Current Behavior

If a Dimmer channel receives an ON or OFF message the following errors are thrown, and the channel stops working.

With on and off defined in the channel:

Type dimmer : kitchenPots                   "kitchen pots"                  [ commandTopic="/isy_command/kitchenPots", stateTopic="/isy_status/kitchenPots", on=“ON”, off=“OFF” ]

When ON or OFF is received:

2024-12-23 14:32:45.937 [DEBUG] [nternal.profiles.ProfileCallbackImpl] - Delegating command '59' for item 'kitchenPots' to handler for channel 'mqtt:topic:insteon:kitchenPots'
2024-12-23 14:32:45.937 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandler" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:32:45.937 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.ChannelUID" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:32:45.938 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.Thing" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:32:45.938 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandlerCallback" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:32:45.938 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.ThingStatusInfo" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:32:45.940 [DEBUG] [nternal.common.InvocationHandlerSync] - Already in a safe-call context, executing 'ThingHandler.handleCommand()' directly on 'org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler@4b898af5'.
2024-12-23 14:32:45.940 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler@4b898af5': class org.openhab.core.library.types.OnOffType cannot be cast to class org.openhab.core.library.types.PercentType (org.openhab.core.library.types.OnOffType and org.openhab.core.library.types.PercentType are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4b76e427)
java.lang.ClassCastException: class org.openhab.core.library.types.OnOffType cannot be cast to class org.openhab.core.library.types.PercentType (org.openhab.core.library.types.OnOffType and org.openhab.core.library.types.PercentType are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4b76e427)
        at org.openhab.binding.mqtt.generic.values.PercentageValue.parseCommand(PercentageValue.java:78) ~[?:?]
        at org.openhab.binding.mqtt.generic.ChannelState.publishValue(ChannelState.java:363) ~[?:?]
        at org.openhab.binding.mqtt.generic.AbstractMQTTThingHandler.handleCommand(AbstractMQTTThingHandler.java:154) ~[?:?]
        at jdk.internal.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:569) ~[?:?]
        at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) [bundleFile:?]
        at org.openhab.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
        at jdk.proxy1706.$Proxy1843.handleCommand(Unknown Source) [?:?]
        at org.openhab.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:95) [bundleFile:?]
        at org.openhab.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [bundleFile:?]
        at jdk.internal.reflect.GeneratedMethodAccessor96.invoke(Unknown Source) ~[?:?]

Without on or off defined:

Type dimmer : kitchenPots                   "kitchen pots"                  [ commandTopic="/isy_command/kitchenPots", stateTopic="/isy_status/kitchenPots" ]

I get the following error:


2024-12-23 14:54:35.067 [DEBUG] [nternal.profiles.ProfileCallbackImpl] - Delegating command '100' for item 'kitchenPots' to handler for channel 'mqtt:topic:insteon:kitchenPots'
2024-12-23 14:54:35.068 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandler" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:54:35.068 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.ChannelUID" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:54:35.068 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.Thing" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:54:35.068 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.binding.ThingHandlerCallback" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:54:35.068 [DEBUG] [.internal.common.CombinedClassLoader] - Loaded class "org.openhab.core.thing.ThingStatusInfo" by classloader "org.eclipse.osgi.internal.loader.EquinoxClassLoader@6e96f620[org.openhab.core.thing:4.3.0(id=221)]" for "[interface org.openhab.core.thing.binding.ThingHandler]"
2024-12-23 14:54:35.070 [DEBUG] [nternal.common.InvocationHandlerSync] - Already in a safe-call context, executing 'ThingHandler.handleCommand()' directly on 'org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler@879ea9e'.
2024-12-23 14:54:35.070 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.mqtt.generic.internal.handler.GenericMQTTThingHandler@879ea9e': null
java.lang.ClassCastException: null

Possible Solution

Restore the previous functionality by allowing dimmer channels to receive ON and OFF

Steps to Reproduce (for Bugs)

Define a channel:

Thing mqtt:topic:insteon "Insteon"  (mqtt:broker:proliant) {
    Channels:
   Type dimmer : kitchenPots                   "kitchen pots"                  [ commandTopic="/isy_command/kitchenPots", stateTopic="/isy_command/kitchenPots", on="ON", off="OFF" ]
}

And an item:


Dimmer  kitchenPots              "Kitchen Pots [%d%%]"                                      (GF_Kitchen, Lights, movie, bedtime)    { channel="mqtt:topic:insteon:kitchenPots" }

Then try moving the dimmer item to 100% or 0%

Context

MQTT is totally unusable, had to revert to 4.2

Your Environment

Ubuntu 22.04, on upgrade from OH 4.2 to 4.3, MQTT became unusable and throws the above errors.

@NickWaterton NickWaterton added the bug An unexpected problem or unintended behavior of an add-on label Dec 24, 2024
@lolodomo
Copy link
Contributor

@jimtng : is it what PR #17980 fixed ?

@jimtng
Copy link
Contributor

jimtng commented Dec 26, 2024

@jimtng : is it what PR #17980 fixed ?

Yes it's exactly the one. Sorry I didn't see this issue.

@lolodomo
Copy link
Contributor

Closed by #17980

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
3 participants