mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-03-21 17:58:38 +05:00
feat: Added support DHT11/DHT22 sensors
This commit is contained in:
@@ -1927,6 +1927,8 @@ bool jsonToSensorSettings(const uint8_t sensorId, const JsonVariantConst src, Se
|
||||
case static_cast<uint8_t>(Sensors::Type::NTC_10K_TEMP):
|
||||
case static_cast<uint8_t>(Sensors::Type::DALLAS_TEMP):
|
||||
case static_cast<uint8_t>(Sensors::Type::BLUETOOTH):
|
||||
case static_cast<uint8_t>(Sensors::Type::DHT11):
|
||||
case static_cast<uint8_t>(Sensors::Type::DHT22):
|
||||
case static_cast<uint8_t>(Sensors::Type::HEATING_SETPOINT_TEMP):
|
||||
case static_cast<uint8_t>(Sensors::Type::MANUAL):
|
||||
case static_cast<uint8_t>(Sensors::Type::NOT_CONFIGURED):
|
||||
@@ -1943,7 +1945,8 @@ bool jsonToSensorSettings(const uint8_t sensorId, const JsonVariantConst src, Se
|
||||
|
||||
// gpio
|
||||
if (!src[FPSTR(S_GPIO)].isNull()) {
|
||||
if (dst.type != Sensors::Type::DALLAS_TEMP && dst.type != Sensors::Type::NTC_10K_TEMP) {
|
||||
if (dst.type != Sensors::Type::DALLAS_TEMP && dst.type != Sensors::Type::NTC_10K_TEMP &&
|
||||
dst.type != Sensors::Type::DHT11 && dst.type != Sensors::Type::DHT22) {
|
||||
if (dst.gpio != GPIO_IS_NOT_CONFIGURED) {
|
||||
dst.gpio = GPIO_IS_NOT_CONFIGURED;
|
||||
changed = true;
|
||||
@@ -2084,6 +2087,10 @@ void sensorResultToJson(const uint8_t sensorId, JsonVariant dst) {
|
||||
dst[FPSTR(S_BATTERY)] = roundf(rSensor.values[static_cast<uint8_t>(Sensors::ValueType::BATTERY)], 1);
|
||||
dst[FPSTR(S_RSSI)] = roundf(rSensor.values[static_cast<uint8_t>(Sensors::ValueType::RSSI)], 0);
|
||||
|
||||
} else if (sSensor.type == Sensors::Type::DHT11 || sSensor.type == Sensors::Type::DHT22) {
|
||||
dst[FPSTR(S_TEMPERATURE)] = roundf(rSensor.values[static_cast<uint8_t>(Sensors::ValueType::TEMPERATURE)], 3);
|
||||
dst[FPSTR(S_HUMIDITY)] = roundf(rSensor.values[static_cast<uint8_t>(Sensors::ValueType::HUMIDITY)], 3);
|
||||
|
||||
} else {
|
||||
dst[FPSTR(S_VALUE)] = roundf(rSensor.values[static_cast<uint8_t>(Sensors::ValueType::PRIMARY)], 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user