]> git.basschouten.com Git - openhab-addons.git/commit
[mqtt] Treat incoming empty string as NULL for most types (#16307)
authorCody Cutrer <cody@cutrer.us>
Mon, 29 Jan 2024 22:05:37 +0000 (15:05 -0700)
committerGitHub <noreply@github.com>
Mon, 29 Jan 2024 22:05:37 +0000 (23:05 +0100)
commit5da9dda3e6a39df3d7e05eb0b2f1b9e03ee67f7d
tree8232d8fd9fc897ce043e766c505a8c7537db0ce0
parentd5fc6950dcacba4493861c0cd30b86b07b4dbb62
[mqtt] Treat incoming empty string as NULL for most types (#16307)

* [mqtt] Treat incoming empty string as NULL for most types

Empty strings are often received when deleting retained topics when a device
goes offline, or as the result of a transformation that is missing
a value (such as a "scene" event from zwave-js-ui, which sends JSON with
a timestamp and the scene value, then immediately sends a value to the topic
with only a timestamp).

For string channels, add a configuration value to allow setting a specific
string for treating as NULL, since empty string can make sense for that
type.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/ChannelConfig.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/NumberValue.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/RollershutterValue.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/TextValue.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/Value.java
bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/ValueFactory.java
bundles/org.openhab.binding.mqtt.generic/src/main/resources/OH-INF/config/string-channel-config.xml
bundles/org.openhab.binding.mqtt.generic/src/main/resources/OH-INF/i18n/mqtt.properties
bundles/org.openhab.binding.mqtt.generic/src/test/java/org/openhab/binding/mqtt/generic/values/ValueTests.java