mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[mqtt.homeassistant] JSON Attributes are supported by Scene (#17614)
Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
2952d21e60
commit
41d306faab
@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
@NonNullByDefault
|
||||
public class Scene extends AbstractComponent<Scene.ChannelConfiguration> {
|
||||
public static final String SCENE_CHANNEL_ID = "scene";
|
||||
public static final String JSON_ATTRIBUTES_CHANNEL_ID = "json-attributes";
|
||||
|
||||
/**
|
||||
* Configuration class for MQTT component
|
||||
@ -43,6 +44,11 @@ public class Scene extends AbstractComponent<Scene.ChannelConfiguration> {
|
||||
|
||||
@SerializedName("payload_on")
|
||||
protected String payloadOn = "ON";
|
||||
|
||||
@SerializedName("json_attributes_topic")
|
||||
protected @Nullable String jsonAttributesTopic;
|
||||
@SerializedName("json_attributes_template")
|
||||
protected @Nullable String jsonAttributesTemplate;
|
||||
}
|
||||
|
||||
public Scene(ComponentFactory.ComponentConfiguration componentConfiguration, boolean newStyleChannels) {
|
||||
@ -55,6 +61,14 @@ public class Scene extends AbstractComponent<Scene.ChannelConfiguration> {
|
||||
.commandTopic(channelConfiguration.commandTopic, channelConfiguration.isRetain(),
|
||||
channelConfiguration.getQos())
|
||||
.withAutoUpdatePolicy(AutoUpdatePolicy.VETO).build();
|
||||
|
||||
if (channelConfiguration.jsonAttributesTopic != null) {
|
||||
buildChannel(JSON_ATTRIBUTES_CHANNEL_ID, ComponentChannelType.STRING, new TextValue(), "JSON Attributes",
|
||||
componentConfiguration.getUpdateListener())
|
||||
.stateTopic(channelConfiguration.jsonAttributesTopic, channelConfiguration.jsonAttributesTemplate)
|
||||
.withAutoUpdatePolicy(AutoUpdatePolicy.VETO).build();
|
||||
}
|
||||
|
||||
finalizeChannels();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user