Skip to content

Commit

Permalink
Merge pull request #870 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
Changes to heatsource, api, console
  • Loading branch information
MichaelDvP authored Jan 5, 2023
2 parents 74acf2f + c754d19 commit 8b2466d
Show file tree
Hide file tree
Showing 27 changed files with 923 additions and 530 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
- Factory Reset not working [#628](https://github.com/emsesp/EMS-ESP32/issues/628)
- Valid 4 byte values [#820](https://github.com/emsesp/EMS-ESP32/issues/820)
- Commands for multiple thermostats [#826](https://github.com/emsesp/EMS-ESP32/issues/826)
- API queries for multiple devices [#865](https://github.com/emsesp/EMS-ESP32/issues/865)
- Console crash when using call with command `hcx` only. [#841](https://github.com/emsesp/EMS-ESP32/issues/841)

## Changed

Expand All @@ -46,3 +48,4 @@
- analog/dallas HA-entities based on id
- MQTT Base is a mandatory field. Removed MQTT topic length from settings
- HA duration class for time entities [[#822](https://github.com/emsesp/EMS-ESP32/issues/822
- AM200 alternative heatsource as class heatsource [[#857](https://github.com/emsesp/EMS-ESP32/issues/857
2 changes: 1 addition & 1 deletion interface/src/i18n/pl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const pl: BaseTranslation = {
NUM_DEVICES: '{num} urządze{{ń|nie|nia|nia|ń}} EMS',
NUM_TEMP_SENSORS: '{num} czujni{{ków|k|ki|ki|ków}} temperatury',
NUM_ANALOG_SENSORS: '{num} inn{{ych|e|e|e|ych}} urządze{{ń|nie|nia(two)|nia|ń}} podłączon{{ych|e|e|e|ych}} do EMS-ESP',
NUM_DAYS: '{num} {{dni|dzień|dni|dni|dni}}',
NUM_DAYS: '{num} d{{ni|zień|ni|ni|ni}}',
NUM_SECONDS: '{num} sekun{{d|da|dy|dy|d}}',
NUM_HOURS: '{num} godzi{{n|na|ny|ny|n}}',
NUM_MINUTES: '{num} minu{{t|ta|ty|ty|t}}',
Expand Down
3 changes: 2 additions & 1 deletion interface/src/project/DashboardData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const DashboardData: FC = () => {
const [coreData, setCoreData] = useState<CoreData>({
connected: true,
devices: [],
s_n: '',
active_sensors: 0,
analog_enabled: false
});
Expand Down Expand Up @@ -721,7 +722,7 @@ const DashboardData: FC = () => {
<Cell>
<DeviceIcon type_id={1} />
</Cell>
<Cell>Sensors</Cell>
<Cell>{coreData.s_n}</Cell>
<Cell>{LL.ATTACHED_SENSORS()}</Cell>
<Cell>{coreData.active_sensors}</Cell>
<Cell>
Expand Down
1 change: 1 addition & 0 deletions interface/src/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface SensorData {
export interface CoreData {
connected: boolean;
devices: Device[];
s_n: string;
active_sensors: number;
analog_enabled: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/FSPersistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FSPersistence {
File settingsFile = _fs->open(_filePath, "w");

// failed to open file, return false
if (!settingsFile) {
if (!settingsFile || !jsonObject.size()) {
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_USE_SERIAL)
Serial.println();
Expand Down
29 changes: 20 additions & 9 deletions src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,9 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
command_p = parse_command_string(command_p, id_n);
if (command_p == nullptr) {
// handle dead endpoints like api/system or api/boiler
// default to 'info' for SYSTEM, DALLASENSOR and ANALOGSENSOR, the other devices to 'values' for shortname version
// default to 'info' for SYSTEM, the other devices to 'values' for shortname version
if (num_paths < (id_n > 0 ? 4 : 3)) {
if (device_type == EMSdevice::DeviceType::SYSTEM) {
command_p = F_(info);
} else {
command_p = F_(values);
}
command_p = device_type == EMSdevice::DeviceType::SYSTEM ? F_(info) : F_(values);
} else {
return message(CommandRet::NOT_FOUND, "missing or bad command", output);
}
Expand All @@ -135,9 +131,15 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
id_n = input["hc"];
} else if (input.containsKey("wwc")) {
id_n = input["wwc"];
id_n += 8; // wwc1 has id 9
id_n += DeviceValueTAG::TAG_WWC1 - DeviceValueTAG::TAG_HC1; // wwc1 has id 9
} else if (input.containsKey("id")) {
id_n = input["id"];
} else if (input.containsKey("ahs")) {
id_n = input["ahs"];
id_n += DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1; // ahs1 has id 19
} else if (input.containsKey("hs")) {
id_n = input["hs"];
id_n += DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1; // hs1 has id 20
}
}

Expand Down Expand Up @@ -208,17 +210,26 @@ const char * Command::parse_command_string(const char * command, int8_t & id) {
id = command[2] - '0';
command += 3;
} else if (!strncmp(lowerCmd, "wwc", 3) && command[3] == '1' && command[4] == '0') {
id = 19;
id = DeviceValueTAG::TAG_WWC10 - DeviceValueTAG::TAG_HC1 + 1; //18;
command += 5;
} else if (!strncmp(lowerCmd, "wwc", 3) && command[3] >= '1' && command[3] <= '9') {
id = command[3] - '0' + 8;
id = command[3] - '1' + DeviceValueTAG::TAG_WWC1 - DeviceValueTAG::TAG_HC1 + 1; //9;
command += 4;
} else if (!strncmp(lowerCmd, "id", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '9') {
id = command[3] - '0' + 10;
command += 4;
} else if (!strncmp(lowerCmd, "id", 2) && command[2] >= '1' && command[2] <= '9') {
id = command[2] - '0';
command += 3;
} else if (!strncmp(lowerCmd, "ahs", 3) && command[3] >= '1' && command[3] <= '1') { // only ahs1 for now
id = command[3] - '1' + DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1 + 1; // 19;
command += 4;
} else if (!strncmp(lowerCmd, "hs", 2) && command[2] == '1' && command[3] >= '0' && command[3] <= '6') {
id = command[3] - '0' + DeviceValueTAG::TAG_HS10 - DeviceValueTAG::TAG_HC1 + 1; //29;
command += 4;
} else if (!strncmp(lowerCmd, "hs", 2) && command[2] >= '1' && command[2] <= '9') {
id = command[2] - '1' + DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1 + 1; //20;
command += 3;
}
// remove separator
if (command[0] == '/' || command[0] == '.' || command[0] == '_') {
Expand Down
11 changes: 10 additions & 1 deletion src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,15 @@ void EMSESPShell::add_console_commands() {
uint8_t return_code = CommandRet::OK;
JsonObject json = doc.to<JsonObject>();

if (cmd == nullptr) {
cmd = device_type == EMSdevice::DeviceType::SYSTEM ? F_(info) : F_(values);
}

if (arguments.size() == 2) {
// no value specified, just the cmd
return_code = Command::call(device_type, cmd, nullptr, true, id, json);
} else if (arguments.size() == 3) {
if (strncmp(cmd, "info", 4) == 0) {
if (strncmp(cmd, F_(info), 4) == 0 || strncmp(cmd, F_(values), 6) == 0) {
// info has a id but no value
return_code = Command::call(device_type, cmd, nullptr, true, atoi(arguments.back().c_str()), json);
} else if (arguments[2] == "?") {
Expand All @@ -387,6 +391,11 @@ void EMSESPShell::add_console_commands() {
}

if (return_code == CommandRet::OK && json.size()) {
if (json.containsKey("api_data")) {
JsonVariant data = json["api_data"];
shell.println(data.as<String>());
return;
}
serializeJsonPretty(doc, shell);
shell.println();
return;
Expand Down
8 changes: 6 additions & 2 deletions src/device_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
{ 84, DeviceType::BOILER, "Logamax Plus GB022", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{ 95, DeviceType::BOILER, "Condens 2500/Logamax/Logomatic/Cerapur Top/Greenstar/Generic HT3", DeviceFlags::EMS_DEVICE_FLAG_HT3},
{115, DeviceType::BOILER, "Topline/GB162", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{121, DeviceType::BOILER, "Cascade MCM10", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{122, DeviceType::BOILER, "Proline", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{123, DeviceType::BOILER, "GBx72/Trendline/Cerapur/Greenstar Si/27i", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{131, DeviceType::BOILER, "GB212", DeviceFlags::EMS_DEVICE_FLAG_NONE},
Expand All @@ -47,7 +48,6 @@
{208, DeviceType::BOILER, "Logamax Plus/GB192/Condens GC9000/Greenstar ErP", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{210, DeviceType::BOILER, "Cascade MC400", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{211, DeviceType::BOILER, "EasyControl Adapter", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{228, DeviceType::BOILER, "Alternative Heatsource", DeviceFlags::EMS_DEVICE_FLAG_AM200},
{234, DeviceType::BOILER, "Logamax Plus GB122/Condense 2300", DeviceFlags::EMS_DEVICE_FLAG_NONE},

// Controllers - 0x09 / 0x10 / 0x50
Expand All @@ -57,6 +57,7 @@
{ 89, DeviceType::CONTROLLER, "BC10 GB142", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
{ 95, DeviceType::CONTROLLER, "HT3", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
{114, DeviceType::CONTROLLER, "BC10", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
{121, DeviceType::CONTROLLER, "MCM10", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{125, DeviceType::CONTROLLER, "BC25", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
{152, DeviceType::CONTROLLER, "Controller", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
{168, DeviceType::CONTROLLER, "Hybrid Heatpump", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
Expand Down Expand Up @@ -138,12 +139,15 @@
{193, DeviceType::MIXER, "MZ100", DeviceFlags::EMS_DEVICE_FLAG_MMPLUS},
{204, DeviceType::MIXER, "MP100", DeviceFlags::EMS_DEVICE_FLAG_MP}, // pool

// Heat Pumps - 0x38?
// Heat Pumps - 0x38? This is a thermostat like RC100H
{252, DeviceType::HEATPUMP, "HP Module", DeviceFlags::EMS_DEVICE_FLAG_NONE},

// Heat Pumps - 0x53
{248, DeviceType::HEATPUMP, "Hybrid Manager HM200", DeviceFlags::EMS_DEVICE_FLAG_NONE},

// Heatsource - 0x60
{228, DeviceType::HEATSOURCE, "AM200", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // alternative heatsource

// Connect devices - 0x02
{171, DeviceType::CONNECT, "OpenTherm Converter", DeviceFlags::EMS_DEVICE_FLAG_NONE},
{205, DeviceType::CONNECT, "Moduline Easy Connect", DeviceFlags::EMS_DEVICE_FLAG_NONE},
Expand Down
Loading

0 comments on commit 8b2466d

Please sign in to comment.