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

Add device_class to MQTT Discovery for rtl_433_ESP #1419

Merged
merged 14 commits into from
Jan 25, 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
6 changes: 3 additions & 3 deletions main/ZgatewayRTL_433.ino
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void launchRTL_433Discovery(bool overrideDiscovery) {
if (strcmp(parameters[i][0], "tamper") == 0 || strcmp(parameters[i][0], "alarm") == 0 || strcmp(parameters[i][0], "motion") == 0) {
createDiscovery("binary_sensor", //set Type
(char*)topic.c_str(), parameters[i][1], pdevice->uniqueId, //set state_topic,name,uniqueId
"", "", (char*)value_template.c_str(), //set availability_topic,device_class,value_template,
"", parameters[i][3], (char*)value_template.c_str(), //set availability_topic,device_class,value_template,
"1", "0", parameters[i][2], //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
"", "", false, "", //set,payload_available,payload_not available ,is a gateway entity, command topic
Expand All @@ -154,7 +154,7 @@ void launchRTL_433Discovery(bool overrideDiscovery) {
} else if (strcmp(parameters[i][0], "strike_count") == 0) {
createDiscovery("sensor", //set Type
(char*)topic.c_str(), parameters[i][1], pdevice->uniqueId, //set state_topic,name,uniqueId
"", "", (char*)value_template.c_str(), //set availability_topic,device_class,value_template,
"", parameters[i][3], (char*)value_template.c_str(), //set availability_topic,device_class,value_template,
"1", "0", parameters[i][2], //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
"", "", false, "", //set,payload_available,payload_not available ,is a gateway entity, command topic
Expand All @@ -164,7 +164,7 @@ void launchRTL_433Discovery(bool overrideDiscovery) {
} else {
createDiscovery("sensor", //set Type
(char*)topic.c_str(), parameters[i][1], pdevice->uniqueId, //set state_topic,name,uniqueId
"", "", (char*)value_template.c_str(), //set availability_topic,device_class,value_template,
"", parameters[i][3], (char*)value_template.c_str(), //set availability_topic,device_class,value_template,
"", "", parameters[i][2], //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
"", "", false, "", //set,payload_available,payload_not available ,is a gateway entity, command topic
Expand Down
82 changes: 41 additions & 41 deletions main/config_RF.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,47 +82,47 @@ struct RTL_433device {

extern std::vector<RTL_433device*> RTL_433devices;

const char parameters[39][3][16] = {
// RTL_433 key, name, unit
{"temperature_C", "temperature", "°C"},
{"temperature_1_C", "temperature", "°C"},
{"temperature_2_C", "temperature", "°C"},
{"temperature_F", "temperature", "°F"},
{"time", "timestamp", ""},
{"battery_ok", "battery", ""},
{"humidity", "humidity", "%"},
{"moisture", "moisture", "%"},
{"pressure_hPa", "pressure", "hPa"},
{"pressure_kPa", "pressure", "kPa"},
{"wind_speed_km_h", "wind speed", "km/h"},
{"wind_avg_km_h", "wind average", "km/h"},
{"wind_avg_mi_h", "wind average", "mi/h"},
{"wind_avg_m_s", "wind average", "m/s"},
{"wind_speed_m_s", "wind speed", "m/s"},
{"gust_speed_km_h", "gust speed", "km/h"},
{"wind_max_km_h", "wind max", "km/h"},
{"wind_max_m_s", "wind max", "m/s"},
{"gust_speed_m_s", "gust speed", "m/s"},
{"wind_dir_deg", "wind direction", "°"},
{"rain_mm", "rain", "mm"},
{"rain_mm_h", "rain", "mm/h"},
{"rain_in", "rain", "in"},
{"rain_rate_in_h", "rain", "in/h"},
{"rssi", "rssi", "dB"},
{"snr", "snr", "dB"},
{"noise", "noise", "dB"},
{"depth_cm", "depth", "cm"},
{"power_W", "power", "W"},
{"light_lux", "light", "lx"},
{"lux", "lux", "lx"},
{"uv", "uv", "UV index"},
{"uvi", "uvi", "UV index"},
{"storm_dist", "storm distance", "mi"},
{"strike_distance", "strike distance", "mi"},
{"tamper", "tamper", ""},
{"alarm", "alarm", ""},
{"motion", "motion", ""},
{"strike_count", "strike count", ""}}; // from rtl_433_mqtt_hass.py
const char parameters[39][4][24] = {
// RTL_433 key, name, unit, device_class
{"temperature_C", "temperature", "°C", "temperature"},
{"temperature_1_C", "temperature", "°C", "temperature"},
{"temperature_2_C", "temperature", "°C", "temperature"},
{"temperature_F", "temperature", "°F", "temperature"},
{"time", "timestamp", "", "timestamp"},
{"battery_ok", "battery", "", "battery"},
{"humidity", "humidity", "%", "humidity"},
{"moisture", "moisture", "%", "humidity"},
{"pressure_hPa", "pressure", "hPa", "pressure"},
{"pressure_kPa", "pressure", "kPa", "pressure"},
{"wind_speed_km_h", "wind speed", "km/h", "wind_speed"},
{"wind_avg_km_h", "wind average", "km/h", "wind_speed"},
{"wind_avg_mi_h", "wind average", "mi/h", "wind_speed"},
{"wind_avg_m_s", "wind average", "m/s", "wind_speed"},
{"wind_speed_m_s", "wind speed", "m/s", "wind_speed"},
{"gust_speed_km_h", "gust speed", "km/h", "wind_speed"},
{"wind_max_km_h", "wind max", "km/h", "wind_speed"},
{"wind_max_m_s", "wind max", "m/s", "wind_speed"},
{"gust_speed_m_s", "gust speed", "m/s", "wind_speed"},
{"wind_dir_deg", "wind direction", "°", ""},
{"rain_mm", "rain", "mm", "precipitation"},
{"rain_mm_h", "rain", "mm/h", "precipitation"},
{"rain_in", "rain", "in", "precipitation_intensity"},
{"rain_rate_in_h", "rain", "in/h", "precipitation_intensity"},
{"rssi", "rssi", "dB", "signal_strength"},
{"snr", "snr", "dB", ""},
{"noise", "noise", "dB", ""},
{"depth_cm", "depth", "cm", ""},
{"power_W", "power", "W", "power"},
{"light_lux", "light", "lx", ""},
{"lux", "lux", "lx", ""},
{"uv", "uv", "UV index", ""},
{"uvi", "uvi", "UV index", ""},
{"storm_dist", "storm distance", "mi", ""},
{"strike_distance", "strike distance", "mi", ""},
{"tamper", "tamper", "", ""},
{"alarm", "alarm", "", ""},
{"motion", "motion", "", "motion"},
{"strike_count", "strike count", "", ""}}; // from rtl_433_mqtt_hass.py
# endif
#endif
/*-------------------RF topics & parameters----------------------*/
Expand Down