mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
enum start at zero
This commit is contained in:
@@ -429,9 +429,9 @@ void Solar::process_SM100Status2(std::shared_ptr<const Telegram> telegram) {
|
|||||||
* e.g. B0 0B FF 00 02 80 50 64 00 00 29 01 00 00 01
|
* e.g. B0 0B FF 00 02 80 50 64 00 00 29 01 00 00 01
|
||||||
*/
|
*/
|
||||||
void Solar::process_SM100CollectorConfig(std::shared_ptr<const Telegram> telegram) {
|
void Solar::process_SM100CollectorConfig(std::shared_ptr<const Telegram> telegram) {
|
||||||
has_update(telegram->read_value(climateZone_, 0, 1));
|
has_update(telegram->read_value(climateZone_, 0));
|
||||||
has_update(telegram->read_value(collector1Area_, 3, 2));
|
has_update(telegram->read_value(collector1Area_, 3));
|
||||||
has_update(telegram->read_value(collector1Type_, 5, 1));
|
has_update(telegram->read_enumvalue(collector1Type_, 5, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -688,7 +688,7 @@ bool Solar::set_collector1Type(const char * value, const int8_t id) {
|
|||||||
if (!Helpers::value2enum(value, num, FL_(enum_collectortype))) {
|
if (!Helpers::value2enum(value, num, FL_(enum_collectortype))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
write_command(0x380, 5, num, 0x380);
|
write_command(0x380, 5, num + 1, 0x380);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -773,9 +773,9 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr<const Telegram> telegram
|
|||||||
has_update(telegram->read_value(hc->curr_roomTemp, 4)); // value is * 10
|
has_update(telegram->read_value(hc->curr_roomTemp, 4)); // value is * 10
|
||||||
has_update(telegram->read_value(hc->setpoint_roomTemp, 2)); // value is * 10
|
has_update(telegram->read_value(hc->setpoint_roomTemp, 2)); // value is * 10
|
||||||
|
|
||||||
has_update(telegram->read_value(hc->modetype, 0)); // 1 = nofrost, 2 = eco, 3 = heat
|
has_update(telegram->read_enumvalue(hc->modetype, 0, 1)); // 1 = nofrost, 2 = eco, 3 = heat
|
||||||
has_update(telegram->read_value(hc->mode, 1)); // 1 = manual, 2 = auto
|
has_update(telegram->read_enumvalue(hc->mode, 1, 1)); // 1 = manual, 2 = auto
|
||||||
hc->hamode = hc->mode; // set special HA mode
|
hc->hamode = hc->mode + 1; // set special HA mode
|
||||||
}
|
}
|
||||||
|
|
||||||
// type 0x02A5 - data from Worchester CRF200
|
// type 0x02A5 - data from Worchester CRF200
|
||||||
@@ -917,7 +917,7 @@ void Thermostat::process_RC300OutdoorTemp(std::shared_ptr<const Telegram> telegr
|
|||||||
|
|
||||||
// 0x240 RC300 parameter
|
// 0x240 RC300 parameter
|
||||||
void Thermostat::process_RC300Settings(std::shared_ptr<const Telegram> telegram) {
|
void Thermostat::process_RC300Settings(std::shared_ptr<const Telegram> telegram) {
|
||||||
has_update(telegram->read_value(ibaBuildingType_, 9)); // 1=light, 2=medium, 3=heavy
|
has_update(telegram->read_enumvalue(ibaBuildingType_, 9, 1)); // 1=light, 2=medium, 3=heavy
|
||||||
has_update(telegram->read_value(ibaMinExtTemperature_, 10));
|
has_update(telegram->read_value(ibaMinExtTemperature_, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1199,11 +1199,11 @@ bool Thermostat::set_building(const char * value, const int8_t id) {
|
|||||||
if ((model() == EMS_DEVICE_FLAG_RC300) || (model() == EMS_DEVICE_FLAG_RC100)) {
|
if ((model() == EMS_DEVICE_FLAG_RC300) || (model() == EMS_DEVICE_FLAG_RC100)) {
|
||||||
if (Helpers::value2enum(value, bd, FL_(enum_ibaBuildingType))) {
|
if (Helpers::value2enum(value, bd, FL_(enum_ibaBuildingType))) {
|
||||||
LOG_INFO(F("Setting building to %s"), value);
|
LOG_INFO(F("Setting building to %s"), value);
|
||||||
write_command(0x240, 9, bd, 0x240);
|
write_command(0x240, 9, bd + 1, 0x240);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Helpers::value2enum(value, bd, FL_(enum_ibaBuildingType2))) {
|
if (Helpers::value2enum(value, bd, FL_(enum_ibaBuildingType))) {
|
||||||
LOG_INFO(F("Setting building to %s"), value);
|
LOG_INFO(F("Setting building to %s"), value);
|
||||||
write_command(EMS_TYPE_IBASettings, 6, bd, EMS_TYPE_IBASettings);
|
write_command(EMS_TYPE_IBASettings, 6, bd, EMS_TYPE_IBASettings);
|
||||||
return true;
|
return true;
|
||||||
@@ -2180,7 +2180,7 @@ void Thermostat::register_device_values() {
|
|||||||
register_device_value(TAG_THERMOSTAT_DATA,
|
register_device_value(TAG_THERMOSTAT_DATA,
|
||||||
&ibaBuildingType_,
|
&ibaBuildingType_,
|
||||||
DeviceValueType::ENUM,
|
DeviceValueType::ENUM,
|
||||||
FL_(enum_ibaBuildingType2),
|
FL_(enum_ibaBuildingType),
|
||||||
FL_(ibaBuildingType),
|
FL_(ibaBuildingType),
|
||||||
DeviceValueUOM::NONE,
|
DeviceValueUOM::NONE,
|
||||||
MAKE_CF_CB(set_building));
|
MAKE_CF_CB(set_building));
|
||||||
@@ -2210,7 +2210,7 @@ void Thermostat::register_device_values() {
|
|||||||
register_device_value(TAG_THERMOSTAT_DATA,
|
register_device_value(TAG_THERMOSTAT_DATA,
|
||||||
&ibaBuildingType_,
|
&ibaBuildingType_,
|
||||||
DeviceValueType::ENUM,
|
DeviceValueType::ENUM,
|
||||||
FL_(enum_ibaBuildingType2),
|
FL_(enum_ibaBuildingType),
|
||||||
FL_(ibaBuildingType),
|
FL_(ibaBuildingType),
|
||||||
DeviceValueUOM::NONE,
|
DeviceValueUOM::NONE,
|
||||||
MAKE_CF_CB(set_building));
|
MAKE_CF_CB(set_building));
|
||||||
|
|||||||
@@ -248,7 +248,6 @@ MAKE_PSTR_WORD(light)
|
|||||||
MAKE_PSTR_WORD(medium)
|
MAKE_PSTR_WORD(medium)
|
||||||
MAKE_PSTR_WORD(heavy)
|
MAKE_PSTR_WORD(heavy)
|
||||||
MAKE_PSTR_WORD(own_prog)
|
MAKE_PSTR_WORD(own_prog)
|
||||||
MAKE_PSTR(blank, "")
|
|
||||||
MAKE_PSTR_WORD(start)
|
MAKE_PSTR_WORD(start)
|
||||||
MAKE_PSTR_WORD(heat)
|
MAKE_PSTR_WORD(heat)
|
||||||
MAKE_PSTR_WORD(hold)
|
MAKE_PSTR_WORD(hold)
|
||||||
@@ -309,25 +308,24 @@ MAKE_PSTR_LIST(enum_ibaMainDisplay,
|
|||||||
F_(smoke_temperature))
|
F_(smoke_temperature))
|
||||||
MAKE_PSTR_LIST(enum_ibaLanguage, F_(german), F_(dutch), F_(french), F_(italian))
|
MAKE_PSTR_LIST(enum_ibaLanguage, F_(german), F_(dutch), F_(french), F_(italian))
|
||||||
MAKE_PSTR_LIST(enum_floordrystatus, F_(off), F_(start), F_(heat), F_(hold), F_(cool), F_(end))
|
MAKE_PSTR_LIST(enum_floordrystatus, F_(off), F_(start), F_(heat), F_(hold), F_(cool), F_(end))
|
||||||
MAKE_PSTR_LIST(enum_ibaBuildingType, F_(blank), F_(light), F_(medium), F_(heavy)) // RC300
|
MAKE_PSTR_LIST(enum_ibaBuildingType, F_(light), F_(medium), F_(heavy)) // RC300
|
||||||
MAKE_PSTR_LIST(enum_wwMode, F_(off), F_(low), F_(high), F_(auto), F_(own_prog))
|
MAKE_PSTR_LIST(enum_wwMode, F_(off), F_(low), F_(high), F_(auto), F_(own_prog))
|
||||||
MAKE_PSTR_LIST(enum_wwCircMode, F_(off), F_(on), F_(auto), F_(own_prog))
|
MAKE_PSTR_LIST(enum_wwCircMode, F_(off), F_(on), F_(auto), F_(own_prog))
|
||||||
MAKE_PSTR_LIST(enum_ibaBuildingType2, F_(light), F_(medium), F_(heavy)) // RC30, RC35
|
|
||||||
MAKE_PSTR_LIST(enum_wwMode2, F_(off), F_(on), F_(auto))
|
MAKE_PSTR_LIST(enum_wwMode2, F_(off), F_(on), F_(auto))
|
||||||
MAKE_PSTR_LIST(enum_wwCircMode2, F_(off), F_(on), F_(auto))
|
MAKE_PSTR_LIST(enum_wwCircMode2, F_(off), F_(on), F_(auto))
|
||||||
MAKE_PSTR_LIST(enum_heatingtype, F_(off), F_(radiator), F_(convector), F_(floor))
|
MAKE_PSTR_LIST(enum_heatingtype, F_(off), F_(radiator), F_(convector), F_(floor))
|
||||||
MAKE_PSTR_LIST(enum_summermode, F_(summer), F_(auto), F_(winter))
|
MAKE_PSTR_LIST(enum_summermode, F_(summer), F_(auto), F_(winter))
|
||||||
|
|
||||||
MAKE_PSTR_LIST(enum_mode, F_(manual), F_(auto)) // RC100, RC300, RC310
|
MAKE_PSTR_LIST(enum_mode, F_(manual), F_(auto)) // RC100, RC300, RC310
|
||||||
MAKE_PSTR_LIST(enum_mode2, F_(off), F_(manual), F_(auto)) // RC20
|
MAKE_PSTR_LIST(enum_mode2, F_(off), F_(manual), F_(auto)) // RC20
|
||||||
MAKE_PSTR_LIST(enum_mode3, F_(night), F_(day), F_(auto)) // RC35, RC30
|
MAKE_PSTR_LIST(enum_mode3, F_(night), F_(day), F_(auto)) // RC35, RC30
|
||||||
MAKE_PSTR_LIST(enum_mode4, F_(blank), F_(manual), F_(auto), F_(holiday)) // JUNKERS
|
MAKE_PSTR_LIST(enum_mode4, F_(manual), F_(auto), F_(holiday)) // JUNKERS
|
||||||
MAKE_PSTR_LIST(enum_mode5, F_(auto), F_(off)) // CRF
|
MAKE_PSTR_LIST(enum_mode5, F_(auto), F_(off)) // CRF
|
||||||
|
|
||||||
MAKE_PSTR_LIST(enum_modetype, F_(eco), F_(comfort))
|
MAKE_PSTR_LIST(enum_modetype, F_(eco), F_(comfort))
|
||||||
MAKE_PSTR_LIST(enum_modetype2, F_(day))
|
MAKE_PSTR_LIST(enum_modetype2, F_(day))
|
||||||
MAKE_PSTR_LIST(enum_modetype3, F_(night), F_(day))
|
MAKE_PSTR_LIST(enum_modetype3, F_(night), F_(day))
|
||||||
MAKE_PSTR_LIST(enum_modetype4, F_(blank), F_(nofrost), F_(eco), F_(heat))
|
MAKE_PSTR_LIST(enum_modetype4, F_(nofrost), F_(eco), F_(heat))
|
||||||
MAKE_PSTR_LIST(enum_modetype5, F_(off), F_(on))
|
MAKE_PSTR_LIST(enum_modetype5, F_(off), F_(on))
|
||||||
|
|
||||||
MAKE_PSTR_LIST(enum_reducemode, F_(nofrost), F_(reduce), F_(room), F_(outdoor))
|
MAKE_PSTR_LIST(enum_reducemode, F_(nofrost), F_(reduce), F_(room), F_(outdoor))
|
||||||
@@ -341,7 +339,7 @@ MAKE_PSTR_LIST(enum_hamode, F_(off), F_(heat), F_(auto), F_(heat), F_(off), F_(h
|
|||||||
|
|
||||||
// solar list
|
// solar list
|
||||||
MAKE_PSTR_LIST(enum_solarmode, F_(constant), F("pwm"), F("analog"))
|
MAKE_PSTR_LIST(enum_solarmode, F_(constant), F("pwm"), F("analog"))
|
||||||
MAKE_PSTR_LIST(enum_collectortype, F_(blank), F("flat"), F("vacuum"))
|
MAKE_PSTR_LIST(enum_collectortype, F("flat"), F("vacuum"))
|
||||||
|
|
||||||
// MQTT topics and full text for values and commands
|
// MQTT topics and full text for values and commands
|
||||||
MAKE_PSTR(homeassistant, "homeassistant/")
|
MAKE_PSTR(homeassistant, "homeassistant/")
|
||||||
|
|||||||
@@ -92,10 +92,7 @@ class Telegram {
|
|||||||
}
|
}
|
||||||
uint8_t val = value;
|
uint8_t val = value;
|
||||||
value = (uint8_t)(((this->message_data[abs_index]) >> (bit)) & 0x01);
|
value = (uint8_t)(((this->message_data[abs_index]) >> (bit)) & 0x01);
|
||||||
if (val != value) {
|
return (val != value);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read a value from a telegram. We always store the value, regardless if its garbage
|
// read a value from a telegram. We always store the value, regardless if its garbage
|
||||||
@@ -116,10 +113,16 @@ class Telegram {
|
|||||||
for (uint8_t i = 0; i < num_bytes; i++) {
|
for (uint8_t i = 0; i < num_bytes; i++) {
|
||||||
value = (value << 8) + this->message_data[index - this->offset + i]; // shift by byte
|
value = (value << 8) + this->message_data[index - this->offset + i]; // shift by byte
|
||||||
}
|
}
|
||||||
if (val != value) {
|
return (val != value);
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
bool read_enumvalue(uint8_t & value, const uint8_t index, uint8_t start = 0) const {
|
||||||
|
if ((index < this->offset) || ((index - this->offset) >= this->message_length)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
uint8_t val = value;
|
||||||
|
value = this->message_data[index - this->offset] - start;
|
||||||
|
return (val != value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user