From 1280a0e11b69f5bf75b93f64dbe9d2e14fb29887 Mon Sep 17 00:00:00 2001 From: LukasA83 <58861945+LukasA83@users.noreply.github.com> Date: Thu, 6 Jan 2022 23:35:41 +0100 Subject: [PATCH] Add DateTime channel type to comply with mqtt homie convention 3.x (#11894) Signed-off-by: Lukas Agethen --- .../binding/mqtt/homie/internal/homie300/Property.java | 4 ++++ .../mqtt/homie/internal/homie300/PropertyAttributes.java | 3 ++- .../src/main/resources/OH-INF/config/homie-channel-config.xml | 1 + .../src/main/resources/OH-INF/i18n/mqtt.properties | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java b/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java index 77775d13f..b87e525c2 100644 --- a/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java +++ b/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/Property.java @@ -30,6 +30,7 @@ import org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass; import org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass.AttributeChanged; import org.openhab.binding.mqtt.generic.mapping.ColorMode; import org.openhab.binding.mqtt.generic.values.ColorValue; +import org.openhab.binding.mqtt.generic.values.DateTimeValue; import org.openhab.binding.mqtt.generic.values.NumberValue; import org.openhab.binding.mqtt.generic.values.OnOffValue; import org.openhab.binding.mqtt.generic.values.PercentageValue; @@ -218,6 +219,9 @@ public class Property implements AttributeChanged { value = new NumberValue(min, max, step, attributes.unit); } break; + case datetime_: + value = new DateTimeValue(); + break; case string_: case unknown: default: diff --git a/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/PropertyAttributes.java b/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/PropertyAttributes.java index 53096c078..993f24254 100644 --- a/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/PropertyAttributes.java +++ b/bundles/org.openhab.binding.mqtt.homie/src/main/java/org/openhab/binding/mqtt/homie/internal/homie300/PropertyAttributes.java @@ -36,7 +36,8 @@ public class PropertyAttributes extends AbstractMqttAttributeClass { boolean_, string_, enum_, - color_ + color_, + datetime_ } public String name = ""; diff --git a/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/config/homie-channel-config.xml b/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/config/homie-channel-config.xml index 83e50a30b..7bb8d2575 100644 --- a/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/config/homie-channel-config.xml +++ b/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/config/homie-channel-config.xml @@ -42,6 +42,7 @@ + diff --git a/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/i18n/mqtt.properties b/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/i18n/mqtt.properties index fcbe137d3..295e5a9f4 100644 --- a/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/i18n/mqtt.properties +++ b/bundles/org.openhab.binding.mqtt.homie/src/main/resources/OH-INF/i18n/mqtt.properties @@ -6,6 +6,7 @@ channel-type.config.mqtt.homie-channel.datatype.option.boolean_ = Boolean channel-type.config.mqtt.homie-channel.datatype.option.string_ = String channel-type.config.mqtt.homie-channel.datatype.option.enum_ = Enumeration channel-type.config.mqtt.homie-channel.datatype.option.color_ = Colour +channel-type.config.mqtt.homie-channel.datatype.option.datetime_ = DateTime channel-type.config.mqtt.homie-channel.format.label = Format channel-type.config.mqtt.homie-channel.format.description = The output format. channel-type.config.mqtt.homie-channel.name.label = Name