- Platform information:
- openHAB version: 2.4.0 (release)
I set up a MQTT switch channel like this:
Thing mqtt:topic:myTopic (mqtt:broker:mybroker) {
Channels:
Type switch : myDebugSwitch [
stateTopic="my/device/node/attribute",
transformationPattern="MAP:on_true.map",
transformationPatternOut="MAP:on_true.map",
commandTopic="my/device/node/attribute/set",
postCommand=true
]
}
with on_true.map
being like this:
true=ON
false=OFF
and an item being like this:
Switch myDebugSwitch_Status "Debug Switch [%s]" <switch> { channel="mqtt:topic:myTopic:myDebugSwitch" }
So receiving a MQTT update my/device/node/attribute true
successfully changes my switch, so that’s great.
Sadly it doesn’t work the other way round, when I change the switch to off, I get this log:
[WARN ] [rm.AbstractFileTransformationService] - Could not transform '0' with the file 'on_true.map' : Target value not found in map for '0'
[WARN ] [eneric.internal.generic.ChannelState] - Command '' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.
and OpenHAB publishes my/device/node/attribute/set 0
- so a zero instead of false.
So I edit my on_true.map
to be like this:
true=ON
false=OFF
1=true
0=false
which only changes the error message to
[WARN ] [eneric.internal.generic.ChannelState] - Command 'false' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.false
but OpenHAB still publishes my/device/node/attribute/set 0
- which doesn’t cause the switch to switch, because it expects a false
there
So what am I doing wrong?