[ism8] Prevent sending for read-only channel types (#17760)

* [ism8] Prevent sending for read-only channel types

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich 2024-11-30 22:38:49 +01:00 committed by GitHub
parent 3ae78a0f91
commit 3187b0110f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
import org.slf4j.Logger;
@ -86,6 +87,14 @@ public class Ism8Handler extends BaseThingHandler implements IDataPointChangeLis
if (command == RefreshType.REFRESH) {
updateChannel(dataPoint);
} else {
ChannelTypeUID channelType = channel.getChannelTypeUID();
if (channelType != null) {
if (channelType.getId().endsWith("-r")) {
logger.warn("Ism8: channel {} of type {} is read-only, cannot send command", channelUID.getId(),
channelType.toString());
return;
}
}
setDataPoint(dataPoint, command);
}
}

View File

@ -43,6 +43,7 @@
<item-type>Switch</item-type>
<label>Digital Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -65,6 +66,7 @@
<item-type>Number:Dimensionless</item-type>
<label>Percentage Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -102,6 +104,7 @@
<item-type>Number:Dimensionless</item-type>
<label>Numeric Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -122,6 +125,7 @@
<item-type>Number:Temperature</item-type>
<label>Temperature Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -162,6 +166,7 @@
<item-type>Number:Pressure</item-type>
<label>Pressure Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -181,6 +186,7 @@
<item-type>Number:Power</item-type>
<label>Power Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -200,6 +206,7 @@
<item-type>Number:VolumetricFlowRate</item-type>
<label>Flowrate Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -220,6 +227,7 @@
<item-type>Number:Energy</item-type>
<label>Active Energy Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>
@ -239,6 +247,8 @@
<channel-type id="mode-r">
<item-type>Number:Dimensionless</item-type>
<label>Mode Readonly DataPoint</label>
<state readOnly="true"/>
<autoUpdatePolicy>veto</autoUpdatePolicy>
<config-description>
<parameter name="id" type="integer" required="true">
<label>DP ID</label>