[mqtt.homeassistant] JSON Attributes can exist on Cover (#17611)
Signed-off-by: Cody Cutrer <cody@cutrer.us>pull/17615/head
parent
41d306faab
commit
b94ed45076
|
@ -40,6 +40,7 @@ import com.google.gson.annotations.SerializedName;
|
||||||
public class Cover extends AbstractComponent<Cover.ChannelConfiguration> {
|
public class Cover extends AbstractComponent<Cover.ChannelConfiguration> {
|
||||||
public static final String COVER_CHANNEL_ID = "cover";
|
public static final String COVER_CHANNEL_ID = "cover";
|
||||||
public static final String STATE_CHANNEL_ID = "state";
|
public static final String STATE_CHANNEL_ID = "state";
|
||||||
|
public static final String JSON_ATTRIBUTES_CHANNEL_ID = "json-attributes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration class for MQTT component
|
* Configuration class for MQTT component
|
||||||
|
@ -83,6 +84,11 @@ public class Cover extends AbstractComponent<Cover.ChannelConfiguration> {
|
||||||
protected String stateOpening = "opening";
|
protected String stateOpening = "opening";
|
||||||
@SerializedName("state_stopped")
|
@SerializedName("state_stopped")
|
||||||
protected String stateStopped = "stopped";
|
protected String stateStopped = "stopped";
|
||||||
|
|
||||||
|
@SerializedName("json_attributes_template")
|
||||||
|
protected @Nullable String jsonAttributesTemplate;
|
||||||
|
@SerializedName("json_attributes_topic")
|
||||||
|
protected @Nullable String jsonAttributesTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -159,6 +165,13 @@ public class Cover extends AbstractComponent<Cover.ChannelConfiguration> {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}).withAutoUpdatePolicy(optimistic ? AutoUpdatePolicy.RECOMMEND : null).build();
|
}).withAutoUpdatePolicy(optimistic ? AutoUpdatePolicy.RECOMMEND : null).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();
|
finalizeChannels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue