fix remote humidity and calc dewpoint, dev.2b

This commit is contained in:
MichaelDvP
2023-10-08 19:20:04 +02:00
parent 87ce1a6d9b
commit 0f78d4f34d
6 changed files with 50 additions and 35 deletions

View File

@@ -698,8 +698,9 @@ void Thermostat::process_RemoteTemp(std::shared_ptr<const Telegram> telegram) {
// 0x47B, ff - for reading humidity from the RC100H remote thermostat (0x38, 0x39, ..)
// e.g. "38 10 FF 00 03 7B 08 24 00 4B"
void Thermostat::process_RemoteHumidity(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, dewtemperature_, 0);
// has_update(telegram, dewtemperature_, 0); // this is int8
has_update(telegram, humidity_, 1);
has_update(telegram, dewtemperature_, 2); // this is int16
}
// 0x273 - for reading temperaturcorrection from the RC100H remote thermostat (0x38, 0x39, ..)
@@ -1764,8 +1765,8 @@ bool Thermostat::set_remotetemp(const char * value, const int8_t id) {
}
bool Thermostat::set_remotehum(const char * value, const int8_t id) {
float f;
if (!Helpers::value2float(value, f)) {
int h;
if (!Helpers::value2number(value, h)) {
return false;
}
@@ -1775,10 +1776,10 @@ bool Thermostat::set_remotehum(const char * value, const int8_t id) {
return false;
}
if (f > 100 || f < 0) {
hc->remotehum = EMS_VALUE_SHORT_NOTSET;
if (h > 100 || h < 0) {
hc->remotehum = EMS_VALUE_UINT_NOTSET;
} else {
hc->remotehum = (int16_t)(f * 10);
hc->remotehum = h;
}
if (model() == EMSdevice::EMS_DEVICE_FLAG_RC300) {
@@ -3478,8 +3479,8 @@ void Thermostat::register_device_values() {
// each device controls only one hc, so we tag the values
uint8_t tag = DeviceValueTAG::TAG_HC1 + device_id() - 0x38;
register_device_value(tag, &tempsensor1_, DeviceValueType::SHORT, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(remotetemp), DeviceValueUOM::DEGREES);
register_device_value(tag, &dewtemperature_, DeviceValueType::INT, FL_(dewTemperature), DeviceValueUOM::DEGREES);
register_device_value(tag, &humidity_, DeviceValueType::INT, FL_(airHumidity), DeviceValueUOM::PERCENT);
register_device_value(tag, &dewtemperature_, DeviceValueType::SHORT, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(dewTemperature), DeviceValueUOM::DEGREES);
register_device_value(tag, &humidity_, DeviceValueType::UINT, FL_(airHumidity), DeviceValueUOM::PERCENT);
register_device_value(tag,
&ibaCalIntTemperature_,
DeviceValueType::INT,
@@ -4253,10 +4254,9 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
101);
register_device_value(tag,
&hc->remotehum,
DeviceValueType::SHORT,
DeviceValueNumOp::DV_NUMOP_DIV10,
DeviceValueType::UINT,
FL_(remotehum),
DeviceValueUOM::DEGREES,
DeviceValueUOM::PERCENT,
MAKE_CF_CB(set_remotehum),
-1,
101);

View File

@@ -37,7 +37,7 @@ class Thermostat : public EMSdevice {
int16_t selTemp;
int16_t roomTemp;
int16_t remotetemp; // for readback
int16_t remotehum; // for readback
uint8_t remotehum; // for readback
uint8_t tempautotemp;
int8_t remoteseltemp;
uint8_t mode;
@@ -209,7 +209,7 @@ class Thermostat : public EMSdevice {
int16_t dampedoutdoortemp2_;
uint8_t floordrystatus_;
uint8_t floordrytemp_;
uint8_t dewtemperature_;
int16_t dewtemperature_;
uint8_t humidity_;
uint8_t battery_;

View File

@@ -24,7 +24,7 @@ namespace emsesp {
bool Roomctrl::switch_off_[HCS] = {false, false, false, false};
uint32_t Roomctrl::rc_time_[HCS] = {0, 0, 0, 0};
int16_t Roomctrl::remotetemp_[HCS] = {EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET};
int16_t Roomctrl::remotehum_[HCS] = {EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET, EMS_VALUE_SHORT_NOTSET};
uint8_t Roomctrl::remotehum_[HCS] = {EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET, EMS_VALUE_UINT_NOTSET};
uint8_t Roomctrl::sendcnt[] = {0, 0, 0, 0};
uint8_t Roomctrl::type_ = RC20;
@@ -46,7 +46,7 @@ void Roomctrl::set_remotetemp(const uint8_t type, const uint8_t hc, const int16_
remotetemp_[hc] = temp;
}
void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int16_t hum) {
void Roomctrl::set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum) {
if (hc >= HCS || (type != RC20 && type != FB10 && type != RC100H && type != SENSOR)) {
return;
}
@@ -227,19 +227,23 @@ void Roomctrl::temperature(uint8_t addr, uint8_t dst, uint8_t hc) {
}
}
// send telegram 0x047B only for RC100H
void Roomctrl::humidity(uint8_t addr, uint8_t dst, uint8_t hc) {
uint8_t data[10];
data[0] = addr;
data[1] = dst;
data[0] = addr;
data[1] = dst;
uint16_t dew = calc_dew(remotetemp_[hc], remotehum_[hc]);
if (type_ == RC100H) { // RC100H, telegram 47B
data[2] = 0xFF;
data[3] = 0;
data[4] = 3;
data[5] = 0x7B;
data[6] = (uint8_t)(remotehum_[hc] >> 8);
data[7] = (uint8_t)(remotehum_[hc] & 0xFF);
data[8] = EMSbus::calculate_crc(data, 8); // apppend CRC
EMSuart::transmit(data, 9);
data[2] = 0xFF;
data[3] = 0;
data[4] = 3;
data[5] = 0x7B;
data[6] = (uint8_t)((dew + 5) / 10);
data[7] = remotehum_[hc];
data[8] = (uint8_t)(dew << 8);
data[9] = (uint8_t)(dew & 0xFF);
data[10] = EMSbus::calculate_crc(data, 10); // apppend CRC
EMSuart::transmit(data, 11);
}
}
@@ -252,4 +256,14 @@ void Roomctrl::nack_write() {
EMSuart::transmit(data, 1);
}
uint16_t Roomctrl::calc_dew(uint16_t temp, uint8_t humi) {
const float k2 = 17.62;
const float k3 = 243.12;
const float t = (float)temp / 10;
const float h = (float)humi / 100;
uint16_t dt = (10 * k3 * (((k2 * t) / (k3 + t)) + log(h)) / (((k2 * k3) / (k3 + t)) - log(h)));
return dt;
}
} // namespace emsesp

View File

@@ -27,7 +27,7 @@ class Roomctrl {
static void send(const uint8_t addr);
static void check(const uint8_t addr, const uint8_t * data);
static void set_remotetemp(const uint8_t type, const uint8_t hc, const int16_t temp);
static void set_remotehum(const uint8_t type, const uint8_t hc, const int16_t hum);
static void set_remotehum(const uint8_t type, const uint8_t hc, const int8_t hum);
enum : uint8_t { RC20 = 113, FB10 = 109, RC100H = 200, SENSOR = 0x40 };
private:
@@ -35,17 +35,18 @@ class Roomctrl {
static constexpr uint32_t SEND_INTERVAL = 60000; // 1 minute
static constexpr uint8_t HCS = 4; // max 4 heating circuits
static uint8_t get_hc(const uint8_t addr);
static void version(uint8_t addr, uint8_t dst);
static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset);
static void temperature(uint8_t addr, uint8_t dst, uint8_t hc);
static void humidity(uint8_t addr, uint8_t dst, uint8_t hc);
static void nack_write();
static uint8_t get_hc(const uint8_t addr);
static void version(uint8_t addr, uint8_t dst);
static void unknown(uint8_t addr, uint8_t dst, uint8_t type, uint8_t offset);
static void temperature(uint8_t addr, uint8_t dst, uint8_t hc);
static void humidity(uint8_t addr, uint8_t dst, uint8_t hc);
static void nack_write();
static uint16_t calc_dew(uint16_t temp, uint8_t hum);
static bool switch_off_[HCS];
static uint32_t rc_time_[HCS];
static int16_t remotetemp_[HCS];
static int16_t remotehum_[HCS];
static uint8_t remotehum_[HCS];
static uint8_t sendcnt[HCS];
static uint8_t type_; // type is product-id 113 for RC20 or 109 for Junkers FB10
};

View File

@@ -105,7 +105,7 @@ void Shower::loop() {
// snprintf(s, 50, "%02u:%02u:%02u", (uint8_t)(duration_ / 3600000UL), (uint8_t)(duration_ / 60000UL), (uint8_t)((duration_ / 1000UL) % 60));
doc["duration"] = (duration_ / 1000UL); // seconds
Mqtt::queue_publish("shower_data", doc.as<JsonObject>());
LOG_INFO("finished with duration %lu seconds", duration_);
LOG_INFO("finished with duration %lu seconds", duration_ / 1000UL);
}
}

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.6.3-dev.2a"
#define EMSESP_APP_VERSION "3.6.3-dev.2b"