Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISC] Additional device classes for HA discovery #1810

Merged
merged 8 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ void pubMqttDiscovery() {
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5TOUGH)
createDiscovery("sensor", //set Type
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,
0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
Expand All @@ -594,7 +594,7 @@ void pubMqttDiscovery() {
);
createDiscovery("sensor", //set Type
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,
0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
Expand All @@ -603,7 +603,7 @@ void pubMqttDiscovery() {
);
createDiscovery("sensor", //set Type
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,
0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
Expand All @@ -612,7 +612,7 @@ void pubMqttDiscovery() {
);
createDiscovery("sensor", //set Type
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,
0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
Expand All @@ -623,7 +623,7 @@ void pubMqttDiscovery() {
# ifdef ZboardM5STACK
createDiscovery("sensor", //set Type
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,
0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, "", //set,payload_available,payload_not available ,is a child device, command topic
Expand Down Expand Up @@ -652,7 +652,7 @@ void pubMqttDiscovery() {
# endif
createDiscovery("button", //set Type
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,
0, //set off_delay
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset, //set,payload_available,payload_not available ,is a gateway entity, command topic
Expand Down Expand Up @@ -682,7 +682,7 @@ void pubMqttDiscovery() {
Log.trace(F("bme280Discovery" CR));
char* BMEsensor[BMEparametersCount][8] = {
{"sensor", "temp", "bme", "temperature", jsonTempc, "", "", "°C"},
{"sensor", "pa", "bme", "", jsonPa, "", "", "hPa"},
{"sensor", "pa", "bme", "pressure", jsonPa, "", "", "hPa"},
{"sensor", "hum", "bme", "humidity", jsonHum, "", "", "%"},
{"sensor", "altim", "bme", "", jsonAltim, "", "", "m"},
{"sensor", "altift", "bme", "", jsonAltif, "", "", "ft"}
Expand Down Expand Up @@ -802,8 +802,8 @@ void pubMqttDiscovery() {
Log.trace(F("BH1750Discovery" CR));
char* BH1750sensor[BH1750parametersCount][8] = {
{"sensor", "lux", "BH1750", "illuminance", jsonLux, "", "", "lx"},
{"sensor", "ftCd", "BH1750", "", jsonFtcd, "", "", ""},
{"sensor", "wattsm2", "BH1750", "", jsonWm2, "", "", "wm²"}
{"sensor", "ftCd", "BH1750", "irradiance", jsonFtcd, "", "", ""},
{"sensor", "wattsm2", "BH1750", "irradiance", jsonWm2, "", "", "wm²"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

Expand All @@ -824,8 +824,8 @@ void pubMqttDiscovery() {
# define MQ2parametersCount 2
Log.trace(F("MQ2Discovery" CR));
char* MQ2sensor[MQ2parametersCount][8] = {
{"sensor", "gas", "MQ2", "", jsonVal, "", "", "ppm"},
{"binary_sensor", "MQ2", "", "", jsonPresence, "true", "false", ""}
{"sensor", "gas", "MQ2", "gas", jsonVal, "", "", "ppm"},
{"binary_sensor", "MQ2", "", "gas", jsonPresence, "true", "false", ""}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

Expand All @@ -846,8 +846,8 @@ void pubMqttDiscovery() {
Log.trace(F("TEMT6000Discovery" CR));
char* TEMT6000sensor[TEMT6000parametersCount][8] = {
{"sensor", "lux", "TEMT6000", "illuminance", jsonLux, "", "", "lx"},
{"sensor", "ftcd", "TEMT6000", "", jsonFtcd, "", "", ""},
{"sensor", "wattsm2", "TEMT6000", "", jsonWm2, "", "", "wm²"}
{"sensor", "ftcd", "TEMT6000", "irradiance", jsonFtcd, "", "", ""},
{"sensor", "wattsm2", "TEMT6000", "irradiance", jsonWm2, "", "", "wm²"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

Expand All @@ -869,8 +869,8 @@ void pubMqttDiscovery() {
Log.trace(F("TSL2561Discovery" CR));
char* TSL2561sensor[TSL2561parametersCount][8] = {
{"sensor", "lux", "TSL2561", "illuminance", jsonLux, "", "", "lx"},
{"sensor", "ftcd", "TSL2561", "", jsonFtcd, "", "", ""},
{"sensor", "wattsm2", "TSL2561", "", jsonWm2, "", "", "wm²"}
{"sensor", "ftcd", "TSL2561", "irradiance", jsonFtcd, "", "", ""},
{"sensor", "wattsm2", "TSL2561", "irradiance", jsonWm2, "", "", "wm²"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

Expand All @@ -889,7 +889,7 @@ void pubMqttDiscovery() {

# ifdef ZsensorHCSR501
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

//trc(HCSR501sensor[1]);
Expand Down Expand Up @@ -923,9 +923,9 @@ void pubMqttDiscovery() {
# define INA226parametersCount 3
Log.trace(F("INA226Discovery" CR));
char* INA226sensor[INA226parametersCount][8] = {
{"sensor", "volt", "INA226", "", jsonVolt, "", "", "V"},
{"sensor", "current", "INA226", "", jsonCurrent, "", "", "A"},
{"sensor", "power", "INA226", "", jsonPower, "", "", "W"}
{"sensor", "volt", "INA226", "voltage", jsonVolt, "", "", "V"},
{"sensor", "current", "INA226", "current", jsonCurrent, "", "", "A"},
{"sensor", "power", "INA226", "power", jsonPower, "", "", "W"}
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
};

Expand Down
5 changes: 5 additions & 0 deletions main/config_mqttDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,19 @@ const char* availableHASSClasses[] = {"battery",
"duration",
"energy",
"enum",
"gas",
"humidity",
"illuminance",
"irradiance",
"motion",
"moving",
"pm10",
"pm25",
"power",
"power_factor",
"pressure",
"problem",
"restart",
"signal_strength",
"temperature",
"timestamp",
Expand Down