[DISC] Additional device classes for HA discovery (#1810)
* Restart Button * BME280 pressure * BH1750 irradiance * MQ2 gas * TEMT6000 & TSL2561 irradiance * Voltage & Current * HCSR501 motion * M5STACK battery
This commit is contained in:
1 parent
e015173530
commit
2fcfc0f6d2
2 files changed
+24
-19
No files matched your search
+19
-19
@@ -585,7 +585,7 @@ void pubMqttDiscovery() {
|
|||||||
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5TOUGH)
|
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5TOUGH)
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Bat voltage", (char*)getUniqueId("m5batvoltage", "").c_str(), //set state_topic,name,uniqueId
|
subjectSYStoMQTT, "SYS: Bat voltage", (char*)getUniqueId("m5batvoltage", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "{{ value_json.m5batvoltage }}", //set availability_topic,device_class,value_template,
|
will_Topic, "voltage", "{{ value_json.m5batvoltage }}", //set availability_topic,device_class,value_template,
|
||||||
"", "", "V", //set,payload_on,payload_off,unit_of_meas,
|
"", "", "V", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
||||||
@@ -594,7 +594,7 @@ void pubMqttDiscovery() {
|
|||||||
);
|
);
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Bat current", (char*)getUniqueId("m5batcurrent", "").c_str(), //set state_topic,name,uniqueId
|
subjectSYStoMQTT, "SYS: Bat current", (char*)getUniqueId("m5batcurrent", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "{{ value_json.m5batcurrent }}", //set availability_topic,device_class,value_template,
|
will_Topic, "current", "{{ value_json.m5batcurrent }}", //set availability_topic,device_class,value_template,
|
||||||
"", "", "A", //set,payload_on,payload_off,unit_of_meas,
|
"", "", "A", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
||||||
@@ -603,7 +603,7 @@ void pubMqttDiscovery() {
|
|||||||
);
|
);
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Vin voltage", (char*)getUniqueId("m5vinvoltage", "").c_str(), //set state_topic,name,uniqueId
|
subjectSYStoMQTT, "SYS: Vin voltage", (char*)getUniqueId("m5vinvoltage", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "{{ value_json.m5vinvoltage }}", //set availability_topic,device_class,value_template,
|
will_Topic, "voltage", "{{ value_json.m5vinvoltage }}", //set availability_topic,device_class,value_template,
|
||||||
"", "", "V", //set,payload_on,payload_off,unit_of_meas,
|
"", "", "V", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
||||||
@@ -612,7 +612,7 @@ void pubMqttDiscovery() {
|
|||||||
);
|
);
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Vin current", (char*)getUniqueId("m5vincurrent", "").c_str(), //set state_topic,name,uniqueId
|
subjectSYStoMQTT, "SYS: Vin current", (char*)getUniqueId("m5vincurrent", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "{{ value_json.m5vincurrent }}", //set availability_topic,device_class,value_template,
|
will_Topic, "current", "{{ value_json.m5vincurrent }}", //set availability_topic,device_class,value_template,
|
||||||
"", "", "A", //set,payload_on,payload_off,unit_of_meas,
|
"", "", "A", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
||||||
@@ -623,7 +623,7 @@ void pubMqttDiscovery() {
|
|||||||
# ifdef ZboardM5STACK
|
# ifdef ZboardM5STACK
|
||||||
createDiscovery("sensor", //set Type
|
createDiscovery("sensor", //set Type
|
||||||
subjectSYStoMQTT, "SYS: Batt level", (char*)getUniqueId("m5battlevel", "").c_str(), //set state_topic,name,uniqueId
|
subjectSYStoMQTT, "SYS: Batt level", (char*)getUniqueId("m5battlevel", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "{{ value_json.m5battlevel }}", //set availability_topic,device_class,value_template,
|
will_Topic, "battery", "{{ value_json.m5battlevel }}", //set availability_topic,device_class,value_template,
|
||||||
"", "", "%", //set,payload_on,payload_off,unit_of_meas,
|
"", "", "%", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
|
||||||
@@ -652,7 +652,7 @@ void pubMqttDiscovery() {
|
|||||||
# endif
|
# endif
|
||||||
createDiscovery("button", //set Type
|
createDiscovery("button", //set Type
|
||||||
will_Topic, "SYS: Restart gateway", (char*)getUniqueId("restart", "").c_str(), //set state_topic,name,uniqueId
|
will_Topic, "SYS: Restart gateway", (char*)getUniqueId("restart", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "", //set availability_topic,device_class,value_template,
|
will_Topic, "restart", "", //set availability_topic,device_class,value_template,
|
||||||
"{\"cmd\":\"restart\"}", "", "", //set,payload_on,payload_off,unit_of_meas,
|
"{\"cmd\":\"restart\"}", "", "", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_available,payload_not available ,is a gateway entity, command topic
|
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_available,payload_not available ,is a gateway entity, command topic
|
||||||
@@ -682,7 +682,7 @@ void pubMqttDiscovery() {
|
|||||||
Log.trace(F("bme280Discovery" CR));
|
Log.trace(F("bme280Discovery" CR));
|
||||||
char* BMEsensor[BMEparametersCount][8] = {
|
char* BMEsensor[BMEparametersCount][8] = {
|
||||||
{"sensor", "temp", "bme", "temperature", jsonTempc, "", "", "°C"},
|
{"sensor", "temp", "bme", "temperature", jsonTempc, "", "", "°C"},
|
||||||
{"sensor", "pa", "bme", "", jsonPa, "", "", "hPa"},
|
{"sensor", "pa", "bme", "pressure", jsonPa, "", "", "hPa"},
|
||||||
{"sensor", "hum", "bme", "humidity", jsonHum, "", "", "%"},
|
{"sensor", "hum", "bme", "humidity", jsonHum, "", "", "%"},
|
||||||
{"sensor", "altim", "bme", "", jsonAltim, "", "", "m"},
|
{"sensor", "altim", "bme", "", jsonAltim, "", "", "m"},
|
||||||
{"sensor", "altift", "bme", "", jsonAltif, "", "", "ft"}
|
{"sensor", "altift", "bme", "", jsonAltif, "", "", "ft"}
|
||||||
@@ -802,8 +802,8 @@ void pubMqttDiscovery() {
|
|||||||
Log.trace(F("BH1750Discovery" CR));
|
Log.trace(F("BH1750Discovery" CR));
|
||||||
char* BH1750sensor[BH1750parametersCount][8] = {
|
char* BH1750sensor[BH1750parametersCount][8] = {
|
||||||
{"sensor", "lux", "BH1750", "illuminance", jsonLux, "", "", "lx"},
|
{"sensor", "lux", "BH1750", "illuminance", jsonLux, "", "", "lx"},
|
||||||
{"sensor", "ftCd", "BH1750", "", jsonFtcd, "", "", ""},
|
{"sensor", "ftCd", "BH1750", "irradiance", jsonFtcd, "", "", ""},
|
||||||
{"sensor", "wattsm2", "BH1750", "", jsonWm2, "", "", "wm²"}
|
{"sensor", "wattsm2", "BH1750", "irradiance", jsonWm2, "", "", "wm²"}
|
||||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -824,8 +824,8 @@ void pubMqttDiscovery() {
|
|||||||
# define MQ2parametersCount 2
|
# define MQ2parametersCount 2
|
||||||
Log.trace(F("MQ2Discovery" CR));
|
Log.trace(F("MQ2Discovery" CR));
|
||||||
char* MQ2sensor[MQ2parametersCount][8] = {
|
char* MQ2sensor[MQ2parametersCount][8] = {
|
||||||
{"sensor", "gas", "MQ2", "", jsonVal, "", "", "ppm"},
|
{"sensor", "gas", "MQ2", "gas", jsonVal, "", "", "ppm"},
|
||||||
{"binary_sensor", "MQ2", "", "", jsonPresence, "true", "false", ""}
|
{"binary_sensor", "MQ2", "", "gas", jsonPresence, "true", "false", ""}
|
||||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -846,8 +846,8 @@ void pubMqttDiscovery() {
|
|||||||
Log.trace(F("TEMT6000Discovery" CR));
|
Log.trace(F("TEMT6000Discovery" CR));
|
||||||
char* TEMT6000sensor[TEMT6000parametersCount][8] = {
|
char* TEMT6000sensor[TEMT6000parametersCount][8] = {
|
||||||
{"sensor", "lux", "TEMT6000", "illuminance", jsonLux, "", "", "lx"},
|
{"sensor", "lux", "TEMT6000", "illuminance", jsonLux, "", "", "lx"},
|
||||||
{"sensor", "ftcd", "TEMT6000", "", jsonFtcd, "", "", ""},
|
{"sensor", "ftcd", "TEMT6000", "irradiance", jsonFtcd, "", "", ""},
|
||||||
{"sensor", "wattsm2", "TEMT6000", "", jsonWm2, "", "", "wm²"}
|
{"sensor", "wattsm2", "TEMT6000", "irradiance", jsonWm2, "", "", "wm²"}
|
||||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -869,8 +869,8 @@ void pubMqttDiscovery() {
|
|||||||
Log.trace(F("TSL2561Discovery" CR));
|
Log.trace(F("TSL2561Discovery" CR));
|
||||||
char* TSL2561sensor[TSL2561parametersCount][8] = {
|
char* TSL2561sensor[TSL2561parametersCount][8] = {
|
||||||
{"sensor", "lux", "TSL2561", "illuminance", jsonLux, "", "", "lx"},
|
{"sensor", "lux", "TSL2561", "illuminance", jsonLux, "", "", "lx"},
|
||||||
{"sensor", "ftcd", "TSL2561", "", jsonFtcd, "", "", ""},
|
{"sensor", "ftcd", "TSL2561", "irradiance", jsonFtcd, "", "", ""},
|
||||||
{"sensor", "wattsm2", "TSL2561", "", jsonWm2, "", "", "wm²"}
|
{"sensor", "wattsm2", "TSL2561", "irradiance", jsonWm2, "", "", "wm²"}
|
||||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -889,7 +889,7 @@ void pubMqttDiscovery() {
|
|||||||
|
|
||||||
# ifdef ZsensorHCSR501
|
# ifdef ZsensorHCSR501
|
||||||
Log.trace(F("HCSR501Discovery" CR));
|
Log.trace(F("HCSR501Discovery" CR));
|
||||||
char* HCSR501sensor[8] = {"binary_sensor", "hcsr501", "", "", jsonPresence, "true", "false", ""};
|
char* HCSR501sensor[8] = {"binary_sensor", "hcsr501", "", "motion", jsonPresence, "true", "false", ""};
|
||||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
|
|
||||||
//trc(HCSR501sensor[1]);
|
//trc(HCSR501sensor[1]);
|
||||||
@@ -923,9 +923,9 @@ void pubMqttDiscovery() {
|
|||||||
# define INA226parametersCount 3
|
# define INA226parametersCount 3
|
||||||
Log.trace(F("INA226Discovery" CR));
|
Log.trace(F("INA226Discovery" CR));
|
||||||
char* INA226sensor[INA226parametersCount][8] = {
|
char* INA226sensor[INA226parametersCount][8] = {
|
||||||
{"sensor", "volt", "INA226", "", jsonVolt, "", "", "V"},
|
{"sensor", "volt", "INA226", "voltage", jsonVolt, "", "", "V"},
|
||||||
{"sensor", "current", "INA226", "", jsonCurrent, "", "", "A"},
|
{"sensor", "current", "INA226", "current", jsonCurrent, "", "", "A"},
|
||||||
{"sensor", "power", "INA226", "", jsonPower, "", "", "W"}
|
{"sensor", "power", "INA226", "power", jsonPower, "", "", "W"}
|
||||||
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -191,14 +191,19 @@ const char* availableHASSClasses[] = {"battery",
|
|||||||
"duration",
|
"duration",
|
||||||
"energy",
|
"energy",
|
||||||
"enum",
|
"enum",
|
||||||
|
"gas",
|
||||||
"humidity",
|
"humidity",
|
||||||
"illuminance",
|
"illuminance",
|
||||||
|
"irradiance",
|
||||||
|
"motion",
|
||||||
|
"moving",
|
||||||
"pm10",
|
"pm10",
|
||||||
"pm25",
|
"pm25",
|
||||||
"power",
|
"power",
|
||||||
"power_factor",
|
"power_factor",
|
||||||
"pressure",
|
"pressure",
|
||||||
"problem",
|
"problem",
|
||||||
|
"restart",
|
||||||
"signal_strength",
|
"signal_strength",
|
||||||
"temperature",
|
"temperature",
|
||||||
"timestamp",
|
"timestamp",
|
||||||
|
|||||||
Reference in new issue
Block a user