Added support for RGB

This commit is contained in:
Indu Prakash
2022-10-05 05:21:57 -05:00
parent a712fb3a7c
commit 8bd59e66d0
3 changed files with 140 additions and 40 deletions

View File

@ -6,10 +6,15 @@
typedef enum {
ENTITY_RELAY = 0,
ENTITY_LIGHT = 1
ENTITY_LIGHT_PWM = 1,
ENTITY_LIGHT_RGB = 2,
ENTITY_LIGHT_RGBCW = 3,
ENTITY_SENSOR = 4,
} ENTITY_TYPE;
//unique_id is based on CFG_GetDeviceName() whose size is CGF_DEVICE_NAME_SIZE (see hass_populate_unique_id)
//unique_id is defined in hass_populate_unique_id and is based on CFG_GetDeviceName() whose size is CGF_DEVICE_NAME_SIZE.
//Sample unique_id would be deviceName_entityType_index.
//Currently supported entityType is `relay` or `light` - 5 char.
#define HASS_UNIQUE_ID_SIZE (CGF_DEVICE_NAME_SIZE + 1 + 5 + 1 + 4)
//channel is based on unique_id (see hass_populate_device_config_channel)
@ -30,6 +35,7 @@ typedef struct HassDeviceInfo_s{
} HassDeviceInfo;
void hass_print_unique_id(http_request_t *request, const char *fmt, ENTITY_TYPE type, int index);
HassDeviceInfo *hass_init_device_info(ENTITY_TYPE type, int index, char *payload_on, char *payload_off);
HassDeviceInfo *hass_init_relay_device_info(int index);
HassDeviceInfo *hass_init_light_device_info(ENTITY_TYPE type, int index);
char *hass_build_discovery_json(HassDeviceInfo *info);
void hass_free_device_info(HassDeviceInfo *info);