Skip to content

Commit

Permalink
v3.2.1 merged from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Aug 8, 2021
2 parents 7eb1f06 + 30ce3f1 commit 2ca0a0c
Show file tree
Hide file tree
Showing 16 changed files with 310 additions and 238 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [3.2.1] August 8 2021

## Added

- json body in API can now take device, name, cmd, hc and id
- added example of how to use API directly to control values from Home Assistant
- API calls are shown in debug log (For troubleshooting)

## Fixed

- fixed issue with Home Assistant entity naming where boiler's ww was duplicated in entity name
- fixed issue where wwSetTemp was written too instead of wwSelTemp

## Changed

- fixed case on mqtt names, like 'wwtankmiddletemp'
- renamed Product ID to 'EMS Product ID' in Home Assistant
- removed brackets around tags, e.g. (hc1) selected room temperature" is now just "hc1 selected room temperature"

# [3.2.0] August 6 2021

## Added
Expand Down
4 changes: 2 additions & 2 deletions src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *

// strip prefixes, check, and find command
Command::CmdFunction * Command::find_command(const uint8_t device_type, char * cmd, int8_t & id) {
// TODO special cases for id=0 and id=-1 will be removed in V3 API
// special cases for id=0 and id=-1 will be removed in V3 API
// no command for id0
if (id == 0) {
return nullptr;
Expand All @@ -126,7 +126,7 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, char * c
*p = tolower(*p);
}

// TODO hack for commands that could have hc or wwc prefixed. will be removed in new API V3 eventually
// hack for commands that could have hc or wwc prefixed. will be removed in new API V3 eventually
// scan for prefix hc.
for (uint8_t i = DeviceValueTAG::TAG_HC1; i <= DeviceValueTAG::TAG_HC4; i++) {
const char * tag = EMSdevice::tag_to_string(i).c_str();
Expand Down
2 changes: 2 additions & 0 deletions src/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ using uuid::log::Level;

// clang-format off
// strings stored 32 bit aligned on ESP8266/ESP32
#define MAKE_STR(string_name, string_literal) static constexpr const char * __str__##string_name = string_literal;
#define MAKE_PSTR(string_name, string_literal) static const char __pstr__##string_name[] __attribute__((__aligned__(sizeof(uint32_t)))) PROGMEM = string_literal;
#define MAKE_PSTR_WORD(string_name) MAKE_PSTR(string_name, #string_name)
#define F_(string_name) FPSTR(__pstr__##string_name)
#define FSTR_(string_name) __str__##string_name
#define MAKE_PSTR_LIST(list_name, ...) static const __FlashStringHelper * const __pstr__##list_name[] PROGMEM = {__VA_ARGS__, nullptr};
#define FL_(list_name) (__pstr__##list_name)
// clang-format on
Expand Down
1 change: 0 additions & 1 deletion src/dallassensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ void DallasSensor::loop() {
if (sensor.id() == get_id(addr)) {
t += sensor.offset();
if (t != sensor.temperature_c) {
sensor.temperature_c = t;
changed_ |= true;
}
sensor.temperature_c = t;
Expand Down
203 changes: 101 additions & 102 deletions src/devices/boiler.cpp

Large diffs are not rendered by default.

63 changes: 31 additions & 32 deletions src/devices/boiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,39 @@ class Boiler : public EMSdevice {
static constexpr uint8_t EMS_BOILER_SELFLOWTEMP_HEATING = 20; // was originally 70, changed to 30 for issue #193, then to 20 with issue #344

// ww
uint8_t wWSetTemp_; // Warm Water set temperature
uint8_t wWSelTemp_; // Warm Water selected temperature
uint8_t wWType_; // 0-off, 1-flow, 2-flowbuffer, 3-buffer, 4-layered buffer
uint8_t wWComfort_; // WW comfort mode
uint8_t wWCircPump_; // Warm Water circulation pump available
uint8_t wwSetTemp_; // Warm Water set temperature
uint8_t wwSelTemp_; // Warm Water selected temperature
uint8_t wwType_; // 0-off, 1-flow, 2-flowbuffer, 3-buffer, 4-layered buffer
uint8_t wwComfort_; // WW comfort mode
uint8_t wwCircPump_; // Warm Water circulation pump available
uint8_t wWChargeType_; // Warm Water charge type (pump or 3-way-valve)
uint8_t wWDisinfectionTemp_; // Warm Water disinfection temperature to prevent infection
uint8_t wWCircMode_; // Warm Water circulation pump mode
uint8_t wWCirc_; // Circulation on/off
uint16_t wWCurTemp_; // Warm Water current temperature
uint16_t wWCurTemp2_; // Warm Water current temperature storage
uint8_t wWCurFlow_; // Warm Water current flow temp in l/min
uint16_t wWStorageTemp1_; // warm water storage temp 1
uint16_t wWStorageTemp2_; // warm water storage temp 2
uint8_t wWActivated_; // Warm Water activated
uint8_t wWOneTime_; // Warm Water one time function on/off
uint8_t wWDisinfecting_; // Warm Water disinfection on/off
uint8_t wWCharging_; // Warm Water charging on/off
uint8_t wWRecharging_; // Warm Water recharge on/off
uint8_t wWTempOK_; // Warm Water temperature ok on/off
uint8_t wWActive_; //
uint8_t wWHeat_; // 3-way valve on WW
uint8_t wWSetPumpPower_; // ww pump speed/power?
uint8_t wWFlowTempOffset_; // Boiler offset for ww heating
uint8_t wWMaxPower_; // Warm Water maximum power
uint8_t wwDisinfectionTemp_; // Warm Water disinfection temperature to prevent infection
uint8_t wwCircMode_; // Warm Water circulation pump mode
uint8_t wwCirc_; // Circulation on/off
uint16_t wwCurTemp_; // Warm Water current temperature
uint16_t wwCurTemp2_; // Warm Water current temperature storage
uint8_t wwCurFlow_; // Warm Water current flow temp in l/min
uint16_t wwStorageTemp1_; // warm water storage temp 1
uint16_t wwStorageTemp2_; // warm water storage temp 2
uint8_t wwActivated_; // Warm Water activated
uint8_t wwOneTime_; // Warm Water one time function on/off
uint8_t wwDisinfecting_; // Warm Water disinfection on/off
uint8_t wwCharging_; // Warm Water charging on/off
uint8_t wwRecharging_; // Warm Water recharge on/off
uint8_t wwTempOK_; // Warm Water temperature ok on/off
uint8_t wwActive_; //
uint8_t wwHeat_; // 3-way valve on WW
uint8_t wwSetPumpPower_; // ww pump speed/power?
uint8_t wwFlowTempOffset_; // Boiler offset for ww heating
uint8_t wwMaxPower_; // Warm Water maximum power
uint32_t wWStarts_; // Warm Water # starts
uint32_t wWStarts2_; // Warm water control starts
uint32_t wWWorkM_; // Warm Water # minutes
int8_t wWHystOn_;
int8_t wWHystOff_;
uint8_t wWTapActivated_; // maintenance-mode to switch DHW off

uint16_t mixerTemp_; // mixing temperature
uint16_t tankMiddleTemp_; // Tank middle temperature (TS3)
uint32_t wwStarts2_; // Warm water control starts
uint32_t wwWorkM_; // Warm Water # minutes
int8_t wwHystOn_;
int8_t wwHystOff_;
uint8_t wwTapActivated_; // maintenance-mode to switch DHW off
uint16_t wwMixerTemp_; // mixing temperature
uint16_t wwTankMiddleTemp_; // Tank middle temperature (TS3)

// main
uint8_t id_; // product id
Expand Down
2 changes: 1 addition & 1 deletion src/devices/heatpump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool Heatpump::publish_ha_config() {
doc["stat_t"] = stat_t;

char name_s[40];
snprintf_P(name_s, sizeof(name_s), PSTR("* %s Product ID"), device_type_name().c_str());
snprintf(name_s, sizeof(name_s), FSTR_(productid_fmt), device_type_name().c_str());
doc["name"] = name_s;

doc["val_tpl"] = FJSON("{{value_json.id}}");
Expand Down
2 changes: 1 addition & 1 deletion src/devices/solar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool Solar::publish_ha_config() {
doc["stat_t"] = stat_t;

char name_s[40];
snprintf_P(name_s, sizeof(name_s), PSTR("* %s Product ID"), device_type_name().c_str());
snprintf(name_s, sizeof(name_s), FSTR_(productid_fmt), device_type_name().c_str());
doc["name"] = name_s;

doc["val_tpl"] = FJSON("{{value_json.id}}");
Expand Down
2 changes: 1 addition & 1 deletion src/devices/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool Switch::publish_ha_config() {
doc["stat_t"] = stat_t;

char name_s[40];
snprintf_P(name_s, sizeof(name_s), PSTR("* %s Product ID"), device_type_name().c_str());
snprintf_P(name_s, sizeof(name_s), FSTR_(productid_fmt), device_type_name().c_str());
doc["name"] = name_s;

doc["val_tpl"] = FJSON("{{value_json.id}}");
Expand Down
8 changes: 4 additions & 4 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ bool Thermostat::publish_ha_config() {
doc["stat_t"] = stat_t;

char name_s[40];
snprintf_P(name_s, sizeof(name_s), PSTR("* %s Product ID"), device_type_name().c_str());
snprintf(name_s, sizeof(name_s), FSTR_(productid_fmt), device_type_name().c_str());
doc["name"] = name_s;

doc["val_tpl"] = FJSON("{{value_json.id}}");
Expand Down Expand Up @@ -2185,7 +2185,7 @@ void Thermostat::register_device_values() {
register_device_value(
TAG_THERMOSTAT_DATA, &wwSetTempLow_, DeviceValueType::UINT, nullptr, FL_(wwSetTempLow), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_wwtemplow));
register_device_value(
TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode), FL_(wWCircMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwcircmode));
TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode), FL_(wwCircMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwcircmode));
register_device_value(TAG_THERMOSTAT_DATA, &wwExtra1_, DeviceValueType::UINT, nullptr, FL_(wwExtra1), DeviceValueUOM::DEGREES);
register_device_value(TAG_THERMOSTAT_DATA, &wwExtra2_, DeviceValueType::UINT, nullptr, FL_(wwExtra2), DeviceValueUOM::DEGREES);
break;
Expand Down Expand Up @@ -2227,7 +2227,7 @@ void Thermostat::register_device_values() {
MAKE_CF_CB(set_building));
register_device_value(TAG_THERMOSTAT_DATA, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode2), FL_(wwMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwmode));
register_device_value(
TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode2), FL_(wWCircMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwcircmode));
TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode2), FL_(wwCircMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwcircmode));
break;
case EMS_DEVICE_FLAG_RC35:
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::TEXT, nullptr, FL_(dateTime), DeviceValueUOM::NONE, MAKE_CF_CB(set_datetime));
Expand Down Expand Up @@ -2257,7 +2257,7 @@ void Thermostat::register_device_values() {
MAKE_CF_CB(set_building));
register_device_value(TAG_THERMOSTAT_DATA, &wwMode_, DeviceValueType::ENUM, FL_(enum_wwMode2), FL_(wwMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwmode));
register_device_value(
TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode2), FL_(wWCircMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwcircmode));
TAG_THERMOSTAT_DATA, &wwCircMode_, DeviceValueType::ENUM, FL_(enum_wwCircMode2), FL_(wwCircMode), DeviceValueUOM::LIST, MAKE_CF_CB(set_wwcircmode));
break;
case EMS_DEVICE_FLAG_JUNKERS:
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::TEXT, nullptr, FL_(dateTime), DeviceValueUOM::NONE, MAKE_CF_CB(set_datetime));
Expand Down
15 changes: 7 additions & 8 deletions src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,11 @@ void EMSdevice::generate_values_json_web(JsonObject & json) {
obj["u"] = dv.uom;

// add name, prefixing the tag if it exists
// except if it's a BOILER which uses a tag to split the MQTT topics
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty() || device_type_ == DeviceType::BOILER) {
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
obj["n"] = dv.full_name;
} else {
char name[50];
snprintf_P(name, sizeof(name), "(%s) %s", tag_to_string(dv.tag).c_str(), uuid::read_flash_string(dv.full_name).c_str());
snprintf_P(name, sizeof(name), "%s %s", tag_to_string(dv.tag).c_str(), uuid::read_flash_string(dv.full_name).c_str());
obj["n"] = name;
}

