2 Commits

Author SHA1 Message Date
Yurii
47bf122cff fix: HaHelper::publishDynamicSensor() for DHT sensors fixed 2026-02-13 13:02:17 +03:00
Yurii
5797a5c4c0 fix: typo 2026-02-13 11:24:28 +03:00
2 changed files with 9 additions and 8 deletions

View File

@@ -176,9 +176,10 @@ public:
objId.c_str()
);
// set device class, name, value template for bluetooth sensors
// set device class, name, value template for Bluetooth/DHT sensors
// or name & value template for another sensors
if (sSensor.type == Sensors::Type::BLUETOOTH) {
if (sSensor.type == Sensors::Type::BLUETOOTH ||
sSensor.type == Sensors::Type::DHT11 || sSensor.type == Sensors::Type::DHT22) {
// available state topic
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_TOPIC)] = doc[FPSTR(HA_STATE_TOPIC)];
doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = JsonString(AVAILABILITY_SENSOR_CONN, true);

View File

@@ -484,14 +484,11 @@ protected:
this->dhtIsPolling = false;
});
DHT::Type sType;
DHT::Type sType = DHT::Type::DHT22;
if (sSensor.type == Sensors::Type::DHT11) {
sType = DHT::Type::DHT11;
} else if (sSensor.type == Sensors::Type::DHT11) {
sType = DHT::Type::DHT22;
} else {
} else if (sSensor.type == Sensors::Type::DHT22) {
sType = DHT::Type::DHT22;
}
@@ -499,7 +496,10 @@ protected:
Log.sinfoln(FPSTR(L_SENSORS_DHT), F("Started on GPIO %hhu"), sSensor.gpio);
} else {
Log.swarningln(FPSTR(L_SENSORS_DHT), F("Failed to start on GPIO %hhu"), sSensor.gpio);
Log.swarningln(
FPSTR(L_SENSORS_DHT), F("Failed to start on GPIO %hhu (err: %s)"),
sSensor.gpio, DHT::statusToString(this->dhtInstance.getStatus())
);
}
}