Added rgb_value_template

This commit is contained in:
Indu Prakash
2022-10-07 06:17:53 -05:00
parent 979d3cd3f1
commit 477fb326d3
2 changed files with 15 additions and 11 deletions

View File

@ -170,7 +170,8 @@ HassDeviceInfo *hass_init_light_device_info(ENTITY_TYPE type, int index){
case ENTITY_LIGHT_RGB:
info = hass_init_device_info(type, index, "1", "0");
cJSON_AddStringToObject(info->root, "rgb_cmd_tpl","{{'#%02x%02x%02x0000'|format(red, green, blue)}}"); //rgb_command_template
cJSON_AddStringToObject(info->root, "rgb_cmd_tpl","{{ '#%02x%02x%02x0000' | format(red, green, blue) }}"); //rgb_command_template
cJSON_AddStringToObject(info->root, "rgb_val_tpl","{{ value[1:3] | int(base=16) }},{{ value[3:5] | int(base=16) }},{{ value[5:7] | int(base=16) }}"); //rgb_value_template
sprintf(g_hassBuffer,"%s/led_basecolor_rgb/get",clientId);
cJSON_AddStringToObject(info->root, "rgb_stat_t", g_hassBuffer); //rgb_state_topic
@ -191,7 +192,7 @@ HassDeviceInfo *hass_init_light_device_info(ENTITY_TYPE type, int index){
if (type == ENTITY_LIGHT_RGBCW){
sprintf(g_hassBuffer,"cmnd/%s/led_temperature",clientId);
cJSON_AddStringToObject(info->root, "clr_temp_cmd_t", g_hassBuffer); //color_temp_command_topic
cJSON_AddStringToObject(info->root, "clr_temp_cmd_t", g_hassBuffer); //color_temp_command_topic
sprintf(g_hassBuffer,"%s/led_temperature/get",clientId);
cJSON_AddStringToObject(info->root, "clr_temp_stat_t", g_hassBuffer); //color_temp_state_topic
}

View File

@ -1387,15 +1387,18 @@ int http_fn_ha_cfg(http_request_t *request) {
hass_print_unique_id(request," - unique_id: \"%s\"\n", ENTITY_LIGHT_RGB,i);
hprintf128(request," name: \"%s\"\n",shortDeviceName);
hprintf128(request," rgb_command_template: \"{{ '#%%02x%%02x%%02x0000' | format(red, green, blue)}}\"\n");
hprintf128(request," rgb_state_topic: \"%s/led_basecolor_rgb/get\"\n",clientId);
hprintf128(request," rgb_command_topic: \"cmnd/%s/led_basecolor_rgb\"\n",clientId);
hprintf128(request," command_topic: \"cmnd/%s/led_enableAll\"\n",clientId);
hprintf128(request," availability_topic: \"%s/connected\"\n",clientId);
hprintf128(request," payload_on: 1\n");
hprintf128(request," payload_off: 0\n");
hprintf128(request," brightness_command_topic: \"cmnd/%s/led_dimmer\"\n",clientId);
hprintf128(request," brightness_scale: 100\n");
hprintf128(request," rgb_command_template: \"{{ '#%%02x%%02x%%02x0000' | format(red, green, blue)}}\"\n");
hprintf128(request," rgb_value_template: \"{{ value[1:3] | int(base=16) }},{{ value[3:5] | int(base=16) }},{{ value[5:7] | int(base=16) }}\"\n");
hprintf128(request," rgb_state_topic: \"%s/led_basecolor_rgb/get\"\n",clientId);
hprintf128(request," rgb_command_topic: \"cmnd/%s/led_basecolor_rgb\"\n",clientId);
hprintf128(request," command_topic: \"cmnd/%s/led_enableAll\"\n",clientId);
hprintf128(request," state_topic: \"%s/led_enableAll/get\"\n",clientId);
hprintf128(request," availability_topic: \"%s/connected\"\n",clientId);
hprintf128(request," payload_on: 1\n");
hprintf128(request," payload_off: 0\n");
hprintf128(request," brightness_command_topic: \"cmnd/%s/led_dimmer\"\n",clientId);
hprintf128(request," brightness_scale: 100\n");
hprintf128(request," #brightness_value_template: \"{{ value }}\"\n");
} else if(pwmCount > 0) {