Expand Down Expand Up @@ -688,10 +687,10 @@ bool EMSdevice::get_value_info(JsonObject & root, const char * cmd, const int8_t
json["name"] = dv.short_name;
// prefix tag if it's included
if (dv.full_name != nullptr) {
if (dv.tag >= DeviceValueTAG::TAG_HC1) {
json["fullname"] = tag_to_string(dv.tag) + " " + uuid::read_flash_string(dv.full_name);
} else {
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
json["fullname"] = dv.full_name;
} else {
json["fullname"] = tag_to_string(dv.tag) + " " + uuid::read_flash_string(dv.full_name);
}
}

Expand Down Expand Up @@ -850,13 +849,13 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter
if (((nested) || tag_filter == DeviceValueTAG::TAG_NONE || (tag_filter == dv.tag)) && (dv.full_name != nullptr || !console)
&& !(dv.full_name == nullptr && dv.has_cmd)) {
// we have a tag if it matches the filter given, and that the tag name is not empty/""
bool have_tag = ((dv.tag != tag_filter) && !tag_to_string(dv.tag).empty()) && (device_type_ != DeviceType::BOILER);
bool have_tag = ((dv.tag != tag_filter) && !tag_to_string(dv.tag).empty());

char name[80];
if (console) {
// prefix the tag in brackets, unless it's Boiler because we're naughty and use tag for the MQTT topic
if (have_tag) {
snprintf_P(name, 80, "(%s) %s", tag_to_string(dv.tag).c_str(), uuid::read_flash_string(dv.full_name).c_str());
snprintf_P(name, 80, "%s %s", tag_to_string(dv.tag).c_str(), uuid::read_flash_string(dv.full_name).c_str());
} else {
strcpy(name, uuid::read_flash_string(dv.full_name).c_str()); // use full name
}
Expand Down
Loading

0 comments on commit 2ca0a0c

Please sign in to comment.