From 92a565151fb3196529839ad85077fb2cc9958193 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 6 Jun 2020 20:55:42 +0200 Subject: [PATCH] added ems gateway & switch. moved all code to devices folder --- src/{ => devices}/boiler.cpp | 0 src/{ => devices}/boiler.h | 0 src/devices/connect.cpp | 60 ++++++ src/devices/connect.h | 52 ++++++ src/{ => devices}/controller.cpp | 1 + src/{ => devices}/controller.h | 0 src/devices/gateway.cpp | 60 ++++++ src/devices/gateway.h | 52 ++++++ src/{ => devices}/heatpump.cpp | 1 + src/{ => devices}/heatpump.h | 0 src/{ => devices}/mixing.cpp | 1 + src/{ => devices}/mixing.h | 0 src/helpers.cpp | 307 ------------------------------- src/solar.cpp | 1 + src/switch.cpp | 60 ++++++ src/switch.h | 52 ++++++ src/thermostat.cpp | 5 +- 17 files changed, 343 insertions(+), 309 deletions(-) rename src/{ => devices}/boiler.cpp (100%) rename src/{ => devices}/boiler.h (100%) create mode 100644 src/devices/connect.cpp create mode 100644 src/devices/connect.h rename src/{ => devices}/controller.cpp (99%) rename src/{ => devices}/controller.h (100%) create mode 100644 src/devices/gateway.cpp create mode 100644 src/devices/gateway.h rename src/{ => devices}/heatpump.cpp (99%) rename src/{ => devices}/heatpump.h (100%) rename src/{ => devices}/mixing.cpp (99%) rename src/{ => devices}/mixing.h (100%) delete mode 100644 src/helpers.cpp create mode 100644 src/switch.cpp create mode 100644 src/switch.h diff --git a/src/boiler.cpp b/src/devices/boiler.cpp similarity index 100% rename from src/boiler.cpp rename to src/devices/boiler.cpp diff --git a/src/boiler.h b/src/devices/boiler.h similarity index 100% rename from src/boiler.h rename to src/devices/boiler.h diff --git a/src/devices/connect.cpp b/src/devices/connect.cpp new file mode 100644 index 000000000..fc796b991 --- /dev/null +++ b/src/devices/connect.cpp @@ -0,0 +1,60 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "connect.h" + +// MAKE_PSTR_WORD(connect) + +namespace emsesp { + +REGISTER_FACTORY(Connect, EMSdevice::DeviceType::CONNECT); + +MAKE_PSTR(logger_name, "connect") +uuid::log::Logger Connect::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; + +Connect::Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand) + : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { + // telegram handlers + // register_telegram_type(EMS_TYPE_XX, "XX", false, std::bind(&Controller::process_XX, this, _1)); + + // MQTT callbacks + // register_mqtt_topic("cmd", std::bind(&Controller::cmd, this, _1)); +} + +void Connect::add_context_menu() { +} + +// display all values into the shell console +void Connect::show_values(uuid::console::Shell & shell) { + EMSdevice::show_values(shell); // always call this to show header +} + +// publish values via MQTT +void Connect::publish_values() { +} + +// check to see if values have been updated +bool Connect::updated_values() { + return false; +} + +// add console commands +void Connect::console_commands() { +} + +} // namespace emsesp \ No newline at end of file diff --git a/src/devices/connect.h b/src/devices/connect.h new file mode 100644 index 000000000..62210ad35 --- /dev/null +++ b/src/devices/connect.h @@ -0,0 +1,52 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EMSESP_CONNECT_H +#define EMSESP_CONNECT_H + +#include +#include + +#include + +#include "emsdevice.h" +#include "telegram.h" +#include "emsesp.h" +#include "helpers.h" +#include "mqtt.h" + +namespace emsesp { + +class Connect : public EMSdevice { + public: + Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand); + + virtual void show_values(uuid::console::Shell & shell); + virtual void publish_values(); + virtual bool updated_values(); + virtual void add_context_menu(); + + private: + static uuid::log::Logger logger_; + + void console_commands(); +}; + +} // namespace emsesp + +#endif diff --git a/src/controller.cpp b/src/devices/controller.cpp similarity index 99% rename from src/controller.cpp rename to src/devices/controller.cpp index d1f8a38ec..37f4c0128 100644 --- a/src/controller.cpp +++ b/src/devices/controller.cpp @@ -23,6 +23,7 @@ namespace emsesp { REGISTER_FACTORY(Controller, EMSdevice::DeviceType::CONTROLLER); + MAKE_PSTR(logger_name, "controller") uuid::log::Logger Controller::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; diff --git a/src/controller.h b/src/devices/controller.h similarity index 100% rename from src/controller.h rename to src/devices/controller.h diff --git a/src/devices/gateway.cpp b/src/devices/gateway.cpp new file mode 100644 index 000000000..c752395c5 --- /dev/null +++ b/src/devices/gateway.cpp @@ -0,0 +1,60 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gateway.h" + +// MAKE_PSTR_WORD(gateway) + +namespace emsesp { + +REGISTER_FACTORY(Gateway, EMSdevice::DeviceType::GATEWAY); + +MAKE_PSTR(logger_name, "gateway") +uuid::log::Logger Gateway::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; + +Gateway::Gateway(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand) + : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { + // telegram handlers + // register_telegram_type(EMS_TYPE_XX, "XX", false, std::bind(&Controller::process_XX, this, _1)); + + // MQTT callbacks + // register_mqtt_topic("cmd", std::bind(&Controller::cmd, this, _1)); +} + +void Gateway::add_context_menu() { +} + +// display all values into the shell console +void Gateway::show_values(uuid::console::Shell & shell) { + EMSdevice::show_values(shell); // always call this to show header +} + +// publish values via MQTT +void Gateway::publish_values() { +} + +// check to see if values have been updated +bool Gateway::updated_values() { + return false; +} + +// add console commands +void Gateway::console_commands() { +} + +} // namespace emsesp \ No newline at end of file diff --git a/src/devices/gateway.h b/src/devices/gateway.h new file mode 100644 index 000000000..25ebb518d --- /dev/null +++ b/src/devices/gateway.h @@ -0,0 +1,52 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EMSESP_GATEWAY_H +#define EMSESP_GATEWAY_H + +#include +#include + +#include + +#include "emsdevice.h" +#include "telegram.h" +#include "emsesp.h" +#include "helpers.h" +#include "mqtt.h" + +namespace emsesp { + +class Gateway : public EMSdevice { + public: + Gateway(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand); + + virtual void show_values(uuid::console::Shell & shell); + virtual void publish_values(); + virtual bool updated_values(); + virtual void add_context_menu(); + + private: + static uuid::log::Logger logger_; + + void console_commands(); +}; + +} // namespace emsesp + +#endif diff --git a/src/heatpump.cpp b/src/devices/heatpump.cpp similarity index 99% rename from src/heatpump.cpp rename to src/devices/heatpump.cpp index 1c52442cc..aa5df273a 100644 --- a/src/heatpump.cpp +++ b/src/devices/heatpump.cpp @@ -30,6 +30,7 @@ namespace emsesp { REGISTER_FACTORY(Heatpump, EMSdevice::DeviceType::HEATPUMP); + MAKE_PSTR(logger_name, "heatpump") uuid::log::Logger Heatpump::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; diff --git a/src/heatpump.h b/src/devices/heatpump.h similarity index 100% rename from src/heatpump.h rename to src/devices/heatpump.h diff --git a/src/mixing.cpp b/src/devices/mixing.cpp similarity index 99% rename from src/mixing.cpp rename to src/devices/mixing.cpp index 2a94bc245..c6a97080a 100644 --- a/src/mixing.cpp +++ b/src/devices/mixing.cpp @@ -21,6 +21,7 @@ namespace emsesp { REGISTER_FACTORY(Mixing, EMSdevice::DeviceType::MIXING); + MAKE_PSTR(logger_name, "mixing") uuid::log::Logger Mixing::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; diff --git a/src/mixing.h b/src/devices/mixing.h similarity index 100% rename from src/mixing.h rename to src/devices/mixing.h diff --git a/src/helpers.cpp b/src/helpers.cpp deleted file mode 100644 index c0c176559..000000000 --- a/src/helpers.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* - * EMS-ESP - https://github.com/proddy/EMS-ESP - * Copyright 2019 Paul Derbyshire - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "helpers.h" -#include "telegram.h" // for EMS_VALUE_* settings - -namespace emsesp { - -// like itoa but for hex, and quicker -char * Helpers::hextoa(char * result, const uint8_t value) { - char * p = result; - uint8_t nib1 = (value >> 4) & 0x0F; - uint8_t nib2 = (value >> 0) & 0x0F; - *p++ = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA; - *p++ = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA; - *p = '\0'; // null terminate just in case - return result; -} - -/* - * itoa for 2 byte integers - * written by Lukás Chmela, Released under GPLv3. http://www.strudel.org.uk/itoa/ version 0.4 - */ -char * Helpers::itoa(char * result, int16_t value, const uint8_t base) { - // check that the base if valid - if (base < 2 || base > 36) { - *result = '\0'; - return result; - } - - char * ptr = result, *ptr1 = result, tmp_char; - int16_t tmp_value; - - do { - tmp_value = value; - value /= base; - *ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + (tmp_value - value * base)]; - } while (value); - - // Apply negative sign - if (tmp_value < 0) { - *ptr++ = '-'; - } - *ptr-- = '\0'; - while (ptr1 < ptr) { - tmp_char = *ptr; - *ptr-- = *ptr1; - *ptr1++ = tmp_char; - } - return result; -} - -// for decimals 0 to 99, printed as a 2 char string -char * Helpers::smallitoa(char * result, const uint8_t value) { - result[0] = ((value / 10) == 0) ? '0' : (value / 10) + '0'; - result[1] = (value % 10) + '0'; - result[2] = '\0'; - return result; -} - -// for decimals 0 to 999, printed as a string -char * Helpers::smallitoa(char * result, const uint16_t value) { - result[0] = ((value / 100) == 0) ? '0' : (value / 100) + '0'; - result[1] = (((value % 100) / 10) == 0) ? '0' : ((value % 100) / 10) + '0'; - result[2] = (value % 10) + '0'; - result[3] = '\0'; - return result; -} - -// convert unsigned int (single byte) to text value and returns it -// format: 2=divide by 2, 10=divide by 10, 255=handle as a Boolean -char * Helpers::render_value(char * result, uint8_t value, uint8_t format) { - result[0] = '\0'; - - // check if its a boolean - if (format == EMS_VALUE_BOOL) { - if (value == EMS_VALUE_BOOL_OFF) { - strlcpy(result, "off", 5); - } else if (value == EMS_VALUE_BOOL_NOTSET) { - strlcpy(result, "?", 5); - } else { - strlcpy(result, "on", 5); // assume on. could have value 0x01 or 0xFF - } - return result; - } - - if (value == EMS_VALUE_UINT_NOTSET) { - strlcpy(result, "?", 5); - return (result); - } - - static char s2[5] = {0}; - - switch (format) { - case 2: - strlcpy(result, itoa(s2, value >> 1, 10), 5); - strlcat(result, ".", 5); - strlcat(result, ((value & 0x01) ? "5" : "0"), 5); - break; - - case 10: - strlcpy(result, itoa(s2, value / 10, 10), 5); - strlcat(result, ".", 5); - strlcat(result, itoa(s2, value % 10, 10), 5); - break; - - default: - itoa(result, value, 10); - break; - } - - return result; -} - -// convert float to char -// format is the precision -char * Helpers::render_value(char * result, const float value, const uint8_t format) { - long p[] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000}; - - char * ret = result; - long whole = (long)value; - Helpers::itoa(result, whole, 10); - while (*result != '\0') { - result++; - } - *result++ = '.'; - long decimal = abs((long)((value - whole) * p[format])); - itoa(result, decimal, 10); - - return ret; -} - -// convert short (two bytes) to text string and returns string -// decimals: 0 = no division, 10=divide value by 10, 2=divide by 2, 100=divide value by 100 -// negative values are assumed stored as 1-compliment (https://medium.com/@LeeJulija/how-integers-are-stored-in-memory-using-twos-complement-5ba04d61a56c) -char * Helpers::render_value(char * result, const int16_t value, const uint8_t format) { - result[0] = '\0'; - - // remove errors or invalid values, 0x7D00 and higher - if ((value == EMS_VALUE_SHORT_NOTSET) || (value == EMS_VALUE_SHORT_INVALID) || (value == EMS_VALUE_USHORT_NOTSET)) { - strlcpy(result, "?", 10); - return result; - } - - // just print it if mo conversion required - if ((format == 0) || (format == 1)) { - itoa(result, value, 10); - return result; - } - - int16_t new_value = value; - - // check for negative values - if (new_value < 0) { - strlcpy(result, "-", 10); - new_value *= -1; // convert to positive - } else { - strlcpy(result, "", 10); - } - - // do floating point - char s2[10] = {0}; - if (format == 2) { - // divide by 2 - strlcat(result, itoa(s2, new_value / 2, 10), 10); - strlcat(result, ".", 10); - strlcat(result, ((new_value & 0x01) ? "5" : "0"), 10); - - } else { - strlcat(result, itoa(s2, new_value / format, 10), 10); - strlcat(result, ".", 10); - strlcat(result, itoa(s2, new_value % format, 10), 10); - } - - return result; -} - -// convert unsigned short (two bytes) to text string and prints it -// format: 0 = no division, 10=divide value by 10, 2=divide by 2, 100=divide value by 100 -char * Helpers::render_value(char * result, const uint16_t value, const uint8_t format) { - result[0] = '\0'; - - if ((value == EMS_VALUE_USHORT_NOTSET) || (value == EMS_VALUE_USHORT_INVALID)) { - strlcpy(result, "?", 10); - return result; - } - - return (render_value(result, (int16_t)value, format)); // use same code, force it to a signed int -} - -// convert signed byte to text string and prints it -// format: 0 = no division, 10=divide value by 10, 2=divide by 2, 100=divide value by 100 -char * Helpers::render_value(char * result, const int8_t value, const uint8_t format) { - result[0] = '\0'; - - if (value == EMS_VALUE_INT_NOTSET) { - strlcpy(result, "?", 10); - return result; - } - - return (render_value(result, (int16_t)value, format)); // use same code, force it to a signed int -} - -// render long (4 byte) unsigned values -// format = 0 for normal, any other value for divide by format -char * Helpers::render_value(char * result, const uint32_t value, const uint8_t format) { - result[0] = '\0'; - - if ((value == EMS_VALUE_ULONG_NOTSET) || (value == EMS_VALUE_ULONG_INVALID)) { - strlcpy(result, "?", 10); - return (result); - } - - static char s[20] = {0}; - -#ifndef EMSESP_STANDALONE - if (format <= 1) { - strlcat(result, ltoa(value, s, 10), 20); - } else { - strlcat(result, ltoa(value / format, s, 10), 20); - strlcat(result, ".", 2); - strlcat(result, ltoa(value % format, s, 10), 20); - } - -#else - strncat(result, itoa(s, value / format, 10), 20); -#endif - - return result; -} - -// creates string of hex values from an arrray of bytes -std::string Helpers::data_to_hex(const uint8_t * data, const uint8_t length) { - if (length == 0) { - return uuid::read_flash_string(F("")); - } - - std::string str(160, '\0'); - char buffer[4]; - char * p = &str[0]; - for (uint8_t i = 0; i < length; i++) { - Helpers::hextoa(buffer, data[i]); - *p++ = buffer[0]; - *p++ = buffer[1]; - *p++ = ' '; // space - } - *--p = '\0'; // null terminate just in case, loosing the trailing space - - return str; -} - - -// takes a hex string and convert it to an unsigned 32bit number (max 8 hex digits) -// works with only positive numbers -uint32_t Helpers::hextoint(const char * hex) { - uint32_t val = 0; - while (*hex) { - // get current character then increment - char byte = *hex++; - // transform hex character to the 4bit equivalent number, using the ascii table indexes - if (byte >= '0' && byte <= '9') - byte = byte - '0'; - else if (byte >= 'a' && byte <= 'f') - byte = byte - 'a' + 10; - else if (byte >= 'A' && byte <= 'F') - byte = byte - 'A' + 10; - else - return 0; // error - // shift 4 to make space for new digit, and add the 4 bits of the new digit - val = (val << 4) | (byte & 0xF); - } - return val; -} - -// quick char to long -uint16_t Helpers::atoint(const char * value) { - unsigned int x = 0; - while (*value != '\0') { - x = (x * 10) + (*value - '0'); - ++value; - } - return x; -} - -// rounds a number to 2 decimal places -// example: round2(3.14159) -> 3.14 -double Helpers::round2(double value) { - return (int)(value * 100 + 0.5) / 100.0; -} - - -} // namespace emsesp diff --git a/src/solar.cpp b/src/solar.cpp index 22c4add94..65a3b8af9 100644 --- a/src/solar.cpp +++ b/src/solar.cpp @@ -24,6 +24,7 @@ MAKE_PSTR(wh, "Wh") namespace emsesp { REGISTER_FACTORY(Solar, EMSdevice::DeviceType::SOLAR); + MAKE_PSTR(logger_name, "solar") uuid::log::Logger Solar::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; diff --git a/src/switch.cpp b/src/switch.cpp new file mode 100644 index 000000000..773b215d8 --- /dev/null +++ b/src/switch.cpp @@ -0,0 +1,60 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "switch.h" + +// MAKE_PSTR_WORD(switch) + +namespace emsesp { + +REGISTER_FACTORY(Switch, EMSdevice::DeviceType::SWITCH); + +MAKE_PSTR(logger_name, "switch") +uuid::log::Logger Switch::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; + +Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand) + : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { + // telegram handlers + // register_telegram_type(EMS_TYPE_XX, "XX", false, std::bind(&Controller::process_XX, this, _1)); + + // MQTT callbacks + // register_mqtt_topic("cmd", std::bind(&Controller::cmd, this, _1)); +} + +void Switch::add_context_menu() { +} + +// display all values into the shell console +void Switch::show_values(uuid::console::Shell & shell) { + EMSdevice::show_values(shell); // always call this to show header +} + +// publish values via MQTT +void Switch::publish_values() { +} + +// check to see if values have been updated +bool Switch::updated_values() { + return false; +} + +// add console commands +void Switch::console_commands() { +} + +} // namespace emsesp \ No newline at end of file diff --git a/src/switch.h b/src/switch.h new file mode 100644 index 000000000..618cbdac9 --- /dev/null +++ b/src/switch.h @@ -0,0 +1,52 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EMSESP_SWITCH_H +#define EMSESP_SWITCH_H + +#include +#include + +#include + +#include "emsdevice.h" +#include "telegram.h" +#include "emsesp.h" +#include "helpers.h" +#include "mqtt.h" + +namespace emsesp { + +class Switch : public EMSdevice { + public: + Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand); + + virtual void show_values(uuid::console::Shell & shell); + virtual void publish_values(); + virtual bool updated_values(); + virtual void add_context_menu(); + + private: + static uuid::log::Logger logger_; + + void console_commands(); +}; + +} // namespace emsesp + +#endif diff --git a/src/thermostat.cpp b/src/thermostat.cpp index f621bcec2..b5152bd50 100644 --- a/src/thermostat.cpp +++ b/src/thermostat.cpp @@ -31,6 +31,7 @@ MAKE_PSTR(master_thermostat_fmt, "Master Thermostat device ID = %s") namespace emsesp { REGISTER_FACTORY(Thermostat, EMSdevice::DeviceType::THERMOSTAT); + MAKE_PSTR(logger_name, "thermostat") uuid::log::Logger Thermostat::logger_{F_(logger_name), uuid::log::Facility::CONSOLE}; @@ -279,7 +280,7 @@ void Thermostat::thermostat_cmd(const char * message) { set_control(ctrl, hc_num); } if (float ct = doc["calinttemp"]) { - set_settings_calinttemp((int8_t)(ct *10)); + set_settings_calinttemp((int8_t)(ct * 10)); } if (nullptr != doc["minexttemp"]) { int8_t mt = doc["minexttemp"]; @@ -1187,7 +1188,7 @@ void Thermostat::set_settings_language(const uint8_t lg) { } // Set the control-mode for hc 0-off, 1-RC20, 2-RC3x -void Thermostat::set_control(const uint8_t ctrl,const uint8_t hc_num) { +void Thermostat::set_control(const uint8_t ctrl, const uint8_t hc_num) { std::shared_ptr hc = heating_circuit(hc_num); if (hc == nullptr) { LOG_WARNING(F("set control: Heating Circuit %d not found or activated"), hc_num);