mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
autodetect deep optimizations
This commit is contained in:
@@ -57,7 +57,7 @@ uint8_t scanThermostat_count = 0;
|
|||||||
|
|
||||||
// ems bus scan
|
// ems bus scan
|
||||||
Ticker scanDevices;
|
Ticker scanDevices;
|
||||||
#define SCANDEVICES_TIME 1
|
#define SCANDEVICES_TIME 250 // ms
|
||||||
uint8_t scanDevices_count;
|
uint8_t scanDevices_count;
|
||||||
|
|
||||||
Ticker showerColdShotStopTimer;
|
Ticker showerColdShotStopTimer;
|
||||||
@@ -448,13 +448,13 @@ void showInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For SM10 Solar Module
|
// For SM10 Solar Module
|
||||||
if (EMS_Other.SM10) {
|
if (EMS_Other.SM) {
|
||||||
myDebug(""); // newline
|
myDebug(""); // newline
|
||||||
myDebug("%sSolar Module stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
|
myDebug("%sSolar Module stats:%s", COLOR_BOLD_ON, COLOR_BOLD_OFF);
|
||||||
_renderShortValue(" Collector temperature", "C", EMS_Other.SM10collectorTemp);
|
_renderShortValue(" Collector temperature", "C", EMS_Other.SMcollectorTemp);
|
||||||
_renderShortValue(" Bottom temperature", "C", EMS_Other.SM10bottomTemp);
|
_renderShortValue(" Bottom temperature", "C", EMS_Other.SMbottomTemp);
|
||||||
_renderIntValue(" Pump modulation", "%", EMS_Other.SM10pumpModulation);
|
_renderIntValue(" Pump modulation", "%", EMS_Other.SMpumpModulation);
|
||||||
_renderBoolValue(" Pump active", EMS_Other.SM10pump);
|
_renderBoolValue(" Pump active", EMS_Other.SMpump);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thermostat stats
|
// Thermostat stats
|
||||||
@@ -688,15 +688,15 @@ void publishValues(bool force) {
|
|||||||
|
|
||||||
// handle the other values separately
|
// handle the other values separately
|
||||||
// For SM10 Solar Module
|
// For SM10 Solar Module
|
||||||
if (EMS_Other.SM10) {
|
if (EMS_Other.SM) {
|
||||||
// build new json object
|
// build new json object
|
||||||
doc.clear();
|
doc.clear();
|
||||||
JsonObject rootSM10 = doc.to<JsonObject>();
|
JsonObject rootSM10 = doc.to<JsonObject>();
|
||||||
|
|
||||||
rootSM10[SM10_COLLECTORTEMP] = _short_to_char(s, EMS_Other.SM10collectorTemp);
|
rootSM10[SM10_COLLECTORTEMP] = _short_to_char(s, EMS_Other.SMcollectorTemp);
|
||||||
rootSM10[SM10_BOTTOMTEMP] = _short_to_char(s, EMS_Other.SM10bottomTemp);
|
rootSM10[SM10_BOTTOMTEMP] = _short_to_char(s, EMS_Other.SMbottomTemp);
|
||||||
rootSM10[SM10_PUMPMODULATION] = _int_to_char(s, EMS_Other.SM10pumpModulation);
|
rootSM10[SM10_PUMPMODULATION] = _int_to_char(s, EMS_Other.SMpumpModulation);
|
||||||
rootSM10[SM10_PUMP] = _bool_to_char(s, EMS_Other.SM10pump);
|
rootSM10[SM10_PUMP] = _bool_to_char(s, EMS_Other.SMpump);
|
||||||
|
|
||||||
data[0] = '\0'; // reset data for next package
|
data[0] = '\0'; // reset data for next package
|
||||||
serializeJson(doc, data, sizeof(data));
|
serializeJson(doc, data, sizeof(data));
|
||||||
@@ -833,14 +833,16 @@ void stopDeviceScan() {
|
|||||||
void do_scanDevices() {
|
void do_scanDevices() {
|
||||||
if (scanDevices_count == 0) {
|
if (scanDevices_count == 0) {
|
||||||
// we're at the finish line
|
// we're at the finish line
|
||||||
myDebug("Finished a deep EMS device scan. Type 'devices' to see what was discovered");
|
myDebug("Finished the deep EMS device scan.");
|
||||||
stopDeviceScan();
|
stopDeviceScan();
|
||||||
|
ems_printDevices();
|
||||||
|
ems_setLogging(EMS_SYS_LOGGING_NONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
|
if ((ems_getBusConnected()) && (!myESP.getUseSerial())) {
|
||||||
myDebug("> Scanning EMS bus for a device type 0x%02X...", scanDevices_count); // TODO: remove debug line
|
// myDebug("> Scanning EMS bus for a device type 0x%02X...", scanDevices_count);
|
||||||
ems_doReadCommand(EMS_TYPE_Version, scanDevices_count++); // ask for version
|
ems_doReadCommand(EMS_TYPE_Version, scanDevices_count++); // ask for version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,9 +852,10 @@ void startDeviceScan() {
|
|||||||
systemCheckTimer.detach();
|
systemCheckTimer.detach();
|
||||||
regularUpdatesTimer.detach();
|
regularUpdatesTimer.detach();
|
||||||
publishSensorValuesTimer.detach();
|
publishSensorValuesTimer.detach();
|
||||||
scanDevices_count = 1;
|
scanDevices_count = 1; // starts at 1
|
||||||
myDebug("Starting a deep EMS device scan...");
|
ems_setLogging(EMS_SYS_LOGGING_NONE);
|
||||||
scanThermostat.attach(SCANDEVICES_TIME, do_scanDevices);
|
myDebug("Starting a deep EMS device scan. This will take about 1 minute. Please wait...");
|
||||||
|
scanThermostat.attach_ms(SCANDEVICES_TIME, do_scanDevices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// initiate a force scan by sending type read requests from 0 to FF to the thermostat
|
// initiate a force scan by sending type read requests from 0 to FF to the thermostat
|
||||||
|
|||||||
50
src/ems.cpp
50
src/ems.cpp
@@ -264,10 +264,10 @@ void ems_init() {
|
|||||||
EMS_Boiler.pump_mod_min = EMS_VALUE_INT_NOTSET; // Boiler circuit pump modulation min. power
|
EMS_Boiler.pump_mod_min = EMS_VALUE_INT_NOTSET; // Boiler circuit pump modulation min. power
|
||||||
|
|
||||||
// Other EMS devices values
|
// Other EMS devices values
|
||||||
EMS_Other.SM10collectorTemp = EMS_VALUE_SHORT_NOTSET; // collector temp from SM10
|
EMS_Other.SMcollectorTemp = EMS_VALUE_SHORT_NOTSET; // collector temp from SM10/SM100
|
||||||
EMS_Other.SM10bottomTemp = EMS_VALUE_SHORT_NOTSET; // bottom temp from SM10
|
EMS_Other.SMbottomTemp = EMS_VALUE_SHORT_NOTSET; // bottom temp from SM10/SM100
|
||||||
EMS_Other.SM10pumpModulation = EMS_VALUE_INT_NOTSET; // modulation solar pump SM10
|
EMS_Other.SMpumpModulation = EMS_VALUE_INT_NOTSET; // modulation solar pump SM10/SM100
|
||||||
EMS_Other.SM10pump = EMS_VALUE_INT_NOTSET; // pump active
|
EMS_Other.SMpump = EMS_VALUE_INT_NOTSET; // pump active
|
||||||
|
|
||||||
// calculated values
|
// calculated values
|
||||||
EMS_Boiler.tapwaterActive = EMS_VALUE_INT_NOTSET; // Hot tap water is on/off
|
EMS_Boiler.tapwaterActive = EMS_VALUE_INT_NOTSET; // Hot tap water is on/off
|
||||||
@@ -283,7 +283,7 @@ void ems_init() {
|
|||||||
strlcpy(EMS_Thermostat.version, "?", sizeof(EMS_Thermostat.version));
|
strlcpy(EMS_Thermostat.version, "?", sizeof(EMS_Thermostat.version));
|
||||||
|
|
||||||
// set other types
|
// set other types
|
||||||
EMS_Other.SM10 = false;
|
EMS_Other.SM = false;
|
||||||
|
|
||||||
// default logging is none
|
// default logging is none
|
||||||
ems_setLogging(EMS_SYS_LOGGING_DEFAULT);
|
ems_setLogging(EMS_SYS_LOGGING_DEFAULT);
|
||||||
@@ -790,8 +790,8 @@ void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
strlcat(output_str, "Boiler", sizeof(output_str));
|
strlcat(output_str, "Boiler", sizeof(output_str));
|
||||||
strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
|
strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
|
||||||
}
|
}
|
||||||
} else if (dest == EMS_ID_SM10) {
|
} else if (dest == EMS_ID_SM) {
|
||||||
strlcat(output_str, "SM10", sizeof(output_str));
|
strlcat(output_str, "SM", sizeof(output_str));
|
||||||
strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
|
strlcpy(color_s, COLOR_MAGENTA, sizeof(color_s));
|
||||||
} else if (dest == EMS_Thermostat.type_id) {
|
} else if (dest == EMS_Thermostat.type_id) {
|
||||||
if (emsp) {
|
if (emsp) {
|
||||||
@@ -860,7 +860,7 @@ void _ems_processTelegram(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
// is it common type for everyone?
|
// is it common type for everyone?
|
||||||
// is it for us? So the src must match with either the boiler, thermostat or other devices
|
// is it for us? So the src must match with either the boiler, thermostat or other devices
|
||||||
if ((EMS_Types[i].model_id == EMS_MODEL_ALL)
|
if ((EMS_Types[i].model_id == EMS_MODEL_ALL)
|
||||||
|| ((src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id) || (src == EMS_ID_SM10))) {
|
|| ((src == EMS_Boiler.type_id) || (src == EMS_Thermostat.type_id) || (src == EMS_ID_SM))) {
|
||||||
typeFound = true;
|
typeFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1266,10 +1266,10 @@ void _process_RCOutdoorTempMessage(uint8_t src, uint8_t * data, uint8_t length)
|
|||||||
* SM10Monitor - type 0x97
|
* SM10Monitor - type 0x97
|
||||||
*/
|
*/
|
||||||
void _process_SM10Monitor(uint8_t src, uint8_t * data, uint8_t length) {
|
void _process_SM10Monitor(uint8_t src, uint8_t * data, uint8_t length) {
|
||||||
EMS_Other.SM10collectorTemp = _toShort(2); // collector temp from SM10, is *10
|
EMS_Other.SMcollectorTemp = _toShort(2); // collector temp from SM10/SM100, is *10
|
||||||
EMS_Other.SM10bottomTemp = _toShort(5); // bottom temp from SM10, is *10
|
EMS_Other.SMbottomTemp = _toShort(5); // bottom temp from SM10/SM100, is *10
|
||||||
EMS_Other.SM10pumpModulation = _toByte(4); // modulation solar pump
|
EMS_Other.SMpumpModulation = _toByte(4); // modulation solar pump
|
||||||
EMS_Other.SM10pump = _bitRead(7, 1); // active if bit 1 is set
|
EMS_Other.SMpump = _bitRead(7, 1); // active if bit 1 is set
|
||||||
|
|
||||||
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back via MQTT
|
||||||
}
|
}
|
||||||
@@ -1462,8 +1462,8 @@ void _process_Version(uint8_t src, uint8_t * data, uint8_t length) {
|
|||||||
_addDevice(product_id, Other_Types[i].type_id, version, Other_Types[i].model_string);
|
_addDevice(product_id, Other_Types[i].type_id, version, Other_Types[i].model_string);
|
||||||
|
|
||||||
// see if this is a Solar Module SM10
|
// see if this is a Solar Module SM10
|
||||||
if (Other_Types[i].type_id == EMS_ID_SM10) {
|
if (Other_Types[i].type_id == EMS_ID_SM) {
|
||||||
EMS_Other.SM10 = true; // we have detected a SM10
|
EMS_Other.SM = true; // we have detected a SM10
|
||||||
myDebug("SM10 Solar Module support enabled.");
|
myDebug("SM10 Solar Module support enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1489,7 +1489,7 @@ void ems_discoverModels() {
|
|||||||
ems_doReadCommand(EMS_TYPE_Version, EMS_Boiler.type_id); // get version details of boiler
|
ems_doReadCommand(EMS_TYPE_Version, EMS_Boiler.type_id); // get version details of boiler
|
||||||
|
|
||||||
// solar module
|
// solar module
|
||||||
ems_doReadCommand(EMS_TYPE_Version, EMS_ID_SM10); // check if there is Solar Module available
|
ems_doReadCommand(EMS_TYPE_Version, EMS_ID_SM); // check if there is Solar Module available
|
||||||
|
|
||||||
// thermostat
|
// thermostat
|
||||||
// if it hasn't been set, auto discover it
|
// if it hasn't been set, auto discover it
|
||||||
@@ -1607,8 +1607,8 @@ void ems_getBoilerValues() {
|
|||||||
* Get other values from EMS devices
|
* Get other values from EMS devices
|
||||||
*/
|
*/
|
||||||
void ems_getOtherValues() {
|
void ems_getOtherValues() {
|
||||||
if (EMS_Other.SM10) {
|
if (EMS_Other.SM) {
|
||||||
ems_doReadCommand(EMS_TYPE_SM10Monitor, EMS_ID_SM10); // fetch all from SM10Monitor, e.g. 0B B0 97 00 16
|
ems_doReadCommand(EMS_TYPE_SM10Monitor, EMS_ID_SM); // fetch all from SM10Monitor, e.g. 0B B0 97 00 16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1766,8 +1766,18 @@ void ems_printAllDevices() {
|
|||||||
(Thermostat_Types[i].write_supported) ? 'y' : 'n');
|
(Thermostat_Types[i].write_supported) ? 'y' : 'n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print out known devices
|
||||||
|
ems_printDevices();
|
||||||
|
|
||||||
|
myDebug(""); // newline
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print out contents of the device list that was captured
|
||||||
|
*/
|
||||||
|
void ems_printDevices() {
|
||||||
if (Devices.size() != 0) {
|
if (Devices.size() != 0) {
|
||||||
myDebug("\nThese %d EMS devices were detected on your system:", Devices.size());
|
myDebug("\nThese %d EMS devices were detected:", Devices.size());
|
||||||
for (std::list<_Generic_Type>::iterator it = Devices.begin(); it != Devices.end(); it++) {
|
for (std::list<_Generic_Type>::iterator it = Devices.begin(); it != Devices.end(); it++) {
|
||||||
myDebug(" %s%s%s (TypeID:0x%02X ProductID:%d Version:%s)",
|
myDebug(" %s%s%s (TypeID:0x%02X ProductID:%d Version:%s)",
|
||||||
COLOR_BOLD_ON,
|
COLOR_BOLD_ON,
|
||||||
@@ -1777,9 +1787,9 @@ void ems_printAllDevices() {
|
|||||||
(it)->product_id,
|
(it)->product_id,
|
||||||
(it)->version);
|
(it)->version);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
myDebug(""); // newline
|
myDebug("\nIf any are marked as 'unknown', please report as a GitHub issue so we can update the EMS devices database.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
13
src/ems.h
13
src/ems.h
@@ -17,7 +17,7 @@
|
|||||||
#define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty type IDs
|
#define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty type IDs
|
||||||
#define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as the "Service Key"
|
#define EMS_ID_ME 0x0B // Fixed - our device, hardcoded as the "Service Key"
|
||||||
#define EMS_ID_DEFAULT_BOILER 0x08
|
#define EMS_ID_DEFAULT_BOILER 0x08
|
||||||
#define EMS_ID_SM10 0x30 // Solar Module SM10
|
#define EMS_ID_SM 0x30 // Solar Module SM10 and SM100
|
||||||
|
|
||||||
#define EMS_MIN_TELEGRAM_LENGTH 6 // minimal length for a validation telegram, including CRC
|
#define EMS_MIN_TELEGRAM_LENGTH 6 // minimal length for a validation telegram, including CRC
|
||||||
|
|
||||||
@@ -235,11 +235,11 @@ typedef struct { // UBAParameterWW
|
|||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// SM10 Solar Module - SM10Monitor
|
// SM10 Solar Module - SM10Monitor
|
||||||
bool SM10; // set true if there is a SM10 available
|
bool SM; // set true if there is a SM10 available
|
||||||
int16_t SM10collectorTemp; // collector temp from SM10
|
int16_t SMcollectorTemp; // collector temp from SM10
|
||||||
int16_t SM10bottomTemp; // bottom temp from SM10
|
int16_t SMbottomTemp; // bottom temp from SM10
|
||||||
uint8_t SM10pumpModulation; // modulation solar pump
|
uint8_t SMpumpModulation; // modulation solar pump
|
||||||
uint8_t SM10pump; // pump active
|
uint8_t SMpump; // pump active
|
||||||
} _EMS_Other;
|
} _EMS_Other;
|
||||||
|
|
||||||
// Thermostat data
|
// Thermostat data
|
||||||
@@ -320,6 +320,7 @@ uint32_t ems_getPollFrequency();
|
|||||||
|
|
||||||
void ems_scanDevices();
|
void ems_scanDevices();
|
||||||
void ems_printAllDevices();
|
void ems_printAllDevices();
|
||||||
|
void ems_printDevices();
|
||||||
char * ems_getThermostatDescription(char * buffer);
|
char * ems_getThermostatDescription(char * buffer);
|
||||||
void ems_printTxQueue();
|
void ems_printTxQueue();
|
||||||
char * ems_getBoilerDescription(char * buffer);
|
char * ems_getBoilerDescription(char * buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user