Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Dec 9, 2020
1 parent 6360794 commit cae2557
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 101 deletions.
187 changes: 92 additions & 95 deletions main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -188,198 +188,195 @@ void strupp(char* beg) {
void MiFloraDiscovery(char* mac) {
# define MiFloraparametersCount 4
Log.trace(F("MiFloraDiscovery" CR));
char* MiFlorasensor[MiFloraparametersCount][12] = {
{"sensor", "MiFlora-lux", mac, "illuminance", jsonLux, "", "", "lx", "", "", "", ""},
{"sensor", "MiFlora-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "MiFlora-fer", mac, "", jsonFer, "", "", "µS/cm", "", "", "", ""},
{"sensor", "MiFlora-moi", mac, "", jsonMoi, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* MiFlorasensor[MiFloraparametersCount][8] = {
{"sensor", "MiFlora-lux", mac, "illuminance", jsonLux, "", "", "lx"},
{"sensor", "MiFlora-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "MiFlora-fer", mac, "", jsonFer, "", "", "µS/cm"},
{"sensor", "MiFlora-moi", mac, "", jsonMoi, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, MiFlorasensor, MiFloraparametersCount);
createDiscoveryFromList(mac, MiFlorasensor, MiFloraparametersCount, "Mi-Flora", "Xiaomi", "HHCCJCY01HHCC");
}

void VegTrugDiscovery(char* mac) {
# define VegTrugparametersCount 4
Log.trace(F("VegTrugDiscovery" CR));
char* VegTrugsensor[VegTrugparametersCount][12] = {
{"sensor", "VegTrug-lux", mac, "illuminance", jsonLux, "", "", "lx", "", "", "", ""},
{"sensor", "VegTrug-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "VegTrug-fer", mac, "", jsonFer, "", "", "µS/cm", "", "", "", ""},
{"sensor", "VegTrug-moi", mac, "", jsonMoi, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* VegTrugsensor[VegTrugparametersCount][8] = {
{"sensor", "VegTrug-lux", mac, "illuminance", jsonLux, "", "", "lx"},
{"sensor", "VegTrug-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "VegTrug-fer", mac, "", jsonFer, "", "", "µS/cm"},
{"sensor", "VegTrug-moi", mac, "", jsonMoi, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, VegTrugsensor, VegTrugparametersCount);
createDiscoveryFromList(mac, VegTrugsensor, VegTrugparametersCount, "", "VEGTRUG", "");
}

void MiJiaDiscovery(char* mac) {
# define MiJiaparametersCount 3
Log.trace(F("MiJiaDiscovery" CR));
char* MiJiasensor[MiJiaparametersCount][12] = {
{"sensor", "MiJia-batt", mac, "battery", jsonBatt, "", "", "%", "", "", "", ""},
{"sensor", "MiJia-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "MiJia-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* MiJiasensor[MiJiaparametersCount][8] = {
{"sensor", "MiJia-batt", mac, "battery", jsonBatt, "", "", "%"},
{"sensor", "MiJia-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "MiJia-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, MiJiasensor, MiJiaparametersCount);
createDiscoveryFromList(mac, MiJiasensor, MiJiaparametersCount, "", "", "");
}

void FormalDiscovery(char* mac) {
# define FormalparametersCount 4
Log.trace(F("FormalDiscovery" CR));
char* Formalsensor[FormalparametersCount][12] = {
{"sensor", "Formal-batt", mac, "battery", jsonBatt, "", "", "%", "", "", "", ""},
{"sensor", "Formal-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "Formal-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""},
{"sensor", "Formal-for", mac, "", jsonFor, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* Formalsensor[FormalparametersCount][8] = {
{"sensor", "Formal-batt", mac, "battery", jsonBatt, "", "", "%"},
{"sensor", "Formal-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "Formal-hum", mac, "humidity", jsonHum, "", "", "%"},
{"sensor", "Formal-for", mac, "", jsonFor, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, Formalsensor, FormalparametersCount);
createDiscoveryFromList(mac, Formalsensor, FormalparametersCount, "", "", "");
}

void LYWSD02Discovery(char* mac) {
# define LYWSD02parametersCount 3
Log.trace(F("LYWSD02Discovery" CR));
char* LYWSD02sensor[LYWSD02parametersCount][12] = {
{"sensor", "LYWSD02-batt", mac, "battery", jsonBatt, "", "", "V", "", "", "", ""},
{"sensor", "LYWSD02-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "LYWSD02-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* LYWSD02sensor[LYWSD02parametersCount][8] = {
{"sensor", "LYWSD02-batt", mac, "battery", jsonBatt, "", "", "V"},
{"sensor", "LYWSD02-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "LYWSD02-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, LYWSD02sensor, LYWSD02parametersCount);
createDiscoveryFromList(mac, LYWSD02sensor, LYWSD02parametersCount, "", "Xiaomi", "LYWSD02MMC");
}

void CLEARGRASSTRHDiscovery(char* mac) {
# define CLEARGRASSTRHparametersCount 3
Log.trace(F("CLEARGRASSTRHDiscovery" CR));
char* CLEARGRASSTRHsensor[CLEARGRASSTRHparametersCount][12] = {
{"sensor", "CLEARGRASSTRH-batt", mac, "battery", jsonBatt, "", "", "V", "", "", "", ""},
{"sensor", "CLEARGRASSTRH-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "CLEARGRASSTRH-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* CLEARGRASSTRHsensor[CLEARGRASSTRHparametersCount][8] = {
{"sensor", "CLEARGRASSTRH-batt", mac, "battery", jsonBatt, "", "", "V"},
{"sensor", "CLEARGRASSTRH-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "CLEARGRASSTRH-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, CLEARGRASSTRHsensor, CLEARGRASSTRHparametersCount);
createDiscoveryFromList(mac, CLEARGRASSTRHsensor, CLEARGRASSTRHparametersCount, "", "ClearGrass", "");
}

void CLEARGRASSCGD1Discovery(char* mac) {
# define CLEARGRASSCGD1parametersCount 3
Log.trace(F("CLEARGRASSCGD1Discovery" CR));
char* CLEARGRASSCGD1sensor[CLEARGRASSCGD1parametersCount][12] = {
{"sensor", "CLEARGRASSCGD1-batt", mac, "battery", jsonBatt, "", "", "V", "", "", "", ""},
{"sensor", "CLEARGRASSCGD1-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "CLEARGRASSCGD1-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* CLEARGRASSCGD1sensor[CLEARGRASSCGD1parametersCount][8] = {
{"sensor", "CLEARGRASSCGD1-batt", mac, "battery", jsonBatt, "", "", "V"},
{"sensor", "CLEARGRASSCGD1-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "CLEARGRASSCGD1-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, CLEARGRASSCGD1sensor, CLEARGRASSCGD1parametersCount);
createDiscoveryFromList(mac, CLEARGRASSCGD1sensor, CLEARGRASSCGD1parametersCount, "CLEARGRASSCGD1", "ClearGrass", "CGD1");
}

void CLEARGRASSTRHKPADiscovery(char* rawMac) {
void CLEARGRASSTRHKPADiscovery(char* mac) {
# define CLEARGRASSTRHKPAparametersCount 3
Log.trace(F("CLEARGRASSTRHKPADiscovery" CR));
String macWOdots = String(rawMac);
macWOdots.replace(":", "");
char* mac = (char*)macWOdots.c_str();
char* CLEARGRASSTRHKPAsensor[CLEARGRASSTRHKPAparametersCount][12] = {
{"sensor", "CLEARGRASSTRHKPA-pres", mac, "pressure", jsonPres, "", "", "kPa", "CLEARGRASSTRHKPA", "ClearGrass", "CGP1W", rawMac},
{"sensor", "CLEARGRASSTRHKPA-temp", mac, "temperature", jsonTempc, "", "", "°C", "CLEARGRASSTRHKPA", "ClearGrass", "CGP1W", rawMac},
{"sensor", "CLEARGRASSTRHKPA-hum", mac, "humidity", jsonHum, "", "", "%", "CLEARGRASSTRHKPA", "ClearGrass", "CGP1W", rawMac}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* CLEARGRASSTRHKPAsensor[CLEARGRASSTRHKPAparametersCount][8] = {
{"sensor", "CLEARGRASSTRHKPA-pres", mac, "pressure", jsonPres, "", "", "kPa"},
{"sensor", "CLEARGRASSTRHKPA-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "CLEARGRASSTRHKPA-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, CLEARGRASSTRHKPAsensor, CLEARGRASSTRHKPAparametersCount);
createDiscoveryFromList(mac, CLEARGRASSTRHKPAsensor, CLEARGRASSTRHKPAparametersCount, "CLEARGRASSTRHKPA", "ClearGrass", "CGP1W");
}

void MiScaleDiscovery(char* mac) {
# define MiScaleparametersCount 1
Log.trace(F("MiScaleDiscovery" CR));
char* MiScalesensor[MiScaleparametersCount][12] = {
{"sensor", "MiScale-weight", mac, "", jsonWeight, "", "", "kg", "", "", "", ""},
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* MiScalesensor[MiScaleparametersCount][8] = {
{"sensor", "MiScale-weight", mac, "", jsonWeight, "", "", "kg"},
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, MiScalesensor, MiScaleparametersCount);
createDiscoveryFromList(mac, MiScalesensor, MiScaleparametersCount, "", "Xiaomi", "");
}

void MiLampDiscovery(char* mac) {
# define MiLampparametersCount 1
Log.trace(F("MiLampDiscovery" CR));
char* MiLampsensor[MiLampparametersCount][12] = {
{"sensor", "MiLamp-presence", mac, "", jsonPresence, "", "", "d", "", "", "", ""},
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* MiLampsensor[MiLampparametersCount][8] = {
{"sensor", "MiLamp-presence", mac, "", jsonPresence, "", "", "d"},
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, MiLampsensor, MiLampparametersCount);
createDiscoveryFromList(mac, MiLampsensor, MiLampparametersCount, "", "Xiaomi", "");
}

void MiBandDiscovery(char* mac) {
# define MiBandparametersCount 1
Log.trace(F("MiBandDiscovery" CR));
char* MiBandsensor[MiBandparametersCount][12] = {
{"sensor", "MiBand-steps", mac, "", jsonStep, "", "", "nb", "", "", "", ""},
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* MiBandsensor[MiBandparametersCount][8] = {
{"sensor", "MiBand-steps", mac, "", jsonStep, "", "", "nb"},
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, MiBandsensor, MiBandparametersCount);
createDiscoveryFromList(mac, MiBandsensor, MiBandparametersCount, "", "Xiaomi", "");
}

void InkBirdDiscovery(char* mac) {
# define InkBirdparametersCount 3
Log.trace(F("InkBirdDiscovery" CR));
char* InkBirdsensor[InkBirdparametersCount][12] = {
{"sensor", "InkBird-batt", mac, "battery", jsonBatt, "", "", "%", "", "", "", ""},
{"sensor", "InkBird-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "InkBird-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* InkBirdsensor[InkBirdparametersCount][8] = {
{"sensor", "InkBird-batt", mac, "battery", jsonBatt, "", "", "%"},
{"sensor", "InkBird-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "InkBird-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, InkBirdsensor, InkBirdparametersCount);
createDiscoveryFromList(mac, InkBirdsensor, InkBirdparametersCount, "", "InkBird", "");
}

void LYWSD03MMCDiscovery(char* mac) {
# define LYWSD03MMCparametersCount 4
Log.trace(F("LYWSD03MMCDiscovery" CR));
char* LYWSD03MMCsensor[LYWSD03MMCparametersCount][12] = {
{"sensor", "LYWSD03MMC-batt", mac, "battery", jsonBatt, "", "", "%", "", "", "", ""},
{"sensor", "LYWSD03MMC-volt", mac, "", jsonVolt, "", "", "V", "", "", "", ""},
{"sensor", "LYWSD03MMC-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "LYWSD03MMC-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* LYWSD03MMCsensor[LYWSD03MMCparametersCount][8] = {
{"sensor", "LYWSD03MMC-batt", mac, "battery", jsonBatt, "", "", "%"},
{"sensor", "LYWSD03MMC-volt", mac, "", jsonVolt, "", "", "V"},
{"sensor", "LYWSD03MMC-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "LYWSD03MMC-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, LYWSD03MMCsensor, LYWSD03MMCparametersCount);
createDiscoveryFromList(mac, LYWSD03MMCsensor, LYWSD03MMCparametersCount, "", "", "");
}

void MHO_C401Discovery(char* mac) {
# define MHO_C401parametersCount 4
Log.trace(F("MHO_C401Discovery" CR));
char* MHO_C401sensor[MHO_C401parametersCount][12] = {
{"sensor", "MHO_C401-batt", mac, "battery", jsonBatt, "", "", "%", "", "", "", ""},
{"sensor", "MHO_C401-volt", mac, "", jsonVolt, "", "", "V", "", "", "", ""},
{"sensor", "MHO_C401-temp", mac, "temperature", jsonTempc, "", "", "°C", "", "", "", ""},
{"sensor", "MHO_C401-hum", mac, "humidity", jsonHum, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* MHO_C401sensor[MHO_C401parametersCount][8] = {
{"sensor", "MHO_C401-batt", mac, "battery", jsonBatt, "", "", "%"},
{"sensor", "MHO_C401-volt", mac, "", jsonVolt, "", "", "V"},
{"sensor", "MHO_C401-temp", mac, "temperature", jsonTempc, "", "", "°C"},
{"sensor", "MHO_C401-hum", mac, "humidity", jsonHum, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, MHO_C401sensor, MHO_C401parametersCount);
createDiscoveryFromList(mac, MHO_C401sensor, MHO_C401parametersCount, "", "", "");
}

void INodeEMDiscovery(char* mac) {
# define INodeEMparametersCount 3
Log.trace(F("INodeEMDiscovery" CR));
char* INodeEMsensor[INodeEMparametersCount][12] = {
{"sensor", "iNodeEM-power", mac, "power", jsonPower, "", "", "W", "", "", "", ""},
{"sensor", "iNodeEM-energy", mac, "", jsonEnergy, "", "", "kWh", "", "", "", ""},
{"sensor", "iNodeEM-batt", mac, "battery", jsonBatt, "", "", "%", "", "", "", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement, device name, device manufacturer, device model, device mac
char* INodeEMsensor[INodeEMparametersCount][8] = {
{"sensor", "iNodeEM-power", mac, "power", jsonPower, "", "", "W"},
{"sensor", "iNodeEM-energy", mac, "", jsonEnergy, "", "", "kWh"},
{"sensor", "iNodeEM-batt", mac, "battery", jsonBatt, "", "", "%"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

createDiscoveryFromList(mac, INodeEMsensor, INodeEMparametersCount);
createDiscoveryFromList(mac, INodeEMsensor, INodeEMparametersCount, "", "", "");
}

# else
Expand All @@ -390,7 +387,7 @@ void FormalDiscovery(char* mac) {}
void LYWSD02Discovery(char* mac) {}
void CLEARGRASSTRHDiscovery(char* mac) {}
void CLEARGRASSCGD1Discovery(char* mac) {}
void CLEARGRASSTRHKPADiscovery(char* rawMac) {}
void CLEARGRASSTRHKPADiscovery(char* mac) {}
void MiScaleDiscovery(char* mac) {}
void MiLampDiscovery(char* mac) {}
void MiBandDiscovery(char* mac) {}
Expand Down Expand Up @@ -843,7 +840,7 @@ void launchDiscovery() {
if (p->sensorModel == JQJCY01YM) FormalDiscovery((char*)macWOdots.c_str());
if (p->sensorModel == LYWSD02) LYWSD02Discovery((char*)macWOdots.c_str());
if (p->sensorModel == CGG1) CLEARGRASSTRHDiscovery((char*)macWOdots.c_str());
if (p->sensorModel == CGP1W) CLEARGRASSTRHKPADiscovery(p->macAdr);
if (p->sensorModel == CGP1W) CLEARGRASSTRHKPADiscovery((char*)macWOdots.c_str());
if (p->sensorModel == MUE4094RT) MiLampDiscovery((char*)macWOdots.c_str());
if (p->sensorModel == CGD1) CLEARGRASSCGD1Discovery((char*)macWOdots.c_str());
if (p->sensorModel == MIBAND) MiBandDiscovery((char*)macWOdots.c_str());
Expand Down
Loading

0 comments on commit cae2557

Please sign in to comment.