Skip to content

Commit b53a414

Browse files
committed
fix for MQTT format #205
1 parent ec1bd95 commit b53a414

2 files changed

Lines changed: 16 additions & 19 deletions

File tree

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Support for static IP-Addresses - thanks to @N-b-dy
66
* Support for current IP-Address sensor for Home Assistant - thanks to @Henry-Sir
7+
* Fix for new Home Assistant Autodiscovery format (fixes [#205](https://github.com/fashberg/WThermostatBeca/issues/205))
78

89
## Version 1.22-fas
910

WThermostat/WBecaDevice.h

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const static char HTTP_CONFIG_SCHTAB_FOOT[] PROGMEM = R"=====(
3434
// LWT = Last Will & Testament
3535
const static char MQTT_HASS_AUTODISCOVERY_CLIMATE[] PROGMEM = R"=====(
3636
{
37-
"name":"%s",
37+
"name":null,
3838
"unique_id": "%s",
39-
"dev":{"ids":["%s"],"name":"%s","mdl":"%s","sw":"%s","mf":"WThermostatBeca"},
39+
"dev":{"ids":["%s"],"name":"%s","mdl":"%s","sw":"%s","mf":"WThermostatBeca","cu":"http://%s/config/"},
4040
"~": "%s",
4141
"avty_t":"~/tele/LWT",
4242
"pl_avail":"Online",
@@ -63,9 +63,9 @@ const static char MQTT_HASS_AUTODISCOVERY_CLIMATE[] PROGMEM = R"=====(
6363
)=====";
6464
const static char MQTT_HASS_AUTODISCOVERY_AIRCO[] PROGMEM = R"=====(
6565
{
66-
"name":"%s",
66+
"name":null,
6767
"unique_id": "%s",
68-
"dev":{"ids":["%s"],"name":"%s","mdl":"%s","sw":"%s","mf":"WThermostatBeca"},
68+
"dev":{"ids":["%s"],"name":"%s","mdl":"%s","sw":"%s","mf":"WThermostatBeca","cu":"http://%s/config/"},
6969
"~": "%s",
7070
"avty_t":"~/tele/LWT",
7171
"pl_avail":"Online",
@@ -95,7 +95,7 @@ const static char MQTT_HASS_AUTODISCOVERY_AIRCO[] PROGMEM = R"=====(
9595
)=====";
9696
const static char MQTT_HASS_AUTODISCOVERY_SENSOR[] PROGMEM = R"=====(
9797
{
98-
"name":"%s Temperature",
98+
"name":"Temperature",
9999
"unique_id":"%s",
100100
"device_class":"temperature",
101101
"dev":{"ids":["%s"]},
@@ -107,7 +107,7 @@ const static char MQTT_HASS_AUTODISCOVERY_SENSOR[] PROGMEM = R"=====(
107107
)=====";
108108
const static char MQTT_HASS_AUTODISCOVERY_SENSORFLOOR[] PROGMEM = R"=====(
109109
{
110-
"name":"%s Temperature Floor",
110+
"name":"Temperature Floor",
111111
"unique_id":"%s",
112112
"device_class":"temperature",
113113
"dev":{"ids":["%s"]},
@@ -119,7 +119,7 @@ const static char MQTT_HASS_AUTODISCOVERY_SENSORFLOOR[] PROGMEM = R"====
119119
)=====";
120120
const static char MQTT_HASS_AUTODISCOVERY_SENSORRSSI[] PROGMEM = R"=====(
121121
{
122-
"name":"%s WiFi RSSI",
122+
"name":"WiFi RSSI",
123123
"unique_id":"%s",
124124
"device_class":"signal_strength",
125125
"dev":{"ids":["%s"]},
@@ -131,7 +131,7 @@ const static char MQTT_HASS_AUTODISCOVERY_SENSORRSSI[] PROGMEM = R"=====
131131
)=====";
132132
const static char MQTT_HASS_AUTODISCOVERY_SENSORIP[] PROGMEM = R"=====(
133133
{
134-
"name":"%s IP",
134+
"name":"IP",
135135
"unique_id":"%s",
136136
"dev":{"ids":["%s"]},
137137
"~":"%s",
@@ -1332,29 +1332,29 @@ class WBecaDevice: public WDevice {
13321332
if (!removeDiscovery){
13331333
if (getThermostatModel() == MODEL_BHT_002_GBLW ){
13341334
response->printf_P(MQTT_HASS_AUTODISCOVERY_CLIMATE,
1335-
network->getIdx(),
13361335
unique_id.c_str(),
13371336
network->getMacAddress().c_str(),
13381337
network->getIdx(),
13391338
network->getApplicationName().c_str(),
13401339
network->getFirmwareVersion().c_str(),
1340+
network->getDeviceIp().toString().c_str(),
13411341
network->getMqttTopic(),
13421342
str_temp
13431343
);
13441344
} else if (getThermostatModel() == MODEL_BAC_002_ALW ){
13451345
response->printf_P(MQTT_HASS_AUTODISCOVERY_AIRCO,
1346-
network->getIdx(),
13471346
unique_id.c_str(),
13481347
network->getMacAddress().c_str(),
13491348
network->getIdx(),
13501349
network->getApplicationName().c_str(),
13511350
network->getFirmwareVersion().c_str(),
1351+
network->getDeviceIp().toString().c_str(),
13521352
network->getMqttTopic(),
13531353
str_temp
13541354
);
13551355
}
13561356
}
1357-
if (!network->publishMqtt(topic.c_str(), response, true)) return false;
1357+
network->publishMqtt(topic.c_str(), response, true);
13581358
response->flush();
13591359

13601360
unique_id = (String)network->getIdx();
@@ -1364,13 +1364,12 @@ class WBecaDevice: public WDevice {
13641364
topic.concat(F("/config"));
13651365
if (!removeDiscovery){
13661366
response->printf_P(MQTT_HASS_AUTODISCOVERY_SENSOR,
1367-
network->getIdx(),
13681367
unique_id.c_str(),
13691368
network->getMacAddress().c_str(),
13701369
network->getMqttTopic()
13711370
);
13721371
}
1373-
if (!network->publishMqtt(topic.c_str(), response, true)) return false;
1372+
network->publishMqtt(topic.c_str(), response, true);
13741373
response->flush();
13751374

13761375
if (this->floorSensor->getBoolean()){
@@ -1381,13 +1380,12 @@ class WBecaDevice: public WDevice {
13811380
topic.concat(F("/config"));
13821381
if (!removeDiscovery){
13831382
response->printf_P(MQTT_HASS_AUTODISCOVERY_SENSORFLOOR,
1384-
network->getIdx(),
13851383
unique_id.c_str(),
13861384
network->getMacAddress().c_str(),
13871385
network->getMqttTopic()
13881386
);
13891387
}
1390-
if (!network->publishMqtt(topic.c_str(), response, true)) return false;
1388+
network->publishMqtt(topic.c_str(), response, true);
13911389
response->flush();
13921390
}
13931391

@@ -1398,13 +1396,12 @@ class WBecaDevice: public WDevice {
13981396
topic.concat(F("/config"));
13991397
if (!removeDiscovery){
14001398
response->printf_P(MQTT_HASS_AUTODISCOVERY_SENSORRSSI,
1401-
network->getIdx(),
14021399
unique_id.c_str(),
14031400
network->getMacAddress().c_str(),
14041401
network->getMqttTopic()
14051402
);
14061403
}
1407-
if (!network->publishMqtt(topic.c_str(), response, true)) return false;
1404+
network->publishMqtt(topic.c_str(), response, true);
14081405
response->flush();
14091406

14101407
unique_id = (String)network->getIdx();
@@ -1414,13 +1411,12 @@ class WBecaDevice: public WDevice {
14141411
topic.concat(F("/config"));
14151412
if (!removeDiscovery){
14161413
response->printf_P(MQTT_HASS_AUTODISCOVERY_SENSORIP,
1417-
network->getIdx(),
14181414
unique_id.c_str(),
14191415
network->getMacAddress().c_str(),
14201416
network->getMqttTopic()
14211417
);
14221418
}
1423-
if (!network->publishMqtt(topic.c_str(), response, true)) return false;
1419+
network->publishMqtt(topic.c_str(), response, true);
14241420
response->flush();
14251421
return true;
14261422
}

0 commit comments

Comments
 (0)