Standardize MQTTDiscovery Temp Keys [deprecate tem key] (#703)
* Detect when sensor isn't available or read fails * Add temperature conversion macros * Add 'tempc' & 'tempf' keys to published values * Unique Values for HA Discovery * Remove degree symbol from temp sensors Co-authored-by: Jonathan Michael Wells <jonathan-wells@oist.jp>
This commit is contained in:
1 parent
b7a4591518
commit
4f1b49d135
10 files changed
+97
-52
No files matched your search
+12
-9
@@ -145,8 +145,8 @@ void pubMqttDiscovery() {
|
||||
# define BMEparametersCount 6
|
||||
Log.trace(F("bme280Discovery" CR));
|
||||
char* BMEsensor[BMEparametersCount][8] = {
|
||||
{"sensor", "tempc", "bme", "temperature", jsonTemp, "", "", "°C"},
|
||||
{"sensor", "tempf", "bme", "temperature", jsonTempf, "", "", "°F"},
|
||||
{"sensor", "tempc", "bme", "temperature", jsonTempc, "", "", "C"},
|
||||
{"sensor", "tempf", "bme", "temperature", jsonTempf, "", "", "F"},
|
||||
{"sensor", "pa", "bme", "", jsonPa, "", "", "hPa"},
|
||||
{"sensor", "hum", "bme", "humidity", jsonHum, "", "", "%"},
|
||||
{"sensor", "altim", "bme", "", jsonAltim, "", "", "m"},
|
||||
@@ -169,8 +169,8 @@ void pubMqttDiscovery() {
|
||||
# define HTUparametersCount 3
|
||||
Log.trace(F("htu21Discovery" CR));
|
||||
char* HTUsensor[HTUparametersCount][8] = {
|
||||
{"sensor", "tempc", "htu", "temperature", jsonTemp, "", "", "°C"},
|
||||
{"sensor", "tempf", "htu", "temperature", jsonTempf, "", "", "°F"},
|
||||
{"sensor", "tempc", "htu", "temperature", jsonTempc, "", "", "C"},
|
||||
{"sensor", "tempf", "htu", "temperature", jsonTempf, "", "", "F"},
|
||||
{"sensor", "hum", "htu", "humidity", jsonHum, "", "", "%"}
|
||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||
};
|
||||
@@ -190,8 +190,8 @@ void pubMqttDiscovery() {
|
||||
# define AHTparametersCount 3
|
||||
Log.trace(F("AHTx0Discovery" CR));
|
||||
char* AHTsensor[AHTparametersCount][8] = {
|
||||
{"sensor", "tempc", "aht", "temperature", jsonTemp, "", "", "°C"},
|
||||
{"sensor", "tempf", "aht", "temperature", jsonTempf, "", "", "°F"},
|
||||
{"sensor", "tempc", "aht", "temperature", jsonTempc, "", "", "C"},
|
||||
{"sensor", "tempf", "aht", "temperature", jsonTempf, "", "", "F"},
|
||||
{"sensor", "hum", "aht", "humidity", jsonHum, "", "", "%"}
|
||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||
};
|
||||
@@ -207,11 +207,14 @@ void pubMqttDiscovery() {
|
||||
# endif
|
||||
|
||||
# ifdef ZsensorDHT
|
||||
# define DHTparametersCount 2
|
||||
# define DHTparametersCount 3
|
||||
Log.trace(F("DHTDiscovery" CR));
|
||||
char* DHTsensor[DHTparametersCount][8] = {
|
||||
{"sensor", "tempc", "dht", "temperature", jsonTemp, "", "", "°C"},
|
||||
{"sensor", "hum", "dht", "humidity", jsonHum, "", "", "%"}};
|
||||
{"sensor", "tempc", "dht", "temperature", jsonTempc, "", "", "C"},
|
||||
{"sensor", "tempf", "dht", "temperature", jsonTempf, "", "", "F"},
|
||||
{"sensor", "hum", "dht", "humidity", jsonHum, "", "", "%"}
|
||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||
};
|
||||
|
||||
for (int i = 0; i < DHTparametersCount; i++) {
|
||||
Log.trace(F("CreateDiscoverySensor" CR));
|
||||
|
||||
Reference in new issue
Block a user