mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
Merge remote-tracking branch 'origin/v2_web' into v2
This commit is contained in:
@@ -793,7 +793,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(wwtemp)},
|
||||
flash_string_vector{F_(wwtemp)},
|
||||
flash_string_vector{F_(degrees_mandatory)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
set_warmwater_temp(Helpers::atoint(arguments.front().c_str()));
|
||||
@@ -801,7 +801,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(flowtemp)},
|
||||
flash_string_vector{F_(flowtemp)},
|
||||
flash_string_vector{F_(degrees_mandatory)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
set_flow_temp(Helpers::atoint(arguments.front().c_str()));
|
||||
@@ -810,7 +810,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(wwactive)},
|
||||
flash_string_vector{F_(wwactive)},
|
||||
flash_string_vector{F_(bool_mandatory)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments[0] == read_flash_string(F_(on))) {
|
||||
@@ -829,7 +829,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(wwonetime)},
|
||||
flash_string_vector{F_(wwonetime)},
|
||||
flash_string_vector{F_(bool_mandatory)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments[0] == read_flash_string(F_(on))) {
|
||||
@@ -848,7 +848,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(wwcirculation)},
|
||||
flash_string_vector{F_(wwcirculation)},
|
||||
flash_string_vector{F_(bool_mandatory)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments[0] == read_flash_string(F_(on))) {
|
||||
@@ -867,7 +867,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(comfort)},
|
||||
flash_string_vector{F_(comfort)},
|
||||
flash_string_vector{F_(comfort_mandatory)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments[0] == read_flash_string(F_(hot))) {
|
||||
@@ -889,65 +889,6 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
flash_string_vector{F_(show)},
|
||||
[&](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) { show_values(shell); });
|
||||
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(set), F_(shower), F_(timer)},
|
||||
flash_string_vector{F_(bool_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
bool value;
|
||||
if (arguments[0] == read_flash_string(F_(on))) {
|
||||
value = true;
|
||||
} else if (arguments[0] == read_flash_string(F_(off))) {
|
||||
value = false;
|
||||
} else {
|
||||
shell.println(F("Must be on or off"));
|
||||
return;
|
||||
}
|
||||
Settings settings;
|
||||
settings.shower_timer(value);
|
||||
settings.commit();
|
||||
shell.printfln(F_(shower_timer_fmt), settings.shower_timer() ? uuid::read_flash_string(F_(on)).c_str() : uuid::read_flash_string(F_(off)).c_str());
|
||||
},
|
||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> {
|
||||
return std::vector<std::string>{read_flash_string(F_(on)), read_flash_string(F_(off))};
|
||||
});
|
||||
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::BOILER,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(set), F_(shower), F_(alert)},
|
||||
flash_string_vector{F_(bool_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
bool value;
|
||||
if (arguments[0] == read_flash_string(F_(on))) {
|
||||
value = true;
|
||||
} else if (arguments[0] == read_flash_string(F_(off))) {
|
||||
value = false;
|
||||
} else {
|
||||
shell.println(F("Must be on or off"));
|
||||
return;
|
||||
}
|
||||
Settings settings;
|
||||
settings.shower_alert(value);
|
||||
settings.commit();
|
||||
shell.printfln(F_(shower_timer_fmt), settings.shower_alert() ? uuid::read_flash_string(F_(on)).c_str() : uuid::read_flash_string(F_(off)).c_str());
|
||||
},
|
||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> {
|
||||
return std::vector<std::string>{read_flash_string(F_(on)), read_flash_string(F_(off))};
|
||||
});
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::BOILER,
|
||||
CommandFlags::USER,
|
||||
flash_string_vector{F_(set)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||
Settings settings;
|
||||
shell.printfln(F_(shower_timer_fmt), settings.shower_timer() ? F_(enabled) : F_(disabled));
|
||||
shell.printfln(F_(shower_alert_fmt), settings.shower_alert() ? F_(enabled) : F_(disabled));
|
||||
shell.println();
|
||||
});
|
||||
|
||||
|
||||
// enter the context
|
||||
Console::enter_custom_context(shell, context);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#include "connect.h"
|
||||
|
||||
// MAKE_PSTR_WORD(connect)
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
REGISTER_FACTORY(Connect, EMSdevice::DeviceType::CONNECT);
|
||||
@@ -33,7 +31,7 @@ Connect::Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, con
|
||||
// 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));
|
||||
// register_mqtt_topic("cmd", std::bind(&Connect::cmd, this, _1));
|
||||
}
|
||||
|
||||
void Connect::add_context_menu() {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ Gateway::Gateway(uint8_t device_type, uint8_t device_id, uint8_t product_id, con
|
||||
// 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));
|
||||
// register_mqtt_topic("cmd", std::bind(&Gateway::cmd, this, _1));
|
||||
}
|
||||
|
||||
void Gateway::add_context_menu() {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
|
||||
@@ -73,6 +73,9 @@ void Solar::show_values(uuid::console::Shell & shell) {
|
||||
shell.printfln(F(" Pump working time: %d days %d hours %d minutes"), pumpWorkMin_ / 1440, (pumpWorkMin_ % 1440) / 60, pumpWorkMin_ % 60);
|
||||
}
|
||||
|
||||
print_value(shell, 2, F("Tank Heated"), tankHeated_, nullptr, EMS_VALUE_BOOL);
|
||||
print_value(shell, 2, F("Collector"), collectorOnOff_, nullptr, EMS_VALUE_BOOL);
|
||||
|
||||
print_value(shell, 2, F("Energy last hour"), energyLastHour_, F_(wh), 10);
|
||||
print_value(shell, 2, F("Energy today"), energyToday_, F_(wh));
|
||||
print_value(shell, 2, F("Energy total"), energyTotal_, F_(kwh), 10);
|
||||
@@ -87,30 +90,47 @@ void Solar::publish_values() {
|
||||
if (Helpers::hasValue(collectorTemp_)) {
|
||||
doc["collectortemp"] = (float)collectorTemp_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(bottomTemp_)) {
|
||||
doc["bottomtemp"] = (float)bottomTemp_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(bottomTemp2_)) {
|
||||
doc["bottomtemp2"] = (float)bottomTemp2_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(pumpModulation_)) {
|
||||
doc["pumpmodulation"] = pumpModulation_;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(pump_, true)) {
|
||||
doc["pump"] = Helpers::render_value(s, pump_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(valveStatus_, true)) {
|
||||
doc["valvestatus"] = Helpers::render_value(s, valveStatus_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(pumpWorkMin_)) {
|
||||
doc["pumpWorkMin"] = (float)pumpWorkMin_;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(tankHeated_, true)) {
|
||||
doc["tankHeated"] = Helpers::render_value(s, tankHeated_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(collectorOnOff_, true)) {
|
||||
doc["collectorOnOff"] = Helpers::render_value(s, collectorOnOff_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(energyLastHour_)) {
|
||||
doc["energylasthour"] = (float)energyLastHour_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(energyToday_)) {
|
||||
doc["energytoday"] = energyToday_;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(energyTotal_)) {
|
||||
doc["energytotal"] = (float)energyTotal_ / 10;
|
||||
}
|
||||
@@ -186,6 +206,9 @@ void Solar::process_SM100Status(std::shared_ptr<const Telegram> telegram) {
|
||||
if (pumpmod == 0 && pumpModulation_ == 100) { // mask out boosts
|
||||
pumpModulation_ = 15; // set to minimum
|
||||
}
|
||||
|
||||
telegram->read_bitvalue(tankHeated_, 3, 1); // issue #422
|
||||
telegram->read_bitvalue(collectorOnOff_, 3, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -221,12 +244,11 @@ void Solar::process_ISM1StatusMessage(std::shared_ptr<const Telegram> telegram)
|
||||
if (Wh != 0xFFFF) {
|
||||
energyLastHour_ = Wh * 10; // set to *10
|
||||
}
|
||||
telegram->read_bitvalue(pump_, 8, 0); // Solar pump on (1) or off (0)
|
||||
telegram->read_value(pumpWorkMin_, 10, 3); // force to 3 bytes
|
||||
telegram->read_bitvalue(collectorOnOff_, 9, 0); // collector on/off
|
||||
telegram->read_bitvalue(tankHeated_, 9, 2); // tank full
|
||||
}
|
||||
|
||||
/*
|
||||
* Junkers ISM1 Solar Module - type 0x0101 EMS+ for setting values
|
||||
* e.g. 90 30 FF 06 00 01 50
|
||||
*/
|
||||
void Solar::process_ISM1Set(std::shared_ptr<const Telegram> telegram) {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
@@ -57,6 +56,8 @@ class Solar : public EMSdevice {
|
||||
uint32_t energyToday_ = EMS_VALUE_ULONG_NOTSET;
|
||||
uint32_t energyTotal_ = EMS_VALUE_ULONG_NOTSET;
|
||||
uint32_t pumpWorkMin_ = EMS_VALUE_ULONG_NOTSET; // Total solar pump operating time
|
||||
uint8_t tankHeated_ = EMS_VALUE_BOOL_NOTSET;
|
||||
uint8_t collectorOnOff_ = EMS_VALUE_BOOL_NOTSET;
|
||||
|
||||
uint8_t availabilityFlag_ = EMS_VALUE_BOOL_NOTSET;
|
||||
uint8_t configFlag_ = EMS_VALUE_BOOL_NOTSET;
|
||||
|
||||
@@ -33,7 +33,7 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const
|
||||
// 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));
|
||||
// register_mqtt_topic("cmd", std::bind(&Switch::cmd, this, _1));
|
||||
}
|
||||
|
||||
void Switch::add_context_menu() {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "emsdevice.h"
|
||||
#include "telegram.h"
|
||||
#include "emsesp.h"
|
||||
#include "helpers.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
|
||||
@@ -126,11 +126,17 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
|
||||
}
|
||||
}
|
||||
|
||||
Settings settings;
|
||||
uint8_t master_thermostat = settings.master_thermostat(); // what the user has defined
|
||||
uint8_t actual_master_thermostat = EMSESP::actual_master_thermostat(); // what we're actually using
|
||||
uint8_t num_devices = EMSESP::count_devices(EMSdevice::DeviceType::THERMOSTAT) + 1; // including this thermostat
|
||||
mqtt_format_ = settings.mqtt_format(); // single, nested or ha
|
||||
uint8_t master_thermostat = 0;
|
||||
EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) {
|
||||
master_thermostat = settings.master_thermostat; // what the user has defined
|
||||
});
|
||||
|
||||
EMSESP::esp8266React.getMqttSettingsService()->read([&](MqttSettings & settings) {
|
||||
mqtt_format_ = settings.mqtt_format; // single, nested or ha
|
||||
});
|
||||
|
||||
uint8_t actual_master_thermostat = EMSESP::actual_master_thermostat(); // what we're actually using
|
||||
uint8_t num_devices = EMSESP::count_devices(EMSdevice::DeviceType::THERMOSTAT) + 1; // including this thermostat
|
||||
|
||||
// if we're on auto mode, register this thermostat if it has a device id of 0x10 or 0x17
|
||||
// or if its the master thermostat we defined
|
||||
@@ -161,7 +167,7 @@ void Thermostat::init_mqtt() {
|
||||
|
||||
// if the MQTT format type is ha then send the config to HA (via the mqtt discovery service)
|
||||
// for each of the heating circuits
|
||||
if (mqtt_format_ == Settings::MQTT_format::HA) {
|
||||
if (mqtt_format_ == MQTT_format::HA) {
|
||||
for (uint8_t hc = 0; hc < monitor_typeids.size(); hc++) {
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
|
||||
@@ -304,7 +310,8 @@ void Thermostat::thermostat_cmd(const char * message) {
|
||||
std::string holiday = doc[hc_name]["holiday"];
|
||||
set_holiday(holiday.c_str(), hc_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != doc["wwmode"]) {
|
||||
std::string mode = doc["wwmode"];
|
||||
set_ww_mode(mode);
|
||||
@@ -502,7 +509,7 @@ void Thermostat::thermostat_cmd(const char * message) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace emsesp
|
||||
|
||||
void Thermostat::thermostat_cmd_temp(const char * message) {
|
||||
float f = strtof((char *)message, 0);
|
||||
@@ -559,8 +566,7 @@ void Thermostat::publish_values() {
|
||||
JsonObject dataThermostat;
|
||||
|
||||
// add external temp
|
||||
if ((flags == EMS_DEVICE_FLAG_RC35 || flags == EMS_DEVICE_FLAG_RC30_1)
|
||||
&& (mqtt_format_ == Settings::MQTT_format::SINGLE || mqtt_format_ == Settings::MQTT_format::CUSTOM)) {
|
||||
if ((flags == EMS_DEVICE_FLAG_RC35 || flags == EMS_DEVICE_FLAG_RC30_1) && (mqtt_format_ == MQTT_format::SINGLE || mqtt_format_ == MQTT_format::CUSTOM)) {
|
||||
if (datetime_.size()) {
|
||||
rootThermostat["time"] = datetime_.c_str();
|
||||
}
|
||||
@@ -597,7 +603,7 @@ void Thermostat::publish_values() {
|
||||
rootThermostat["wwmode"] = "auto";
|
||||
}
|
||||
}
|
||||
if (mqtt_format_ == Settings::MQTT_format::SINGLE) {
|
||||
if (mqtt_format_ == MQTT_format::SINGLE) {
|
||||
Mqtt::publish("thermostat_data", doc);
|
||||
rootThermostat = doc.to<JsonObject>(); // clear object
|
||||
}
|
||||
@@ -611,7 +617,7 @@ void Thermostat::publish_values() {
|
||||
|
||||
has_data = true;
|
||||
// if the MQTT format is 'nested' or 'ha' then create the parent object hc<n>
|
||||
if (mqtt_format_ != Settings::MQTT_format::SINGLE) {
|
||||
if (mqtt_format_ != MQTT_format::SINGLE) {
|
||||
// create nested json for each HC
|
||||
char hc_name[10]; // hc{1-4}
|
||||
strlcpy(hc_name, "hc", 10);
|
||||
@@ -674,10 +680,10 @@ void Thermostat::publish_values() {
|
||||
}
|
||||
|
||||
// when using HA always send the mode otherwise it'll break the component/widget and report an error
|
||||
if ((Helpers::hasValue(hc->mode)) || (mqtt_format_ == Settings::MQTT_format::HA)) {
|
||||
if ((Helpers::hasValue(hc->mode)) || (mqtt_format_ == MQTT_format::HA)) {
|
||||
uint8_t hc_mode = hc->get_mode(flags);
|
||||
// if we're sending to HA the only valid mode types are heat, auto and off
|
||||
if (mqtt_format_ == Settings::MQTT_format::HA) {
|
||||
if (mqtt_format_ == MQTT_format::HA) {
|
||||
if ((hc_mode == HeatingCircuit::Mode::MANUAL) || (hc_mode == HeatingCircuit::Mode::DAY)) {
|
||||
hc_mode = HeatingCircuit::Mode::HEAT;
|
||||
} else if ((hc_mode == HeatingCircuit::Mode::NIGHT) || (hc_mode == HeatingCircuit::Mode::OFF)) {
|
||||
@@ -700,7 +706,7 @@ void Thermostat::publish_values() {
|
||||
}
|
||||
|
||||
// if format is single, send immediately and clear object for next hc
|
||||
if (mqtt_format_ == Settings::MQTT_format::SINGLE) {
|
||||
if (mqtt_format_ == MQTT_format::SINGLE) {
|
||||
char topic[30];
|
||||
char s[3]; // for formatting strings
|
||||
strlcpy(topic, "thermostat_data", 30);
|
||||
@@ -715,11 +721,11 @@ void Thermostat::publish_values() {
|
||||
}
|
||||
|
||||
// if we're using nested json, send all in one go
|
||||
if (mqtt_format_ == Settings::MQTT_format::NESTED) {
|
||||
if (mqtt_format_ == MQTT_format::NESTED) {
|
||||
Mqtt::publish("thermostat_data", doc);
|
||||
} else if (mqtt_format_ == Settings::MQTT_format::HA) {
|
||||
} else if (mqtt_format_ == MQTT_format::HA) {
|
||||
Mqtt::publish("homeassistant/climate/ems-esp/state", doc);
|
||||
} else if (mqtt_format_ == Settings::MQTT_format::CUSTOM) {
|
||||
} else if (mqtt_format_ == MQTT_format::CUSTOM) {
|
||||
Mqtt::publish("thermostat_data", doc);
|
||||
}
|
||||
}
|
||||
@@ -727,7 +733,6 @@ void Thermostat::publish_values() {
|
||||
// returns the heating circuit object based on the hc number
|
||||
// of nullptr if it doesn't exist yet
|
||||
std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(const uint8_t hc_num) {
|
||||
// uint8_t hc = (hc_num) ? hc_num : DEFAULT_HEATING_CIRCUIT;
|
||||
if (hc_num == 0) {
|
||||
// return first existing hc
|
||||
for (const auto & heating_circuit : heating_circuits_) {
|
||||
@@ -1454,16 +1459,16 @@ void Thermostat::set_party(const uint8_t hrs, const uint8_t hc_num) {
|
||||
|
||||
// set date&time as string hh:mm:ss-dd.mm.yyyy-dw-dst
|
||||
// dw - day of week (0..6), dst- summertime (0/1)
|
||||
void Thermostat::set_datetime(const char * dt) {
|
||||
void Thermostat::set_datetime(const char * dt) {
|
||||
uint8_t data[9];
|
||||
data[0] = (dt[16] - '0') * 100 + (dt[17] - '0') * 10 + (dt[18] - '0'); // year
|
||||
data[1] = (dt[12] - '0') * 10 + (dt[13] - '0'); // month
|
||||
data[2] = (dt[0] - '0') * 10 + (dt[1] - '0'); // hour
|
||||
data[3] = (dt[9] - '0') * 10 + (dt[10] - '0'); // day
|
||||
data[4] = (dt[3] - '0') * 10 + (dt[4] - '0'); // min
|
||||
data[5] = (dt[6] - '0') * 10 + (dt[7] - '0'); // sec
|
||||
data[6] = (dt[20] - '0'); // day of week
|
||||
data[7] = (dt[22] - '0'); // summerime
|
||||
data[1] = (dt[12] - '0') * 10 + (dt[13] - '0'); // month
|
||||
data[2] = (dt[0] - '0') * 10 + (dt[1] - '0'); // hour
|
||||
data[3] = (dt[9] - '0') * 10 + (dt[10] - '0'); // day
|
||||
data[4] = (dt[3] - '0') * 10 + (dt[4] - '0'); // min
|
||||
data[5] = (dt[6] - '0') * 10 + (dt[7] - '0'); // sec
|
||||
data[6] = (dt[20] - '0'); // day of week
|
||||
data[7] = (dt[22] - '0'); // summerime
|
||||
if ((flags() & 0x0F) == EMS_DEVICE_FLAG_RC35 || (flags() & 0x0F) == EMS_DEVICE_FLAG_RC30_1) {
|
||||
LOG_INFO(F("Setting date and time"));
|
||||
write_command(6, 0, data, 8, 0);
|
||||
@@ -1490,8 +1495,8 @@ void Thermostat::set_mode(const std::string & mode, const uint8_t hc_num) {
|
||||
set_mode(HeatingCircuit::Mode::NOFROST, hc_num);
|
||||
} else if (mode_tostring(HeatingCircuit::Mode::ECO) == mode) {
|
||||
set_mode(HeatingCircuit::Mode::ECO, hc_num);
|
||||
// } else if (mode_tostring(HeatingCircuit::Mode::HOLIDAY) == mode) {
|
||||
// set_mode(HeatingCircuit::Mode::HOLIDAY, hc_num);
|
||||
} else if (mode_tostring(HeatingCircuit::Mode::HOLIDAY) == mode) {
|
||||
set_mode(HeatingCircuit::Mode::HOLIDAY, hc_num);
|
||||
} else if (mode_tostring(HeatingCircuit::Mode::COMFORT) == mode) {
|
||||
set_mode(HeatingCircuit::Mode::COMFORT, hc_num);
|
||||
} else {
|
||||
@@ -1509,7 +1514,7 @@ void Thermostat::set_mode(const uint8_t mode, const uint8_t hc_num) {
|
||||
// get hc based on number
|
||||
std::shared_ptr<Thermostat::HeatingCircuit> hc = heating_circuit(hc_num);
|
||||
if (hc == nullptr) {
|
||||
LOG_WARNING(F("Set mode: Heating Circuit %d not found or activated"), hc_num);
|
||||
LOG_WARNING(F("set mode: Heating Circuit %d not found or activated"), hc_num);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1593,7 +1598,7 @@ void Thermostat::set_mode(const uint8_t mode, const uint8_t hc_num) {
|
||||
|
||||
// add the write command to the Tx queue
|
||||
// post validate is the corresponding monitor or set type IDs as they can differ per model
|
||||
write_command(set_typeids[hc_p], offset, set_mode_value, validate_typeid);
|
||||
write_command(set_typeids[hc->hc_num() - 1], offset, set_mode_value, validate_typeid);
|
||||
}
|
||||
|
||||
// sets the thermostat temp, where mode is a string
|
||||
@@ -1641,7 +1646,7 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
|
||||
uint8_t model = flags() & 0x0F;
|
||||
int8_t offset = -1; // we use -1 to check if there is a value
|
||||
uint8_t factor = 2; // some temperatures only use 1
|
||||
uint8_t factor = 2; // some temperatures only use 1
|
||||
uint16_t validate_typeid = monitor_typeids[hc->hc_num() - 1];
|
||||
|
||||
if (model == EMS_DEVICE_FLAG_RC10) {
|
||||
@@ -1771,6 +1776,7 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
mode_tostring(mode).c_str());
|
||||
|
||||
// add the write command to the Tx queue
|
||||
// value is *2
|
||||
// post validate is the corresponding monitor or set type IDs as they can differ per model
|
||||
write_command(set_typeids[hc->hc_num() - 1], offset, (uint8_t)((float)temperature * (float)factor), validate_typeid);
|
||||
}
|
||||
@@ -1789,14 +1795,17 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
||||
} else {
|
||||
value = Helpers::hextoint(arguments.front().c_str());
|
||||
}
|
||||
Settings settings;
|
||||
settings.master_thermostat(value);
|
||||
settings.commit();
|
||||
EMSESP::actual_master_thermostat(value); // set the internal value too
|
||||
char buffer[5];
|
||||
shell.printfln(F_(master_thermostat_fmt),
|
||||
settings.master_thermostat() == 0 ? uuid::read_flash_string(F_(auto)).c_str()
|
||||
: Helpers::hextoa(buffer, settings.master_thermostat()));
|
||||
|
||||
EMSESP::emsespSettingsService.update(
|
||||
[&](EMSESPSettings & settings) {
|
||||
settings.master_thermostat = value;
|
||||
EMSESP::actual_master_thermostat(value); // set the internal value too
|
||||
char buffer[5];
|
||||
shell.printfln(F_(master_thermostat_fmt),
|
||||
!value ? uuid::read_flash_string(F_(auto)).c_str() : Helpers::hextoa(buffer, value));
|
||||
return StateUpdateResult::CHANGED;
|
||||
},
|
||||
"local");
|
||||
});
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::THERMOSTAT,
|
||||
@@ -1810,7 +1819,7 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::THERMOSTAT,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(temp)},
|
||||
flash_string_vector{F_(temp)},
|
||||
flash_string_vector{F_(degrees_mandatory), F_(hc_optional), F_(mode_optional)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
uint8_t hc = (arguments.size() >= 2) ? arguments[1].at(0) - '0' : AUTO_HEATING_CIRCUIT;
|
||||
@@ -1826,7 +1835,7 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::THERMOSTAT,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(mode)},
|
||||
flash_string_vector{F_(mode)},
|
||||
flash_string_vector{F_(mode_mandatory), F_(hc_optional)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
uint8_t hc = (arguments.size() == 2) ? arguments[1].at(0) - '0' : AUTO_HEATING_CIRCUIT;
|
||||
@@ -1850,12 +1859,11 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
||||
EMSESPShell::commands->add_command(
|
||||
ShellContext::THERMOSTAT,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(change), F_(wwmode)},
|
||||
flash_string_vector{F_(wwmode)},
|
||||
flash_string_vector{F_(mode_mandatory)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) { set_ww_mode(arguments.front()); },
|
||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> {
|
||||
return std::vector<std::string>{read_flash_string(F("off")), read_flash_string(F("on")), read_flash_string(F("auto"))
|
||||
};
|
||||
return std::vector<std::string>{read_flash_string(F("off")), read_flash_string(F("on")), read_flash_string(F("auto"))};
|
||||
});
|
||||
|
||||
EMSESPShell::commands->add_command(ShellContext::THERMOSTAT,
|
||||
@@ -1867,12 +1875,13 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
||||
CommandFlags::USER,
|
||||
flash_string_vector{F_(set)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||
Settings settings;
|
||||
char buffer[4];
|
||||
shell.printfln(F_(master_thermostat_fmt),
|
||||
settings.master_thermostat() == 0 ? uuid::read_flash_string(F_(auto)).c_str()
|
||||
: Helpers::hextoa(buffer, settings.master_thermostat()));
|
||||
shell.println();
|
||||
EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) {
|
||||
char buffer[4];
|
||||
shell.printfln(F_(master_thermostat_fmt),
|
||||
settings.master_thermostat == 0 ? uuid::read_flash_string(F_(auto)).c_str()
|
||||
: Helpers::hextoa(buffer, settings.master_thermostat));
|
||||
shell.println();
|
||||
});
|
||||
});
|
||||
|
||||
// enter the context
|
||||
|
||||
@@ -63,7 +63,7 @@ class Thermostat : public EMSdevice {
|
||||
int8_t offsettemp = EMS_VALUE_INT_NOTSET; // heatingcurve offest temp at roomtemp signed!
|
||||
|
||||
uint8_t hc_num() const {
|
||||
return hc_num_;
|
||||
return hc_num_; // 1..10
|
||||
}
|
||||
|
||||
uint8_t get_mode(uint8_t flags) const;
|
||||
@@ -85,7 +85,7 @@ class Thermostat : public EMSdevice {
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t hc_num_;
|
||||
uint8_t hc_num_; // 1..10
|
||||
uint16_t monitor_typeid_;
|
||||
uint16_t set_typeid_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user