Skip to content

OpenClosedType is not a Command ?!?!#5515

Open
dilyanpalauzov wants to merge 1 commit into
openhab:mainfrom
dilyanpalauzov:openclosed_not_command
Open

OpenClosedType is not a Command ?!?!#5515
dilyanpalauzov wants to merge 1 commit into
openhab:mainfrom
dilyanpalauzov:openclosed_not_command

Conversation

@dilyanpalauzov

Copy link
Copy Markdown
Contributor

Discussion at #5502 (comment)

@dilyanpalauzov dilyanpalauzov requested a review from a team as a code owner April 25, 2026 08:29
@dilyanpalauzov

Copy link
Copy Markdown
Contributor Author

org.openhab.core.io.transport.modbus assumes that OpenClosedType can be a command:

if (command instanceof OnOffType || command instanceof OpenClosedType) { …
Command '%s' of class '%s' cannot be converted to registers. Please use OnOffType, OpenClosedType, DecimalType  or dimensionless QuantityType commands.
Optional<Boolean> actual = ModbusBitUtilities.translateCommand2Boolean(OpenClosedType.CLOSED);

@dilyanpalauzov dilyanpalauzov changed the title OpenClosedType is not a Command OpenClosedType is not a Command ?!?! Apr 25, 2026
@Nadahar

Nadahar commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Modbus doesn't actually use it as a command, it has just included it in a generic "command to boolean" logic. The author probably was fooled by the fact that it implements Command to think that it's something that might be received, and it's obvious that it is convertible to a boolean. My guess is that all references to OpenClosedType can be removed from the ModbusBitUtilities class without it having any real consequences.

But, that is what I find most likely, how to absolutely verify that this is the case is another matter. I don't really know how to do that.

@dilyanpalauzov dilyanpalauzov force-pushed the openclosed_not_command branch from be6c9e4 to c15c682 Compare April 27, 2026 05:29
@dilyanpalauzov

Copy link
Copy Markdown
Contributor Author

I have adjusted org.openhab.core.io.transport.modbus not to handle OpenClosedType as a command. However the add-on org.openhab.binding.modbus still mentions the possiblitiy to use CLOSED and OPEN. I think somebody with understanding of Modbus should first adjust the add-on org.openhab.binding.modbus not to use CLOSED and OPEN as commands, if they are used there in such way.

@kaikreuzer

Copy link
Copy Markdown
Member

Change looks good to me. Do we first need to fix anything in the modbus add-on before this PR can be merged?

@Nadahar

Nadahar commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

It looks highly unlikely to have an impact, given that it's not treated as a command many other places in the system. It's just included in this generic "conversion method" commandToRegisters(), but chances are great that it's not actually ever used as a command.

But, ultimately, only somebody with intimate knowledge of the binding might be able to answer that. Who is "the authority" on the modbus binding?

@Nadahar

Nadahar commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@Nadahar

Nadahar commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Unfortunately, this has "spread" to other bindings as well. This list isn't complete, these are the warnings I get when making the change in my "local core", but it only shows compilation errors from add-ons that I have opened in Eclipse. I guess there's no way to know the full extent but to first build core with this PR, and then build the add-ons until there are no more errors:

Description	Resource	Path	Location	Type
Incompatible conditional operand types Command and OpenClosedType	DeviceHandler.java	/org.openhab.binding.salus/src/main/java/org/openhab/binding/salus/internal/handler	line 221	Java Problem
Incompatible conditional operand types Command and OpenClosedType	OpenCloseValue.java	/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/generic/values	line 57	Java Problem
Incompatible conditional operand types Command and OpenClosedType	ZonePlayerHandler.java	/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler	line 1904	Java Problem
Incompatible conditional operand types Command and OpenClosedType	ZonePlayerHandler.java	/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler	line 2048	Java Problem
Incompatible conditional operand types Command and OpenClosedType	ZonePlayerHandler.java	/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler	line 2153	Java Problem
Incompatible conditional operand types Command and OpenClosedType	ZonePlayerHandler.java	/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler	line 2356	Java Problem
Incompatible conditional operand types Command and OpenClosedType	ZonePlayerHandler.java	/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler	line 2402	Java Problem
Incompatible conditional operand types Command and OpenClosedType	ZonePlayerHandler.java	/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/internal/handler	line 3013	Java Problem
Incompatible operand types Command and OpenClosedType	OpenCloseValue.java	/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/generic/values	line 78	Java Problem
The constructor Value(String, List<Class<? extends Object & PrimitiveType & State>>) is undefined	OpenCloseValue.java	/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/generic/values	line 38	Java Problem
The constructor Value(String, List<Class<? extends Object & PrimitiveType & State>>) is undefined	OpenCloseValue.java	/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/generic/values	line 50	Java Problem
The constructor ZWaveThingChannel.DataType(Class<OpenClosedType>) is undefined	ZWaveThingChannel.java	/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/handler	line 36	Java Problem
The method getMQTTpublishValue(Command, String) in the type OpenCloseValue is not applicable for the arguments (OpenClosedType, null)	ValueTests.java	/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/generic/values	line 174	Java Problem
The method getMQTTpublishValue(Command, String) in the type OpenCloseValue is not applicable for the arguments (OpenClosedType, null)	ValueTests.java	/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/generic/values	line 175	Java Problem
The method parseCommand(Command) in the type OpenCloseValue is not applicable for the arguments (OpenClosedType)	ValueTests.java	/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/generic/values	line 162	Java Problem
The method parseCommand(Command) in the type OpenCloseValue is not applicable for the arguments (OpenClosedType)	ValueTests.java	/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/generic/values	line 163	Java Problem
The method valueOf(Class<T>, String) in the type Enum<ZWaveThingChannel.DataType> is not applicable for the arguments (String)	ZWaveThingHandler.java	/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/handler	line 274	Java Problem
The return type is incompatible with Value.parseCommand(Command)	OpenCloseValue.java	/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/generic/values	line 56	Java Problem
Type mismatch: cannot convert from OpenClosedType to Command	TypeConverters.java	/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link	line 118	Java Problem
Type mismatch: cannot convert from OpenClosedType to Command	TypeConverters.java	/org.openhab.binding.webthing/src/main/java/org/openhab/binding/webthing/internal/link	line 118	Java Problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants