hass rssi discovery

This commit is contained in:
Tester23
2023-10-19 10:30:18 +02:00
parent f12ab9872b
commit 83cd57dff5
2 changed files with 13 additions and 1 deletions

View File

@ -245,6 +245,9 @@ HassDeviceInfo* hass_init_device_info(ENTITY_TYPE type, int index, char* payload
case ILLUMINANCE_SENSOR:
sprintf(g_hassBuffer, "Illuminance");
break;
case HASS_RSSI:
sprintf(g_hassBuffer, "RSSI");
break;
default:
sprintf(g_hassBuffer, "%s", CHANNEL_GetLabel(index));
break;
@ -582,6 +585,13 @@ HassDeviceInfo* hass_init_sensor_device_info(ENTITY_TYPE type, int channel, int
cJSON_AddStringToObject(info->root, "stat_t", g_hassBuffer);
cJSON_AddStringToObject(info->root, "val_tpl", g_template_lowMidHigh);
break;
case HASS_RSSI:
cJSON_AddStringToObject(info->root, "dev_cla", "signal_strength");
cJSON_AddStringToObject(info->root, "stat_t", "~/rssi");
cJSON_AddStringToObject(info->root, "unit_of_meas", "dBm");
//cJSON_AddStringToObject(info->root, "icon_template", "mdi:access-point");
break;
default:
sprintf(g_hassBuffer, "~/%d/get", channel);
@ -589,7 +599,7 @@ HassDeviceInfo* hass_init_sensor_device_info(ENTITY_TYPE type, int channel, int
return NULL;
}
if (type != READONLYLOWMIDHIGH_SENSOR && type != ENERGY_SENSOR) {
if (type != READONLYLOWMIDHIGH_SENSOR && type != ENERGY_SENSOR && type != HASS_RSSI) {
cJSON_AddStringToObject(info->root, "stat_cla", "measurement");
}

View File

@ -65,6 +65,8 @@ typedef enum {
ILLUMINANCE_SENSOR,
ENERGY_SENSOR,
HASS_RSSI,
} ENTITY_TYPE;
//unique_id is defined in hass_populate_unique_id and is based on CFG_GetDeviceName() whose size is CGF_DEVICE_NAME_SIZE.