Fix warnings

This commit is contained in:
Theo Arends 2021-01-26 12:45:48 +01:00
parent bc3e9bedd9
commit adf05a5a3c

View File

@ -2561,14 +2561,14 @@ void MI32ShowOneMISensor(){
p = &MIBLEsensors[MI32.mqttCurrentSingleSlot]; p = &MIBLEsensors[MI32.mqttCurrentSingleSlot];
ResponseAppend_P(PSTR("}")); ResponseAppend_P(PSTR("}"));
char idstr[32]; char idstr[32];
const char *alias = BLE_ESP32::getAlias(p->MAC); const char *alias = BLE_ESP32::getAlias(p->MAC);
const char *id = idstr; const char *id = idstr;
if (alias && *alias){ if (alias && *alias){
id = alias; id = alias;
} else { } else {
sprintf(idstr, PSTR("%s%02x%02x%02x"), sprintf(idstr, PSTR("%s%02x%02x%02x"),
kMI32DeviceType[p->type-1], kMI32DeviceType[p->type-1],
p->MAC[3], p->MAC[4], p->MAC[5]); p->MAC[3], p->MAC[4], p->MAC[5]);
} }
@ -2587,21 +2587,23 @@ void MI32ShowOneMISensor(){
/////////////////////////////////////////////// ///////////////////////////////////////////////
// starts a completely fresh MQTT message. // starts a completely fresh MQTT message.
// sends ONE sensor's worth of HA discovery msg // sends ONE sensor's worth of HA discovery msg
#define MI_HA_DISCOVERY_TEMPLATE PSTR("{\"availability\":[],\"device\": \ const char MI_HA_DISCOVERY_TEMPLATE[] PROGMEM =
{\"identifiers\":[\"BLE%s\"],\ "{\"availability\":[],\"device\":"
\"name\":\"%s\",\ "{\"identifiers\":[\"BLE%s\"],"
\"manufacturer\":\"tas\",\ "\"name\":\"%s\","
\"model\":\"%s\",\ "\"manufacturer\":\"tas\","
\"via_device\":\"%s\"\ "\"model\":\"%s\","
}, \ "\"via_device\":\"%s\""
\"dev_cla\":\"%s\",\ "},"
\"expire_after\":600,\ "\"dev_cla\":\"%s\","
\"json_attr_t\":\"%s\",\ "\"expire_after\":600,"
\"name\":\"%s_%s\",\ "\"json_attr_t\":\"%s\","
\"state_topic\":\"%s\",\ "\"name\":\"%s_%s\","
\"uniq_id\":\"%s_%s\",\ "\"state_topic\":\"%s\","
\"unit_of_meas\":\"%s\",\ "\"uniq_id\":\"%s_%s\","
\"val_tpl\":\"{{ value_json.%s }}\"}") "\"unit_of_meas\":\"%s\","
"\"val_tpl\":\"{{ value_json.%s }}\"}")
void MI32DiscoveryOneMISensor(){ void MI32DiscoveryOneMISensor(){
// don't detect half-added ones here // don't detect half-added ones here
int numsensors = MIBLEsensors.size(); int numsensors = MIBLEsensors.size();
@ -2617,7 +2619,7 @@ void MI32DiscoveryOneMISensor(){
// careful - a missing comma causes a crash!!!! // careful - a missing comma causes a crash!!!!
// because of the way we loop? // because of the way we loop?
const char *classes[] = { const char *classes[] = {
"temperature", "temperature",
"Temperature", "Temperature",
@ -2654,7 +2656,7 @@ void MI32DiscoveryOneMISensor(){
if (alias && *alias){ if (alias && *alias){
id = alias; id = alias;
} else { } else {
sprintf(idstr, PSTR("%s%02x%02x%02x"), sprintf(idstr, PSTR("%s%02x%02x%02x"),
kMI32DeviceType[p->type-1], kMI32DeviceType[p->type-1],
p->MAC[3], p->MAC[4], p->MAC[5]); p->MAC[3], p->MAC[4], p->MAC[5]);
} }
@ -2676,7 +2678,7 @@ void MI32DiscoveryOneMISensor(){
"val_tpl":"{{ value_json.LYWSD037fc1e1.Temperature }}"} "val_tpl":"{{ value_json.LYWSD037fc1e1.Temperature }}"}
*/ */
ResponseAppend_P(MI_HA_DISCOVERY_TEMPLATE, ResponseAppend_P(MI_HA_DISCOVERY_TEMPLATE,
//"{\"identifiers\":[\"BLE%s\"]," //"{\"identifiers\":[\"BLE%s\"],"
id, id,
//"\"name\":\"%s\"}," //"\"name\":\"%s\"},"
@ -2701,7 +2703,7 @@ void MI32DiscoveryOneMISensor(){
classes[i+1] classes[i+1]
// //
); );
char DiscoveryTopic[80]; char DiscoveryTopic[80];
sprintf(DiscoveryTopic, "homeassistant/sensor/%s/%s/config", sprintf(DiscoveryTopic, "homeassistant/sensor/%s/%s/config",
id, classes[i+1]); id, classes[i+1]);
@ -2709,7 +2711,7 @@ void MI32DiscoveryOneMISensor(){
MqttPublish(DiscoveryTopic); MqttPublish(DiscoveryTopic);
p->nextDiscoveryData++; p->nextDiscoveryData++;
//vTaskDelay(100/ portTICK_PERIOD_MS); //vTaskDelay(100/ portTICK_PERIOD_MS);
} }
} // end if hass discovery } // end if hass discovery
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); //AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
#endif //USE_HOME_ASSISTANT #endif //USE_HOME_ASSISTANT