mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-10 18:05:32 +00:00
Merge pull request #309 from iprak/discovery-publish-channels
Discovery / publish initial values
This commit is contained in:
@ -1293,17 +1293,25 @@ int http_fn_ha_discovery(http_request_t* request) {
|
||||
if (relayCount > 0) {
|
||||
for (i = 0; i < CHANNEL_MAX; i++) {
|
||||
if (h_isChannelRelay(i)) {
|
||||
if (dev_info != NULL) {
|
||||
MQTT_QueuePublish(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN);
|
||||
hass_free_device_info(dev_info);
|
||||
}
|
||||
dev_info = hass_init_relay_device_info(i);
|
||||
MQTT_QueuePublish(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN);
|
||||
hass_free_device_info(dev_info);
|
||||
}
|
||||
}
|
||||
|
||||
//Invoke publishChannles after the last topic
|
||||
if (dev_info != NULL) {
|
||||
MQTT_QueuePublishWithCommand(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN, PublishChannels);
|
||||
hass_free_device_info(dev_info);
|
||||
}
|
||||
}
|
||||
|
||||
if (pwmCount == 5 || isLedDriverChipRunning()) {
|
||||
// Enable + RGB control + CW control
|
||||
dev_info = hass_init_light_device_info(ENTITY_LIGHT_RGBCW);
|
||||
MQTT_QueuePublish(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN);
|
||||
MQTT_QueuePublishWithCommand(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN, PublishChannels);
|
||||
hass_free_device_info(dev_info);
|
||||
}
|
||||
else if (pwmCount > 0) {
|
||||
@ -1323,7 +1331,7 @@ int http_fn_ha_discovery(http_request_t* request) {
|
||||
}
|
||||
|
||||
if (dev_info != NULL) {
|
||||
MQTT_QueuePublish(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN);
|
||||
MQTT_QueuePublishWithCommand(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN, PublishChannels);
|
||||
hass_free_device_info(dev_info);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user