mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-21 06:38:19 +01:00
flag for adding relays as lights in hA discovery
This commit is contained in:
@@ -29,10 +29,10 @@ void hass_populate_unique_id(ENTITY_TYPE type, int index, char* uniq_id) {
|
||||
const char* longDeviceName = CFG_GetDeviceName();
|
||||
|
||||
switch (type) {
|
||||
case LIGHT_ON_OFF:
|
||||
case LIGHT_PWM:
|
||||
sprintf(uniq_id, "%s_%s_%d", longDeviceName, "light", index);
|
||||
break;
|
||||
|
||||
case LIGHT_PWMCW:
|
||||
case LIGHT_RGB:
|
||||
case LIGHT_RGBCW:
|
||||
@@ -77,6 +77,7 @@ void hass_print_unique_id(http_request_t* request, const char* fmt, ENTITY_TYPE
|
||||
/// @param info Device info
|
||||
void hass_populate_device_config_channel(ENTITY_TYPE type, char* uniq_id, HassDeviceInfo* info) {
|
||||
switch (type) {
|
||||
case LIGHT_ON_OFF:
|
||||
case LIGHT_PWM:
|
||||
case LIGHT_PWMCW:
|
||||
case LIGHT_RGB:
|
||||
@@ -145,6 +146,7 @@ HassDeviceInfo* hass_init_device_info(ENTITY_TYPE type, int index, char* payload
|
||||
|
||||
//Build the `name`
|
||||
switch (type) {
|
||||
case LIGHT_ON_OFF:
|
||||
case LIGHT_PWM:
|
||||
case RELAY:
|
||||
case BINARY_SENSOR:
|
||||
@@ -195,8 +197,8 @@ HassDeviceInfo* hass_init_device_info(ENTITY_TYPE type, int index, char* payload
|
||||
/// @brief Initializes HomeAssistant relay device discovery storage.
|
||||
/// @param index
|
||||
/// @return
|
||||
HassDeviceInfo* hass_init_relay_device_info(int index) {
|
||||
HassDeviceInfo* info = hass_init_device_info(RELAY, index, "1", "0");
|
||||
HassDeviceInfo* hass_init_relay_device_info(int index, ENTITY_TYPE type) {
|
||||
HassDeviceInfo* info = hass_init_device_info(type, index, "1", "0");
|
||||
|
||||
sprintf(g_hassBuffer, "~/%i/get", index);
|
||||
cJSON_AddStringToObject(info->root, STATE_TOPIC_KEY, g_hassBuffer); //state_topic
|
||||
@@ -229,6 +231,7 @@ HassDeviceInfo* hass_init_light_device_info(ENTITY_TYPE type) {
|
||||
cJSON_AddStringToObject(info->root, "rgb_cmd_t", g_hassBuffer); //rgb_command_topic
|
||||
break;
|
||||
|
||||
case LIGHT_ON_OFF:
|
||||
case LIGHT_PWM:
|
||||
brightness_scale = 100;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user