minor updates

This commit is contained in:
proddy
2019-04-28 10:45:00 +02:00
parent aa6139a198
commit fac660bb98
6 changed files with 40 additions and 27 deletions

View File

@@ -18,11 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- nefit proline hrc 24 cw4 thermostat - nefit proline hrc 24 cw4 thermostat
- support for Buderus RC300 and RC310 thermostats [(issue 37)](https://github.com/proddy/EMS-ESP/issues/37) - support for Buderus RC300 and RC310 thermostats [(issue 37)](https://github.com/proddy/EMS-ESP/issues/37)
- added a test harness to try out response to various telegrams - added a test harness to try out response to various telegrams
- EMS_ID_GATEWAY for Buderus Web Gateway KM200
### Changed ### Changed
- `types` renamed to `devices` to also show all detected devices - `types` renamed to `devices` to also show all detected devices
- EMS Plus logic optimized - EMS Plus logic optimized
- `silent_mode` to `listen_mode`
## [1.6.0] 2019-03-24 ## [1.6.0] 2019-03-24

View File

@@ -77,7 +77,7 @@ typedef struct {
bool shower_timer; // true if we want to report back on shower times bool shower_timer; // true if we want to report back on shower times
bool shower_alert; // true if we want the alert of cold water bool shower_alert; // true if we want the alert of cold water
bool led; // LED on/off bool led; // LED on/off
bool silent_mode; // stop automatic Tx on/off bool listen_mode; // stop automatic Tx on/off
uint16_t publish_wait; // frequency of MQTT publish in seconds uint16_t publish_wait; // frequency of MQTT publish in seconds
uint8_t led_gpio; // pin for LED uint8_t led_gpio; // pin for LED
uint8_t dallas_gpio; // pin for attaching external dallas temperature sensors uint8_t dallas_gpio; // pin for attaching external dallas temperature sensors
@@ -101,7 +101,7 @@ command_t PROGMEM project_cmds[] = {
{true, "dallas_parasite <on | off>", "set to on if powering Dallas via parasite"}, {true, "dallas_parasite <on | off>", "set to on if powering Dallas via parasite"},
{true, "thermostat_type <device ID>", "set the thermostat type id (e.g. 10 for 0x10)"}, {true, "thermostat_type <device ID>", "set the thermostat type id (e.g. 10 for 0x10)"},
{true, "boiler_type <device ID>", "set the boiler type id (e.g. 8 for 0x08)"}, {true, "boiler_type <device ID>", "set the boiler type id (e.g. 8 for 0x08)"},
{true, "silent_mode <on | off>", "when on all automatic Tx is disabled"}, {true, "listen_mode <on | off>", "when on all automatic Tx is disabled"},
{true, "shower_timer <on | off>", "notify via MQTT all shower durations"}, {true, "shower_timer <on | off>", "notify via MQTT all shower durations"},
{true, "shower_alert <on | off>", "send a warning of cold water after shower time is exceeded"}, {true, "shower_alert <on | off>", "send a warning of cold water after shower time is exceeded"},
{true, "publish_wait <seconds>", "set frequency for publishing to MQTT"}, {true, "publish_wait <seconds>", "set frequency for publishing to MQTT"},
@@ -324,7 +324,7 @@ void showInfo() {
myDebug(" System logging set to None"); myDebug(" System logging set to None");
} }
myDebug(" LED is %s, Silent mode is %s", EMSESP_Status.led ? "on" : "off", EMSESP_Status.silent_mode ? "on" : "off"); myDebug(" LED is %s, Silent mode is %s", EMSESP_Status.led ? "on" : "off", EMSESP_Status.listen_mode ? "on" : "off");
if (EMSESP_Status.dallas_sensors > 0) { if (EMSESP_Status.dallas_sensors > 0) {
myDebug(" %d external temperature sensor%s found", EMSESP_Status.dallas_sensors, (EMSESP_Status.dallas_sensors == 1) ? "" : "s"); myDebug(" %d external temperature sensor%s found", EMSESP_Status.dallas_sensors, (EMSESP_Status.dallas_sensors == 1) ? "" : "s");
} }
@@ -936,6 +936,7 @@ void runUnitTest(uint8_t test_num) {
publishValuesTimer.detach(); publishValuesTimer.detach();
systemCheckTimer.detach(); systemCheckTimer.detach();
regularUpdatesTimer.detach(); regularUpdatesTimer.detach();
EMSESP_Status.listen_mode = true; // temporary go into listen mode to disable Tx
if (test_num >= 1 && test_num <= 10) { if (test_num >= 1 && test_num <= 10) {
ems_testTelegram(test_num); ems_testTelegram(test_num);
} }
@@ -973,8 +974,8 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
} }
// silent mode // silent mode
EMSESP_Status.silent_mode = json["silent_mode"]; EMSESP_Status.listen_mode = json["listen_mode"];
ems_setTxDisabled(EMSESP_Status.silent_mode); ems_setTxDisabled(EMSESP_Status.listen_mode);
// shower_timer // shower_timer
EMSESP_Status.shower_timer = json["shower_timer"]; EMSESP_Status.shower_timer = json["shower_timer"];
@@ -1006,7 +1007,7 @@ bool FSCallback(MYESP_FSACTION action, const JsonObject json) {
json["led_gpio"] = EMSESP_Status.led_gpio; json["led_gpio"] = EMSESP_Status.led_gpio;
json["dallas_gpio"] = EMSESP_Status.dallas_gpio; json["dallas_gpio"] = EMSESP_Status.dallas_gpio;
json["dallas_parasite"] = EMSESP_Status.dallas_parasite; json["dallas_parasite"] = EMSESP_Status.dallas_parasite;
json["silent_mode"] = EMSESP_Status.silent_mode; json["listen_mode"] = EMSESP_Status.listen_mode;
json["shower_timer"] = EMSESP_Status.shower_timer; json["shower_timer"] = EMSESP_Status.shower_timer;
json["shower_alert"] = EMSESP_Status.shower_alert; json["shower_alert"] = EMSESP_Status.shower_alert;
json["publish_wait"] = EMSESP_Status.publish_wait; json["publish_wait"] = EMSESP_Status.publish_wait;
@@ -1042,19 +1043,19 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
} }
// test mode // test mode
if ((strcmp(setting, "silent_mode") == 0) && (wc == 2)) { if ((strcmp(setting, "listen_mode") == 0) && (wc == 2)) {
if (strcmp(value, "on") == 0) { if (strcmp(value, "on") == 0) {
EMSESP_Status.silent_mode = true; EMSESP_Status.listen_mode = true;
ok = true; ok = true;
myDebug("* in Silent mode. All Tx is disabled."); myDebug("* in listen mode. All Tx is disabled.");
ems_setTxDisabled(true); ems_setTxDisabled(true);
} else if (strcmp(value, "off") == 0) { } else if (strcmp(value, "off") == 0) {
EMSESP_Status.silent_mode = false; EMSESP_Status.listen_mode = false;
ok = true; ok = true;
ems_setTxDisabled(false); ems_setTxDisabled(false);
myDebug("* out of Silent mode. Tx is enabled."); myDebug("* out of listen mode. Tx is enabled.");
} else { } else {
myDebug("Error. Usage: set silent_mode <on | off>"); myDebug("Error. Usage: set listen_mode <on | off>");
} }
} }
@@ -1176,7 +1177,7 @@ bool SettingsCallback(MYESP_FSACTION action, uint8_t wc, const char * setting, c
myDebug(" boiler_type=%02X", EMS_Boiler.device_id); myDebug(" boiler_type=%02X", EMS_Boiler.device_id);
} }
myDebug(" silent_mode=%s", EMSESP_Status.silent_mode ? "on" : "off"); myDebug(" listen_mode=%s", EMSESP_Status.listen_mode ? "on" : "off");
myDebug(" shower_timer=%s", EMSESP_Status.shower_timer ? "on" : "off"); myDebug(" shower_timer=%s", EMSESP_Status.shower_timer ? "on" : "off");
myDebug(" shower_alert=%s", EMSESP_Status.shower_alert ? "on" : "off"); myDebug(" shower_alert=%s", EMSESP_Status.shower_alert ? "on" : "off");
myDebug(" publish_wait=%d", EMSESP_Status.publish_wait); myDebug(" publish_wait=%d", EMSESP_Status.publish_wait);
@@ -1512,7 +1513,7 @@ void WIFICallback() {
} else { } else {
emsuart_init(); emsuart_init();
myDebug("[UART] Opened Rx/Tx connection"); myDebug("[UART] Opened Rx/Tx connection");
if (!EMSESP_Status.silent_mode) { if (!EMSESP_Status.listen_mode) {
// go and find the boiler and thermostat types, if not in silent mode // go and find the boiler and thermostat types, if not in silent mode
ems_discoverModels(); ems_discoverModels();
} }
@@ -1526,7 +1527,7 @@ void initEMSESP() {
EMSESP_Status.shower_timer = false; EMSESP_Status.shower_timer = false;
EMSESP_Status.shower_alert = false; EMSESP_Status.shower_alert = false;
EMSESP_Status.led = true; // LED is on by default EMSESP_Status.led = true; // LED is on by default
EMSESP_Status.silent_mode = false; EMSESP_Status.listen_mode = false;
EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT; EMSESP_Status.publish_wait = DEFAULT_PUBLISHWAIT;
EMSESP_Status.timestamp = millis(); EMSESP_Status.timestamp = millis();
EMSESP_Status.dallas_sensors = 0; EMSESP_Status.dallas_sensors = 0;
@@ -1643,7 +1644,7 @@ void setup() {
// at this point we have all the settings from our internall SPIFFS config file // at this point we have all the settings from our internall SPIFFS config file
// enable regular checks if not in test mode // enable regular checks if not in test mode
if (!EMSESP_Status.silent_mode) { if (!EMSESP_Status.listen_mode) {
publishValuesTimer.attach(EMSESP_Status.publish_wait, do_publishValues); // post MQTT EMS values publishValuesTimer.attach(EMSESP_Status.publish_wait, do_publishValues); // post MQTT EMS values
publishSensorValuesTimer.attach(EMSESP_Status.publish_wait, do_publishSensorValues); // post MQTT sensor values publishSensorValuesTimer.attach(EMSESP_Status.publish_wait, do_publishSensorValues); // post MQTT sensor values
regularUpdatesTimer.attach(REGULARUPDATES_TIME, do_regularUpdates); // regular reads from the EMS regularUpdatesTimer.attach(REGULARUPDATES_TIME, do_regularUpdates); // regular reads from the EMS
@@ -1677,7 +1678,7 @@ void loop() {
// publish the values to MQTT, only if the values have changed // publish the values to MQTT, only if the values have changed
// although we don't want to publish when doing a deep scan of the thermostat // although we don't want to publish when doing a deep scan of the thermostat
if (ems_getEmsRefreshed() && (scanThermostat_count == 0) && (!EMSESP_Status.silent_mode)) { if (ems_getEmsRefreshed() && (scanThermostat_count == 0) && (!EMSESP_Status.listen_mode)) {
publishValues(false); publishValues(false);
ems_setEmsRefreshed(false); // reset ems_setEmsRefreshed(false); // reset
} }

View File

@@ -617,7 +617,7 @@ void _createValidate() {
/* /*
* Entry point triggered by an interrupt in emsuart.cpp * Entry point triggered by an interrupt in emsuart.cpp
* length is size of all the data bytes with CRC, excluding the BRK at the end * length is size of all the telegram bytes including the CRC, excluding the BRK at the end
* Read commands are asynchronous as they're handled by the interrupt * Read commands are asynchronous as they're handled by the interrupt
* When a telegram is processed we forcefully erase it from the stack to prevent overflow * When a telegram is processed we forcefully erase it from the stack to prevent overflow
*/ */
@@ -633,7 +633,7 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
/** /**
* the main logic that parses the telegram message * the main logic that parses the telegram message
* When we receive a Poll Request we need to send any Tx packages quickly within a 200ms window * When we receive a Poll Request we need to send any Tx packages quickly within a 200ms window
* length is total number of bytes of the telegram excluding the CRC byte at the end * length is total number of bytes of the telegram including the CRC byte at the end if it exists
*/ */
void _ems_readTelegram(uint8_t * telegram, uint8_t length) { void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
// create the Rx package // create the Rx package
@@ -704,7 +704,11 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) {
EMS_RxTelegram.emsplus = true; EMS_RxTelegram.emsplus = true;
EMS_RxTelegram.type = (telegram[4] << 8) + telegram[5]; // is a long in bytes 5 & 6 EMS_RxTelegram.type = (telegram[4] << 8) + telegram[5]; // is a long in bytes 5 & 6
EMS_RxTelegram.data = telegram + 6; EMS_RxTelegram.data = telegram + 6;
EMS_RxTelegram.length = length - 8; // remove 5 bytes header plus CRC + length byte + 0x00 at end if (length <= 7) {
EMS_RxTelegram.length = 0; // special broadcast on ems+ have no data values
} else {
EMS_RxTelegram.length = length - 8; // remove 5 bytes header plus CRC + length byte + 0x00 at end
}
} else { } else {
EMS_RxTelegram.emsplus = false; EMS_RxTelegram.emsplus = false;
EMS_RxTelegram.type = telegram[2]; // 3rd byte EMS_RxTelegram.type = telegram[2]; // 3rd byte
@@ -763,6 +767,8 @@ void _printMessage(_EMS_RxTelegram * EMS_RxTelegram) {
strlcpy(output_str, "Thermostat", sizeof(output_str)); strlcpy(output_str, "Thermostat", sizeof(output_str));
} else if (src == EMS_ID_SM) { } else if (src == EMS_ID_SM) {
strlcpy(output_str, "SM", sizeof(output_str)); strlcpy(output_str, "SM", sizeof(output_str));
} else if (src == EMS_ID_GATEWAY) {
strlcpy(output_str, "Gateway", sizeof(output_str));
} else { } else {
strlcpy(output_str, "0x", sizeof(output_str)); strlcpy(output_str, "0x", sizeof(output_str));
strlcat(output_str, _hextoa(src, buffer), sizeof(output_str)); strlcat(output_str, _hextoa(src, buffer), sizeof(output_str));
@@ -2212,7 +2218,7 @@ void ems_testTelegram(uint8_t test_num) {
if (test_num == 0) if (test_num == 0)
return; return;
static const char tests[9][200] = { static const char tests[10][200] = {
"08 00 34 00 3E 02 1D 80 00 31 00 00 01 00 01 0B AE 02", // test 1 "08 00 34 00 3E 02 1D 80 00 31 00 00 01 00 01 0B AE 02", // test 1
"10 00 FF 00 01 A5 80 00 01 30 28 00 30 28 01 54 03 03 01 01 54 02 A8 00 00 11 01 03 FF FF 00", // test 2 - RC310 ems+ "10 00 FF 00 01 A5 80 00 01 30 28 00 30 28 01 54 03 03 01 01 54 02 A8 00 00 11 01 03 FF FF 00", // test 2 - RC310 ems+
@@ -2222,7 +2228,8 @@ void ems_testTelegram(uint8_t test_num) {
"18 00 FF 00 01 A5 00 DD 21 23 00 00 23 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00", // test 6 - RC300 "18 00 FF 00 01 A5 00 DD 21 23 00 00 23 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00", // test 6 - RC300
"90 00 FF 00 00 6F 01 01 00 46 00 B9", // test 7 - FR10 "90 00 FF 00 00 6F 01 01 00 46 00 B9", // test 7 - FR10
"30 00 FF 00 02 62 01 FB 01 9E 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 2B", // test 8 - SM100 "30 00 FF 00 02 62 01 FB 01 9E 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 2B", // test 8 - SM100
"30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0C 20 64 00 00 00 00 E9" // test 9 - SM100 "30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0C 20 64 00 00 00 00 E9", // test 9 - SM100
"30 09 FF 00 00 01" // test 10
}; };
@@ -2259,7 +2266,7 @@ void ems_testTelegram(uint8_t test_num) {
length++; // this is the total amount of bytes length++; // this is the total amount of bytes
telegram[length] = _crcCalculator(telegram, length + 1); // add the CRC telegram[length] = _crcCalculator(telegram, length + 1); // add the CRC
myDebug("[TEST %d] Injecting telegram %s (length %d)", test_num, tests[test_num - 1], length); myDebug("[TEST %d] Injecting telegram %s (data length %d)", test_num, tests[test_num - 1], length);
// go an parse it // go an parse it
_ems_readTelegram(telegram, length + 1); // include CRC in length _ems_readTelegram(telegram, length + 1); // include CRC in length

View File

@@ -17,7 +17,9 @@
#define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty device IDs #define EMS_PLUS_ID_NONE 0x01 // Fixed - used as a dest in broadcast messages and empty device 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_SM 0x30 // Solar Module SM10 and SM100 #define EMS_ID_SM 0x30 // Solar Module SM10 and SM100
#define EMS_ID_GATEWAY 0x48 // KM200 Web Gateway
#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

View File

@@ -158,7 +158,8 @@ const _Other_Type Other_Types[] = {
{EMS_MODEL_OTHER, 205, 0x02, "Nefit Moduline Easy Connect"}, {EMS_MODEL_OTHER, 205, 0x02, "Nefit Moduline Easy Connect"},
{EMS_MODEL_OTHER, 73, EMS_ID_SM, "SM10 Solar Module"}, {EMS_MODEL_OTHER, 73, EMS_ID_SM, "SM10 Solar Module"},
{EMS_MODEL_OTHER, 163, EMS_ID_SM, "SM100 Solar Module"}, {EMS_MODEL_OTHER, 163, EMS_ID_SM, "SM100 Solar Module"},
{EMS_MODEL_OTHER, 171, 0x02, "EMS-OT OpenTherm converter"} {EMS_MODEL_OTHER, 171, 0x02, "EMS-OT OpenTherm converter"},
{EMS_MODEL_OTHER, 252, EMS_ID_GATEWAY, "Web Gateway KM200"} // warning, fake product id!
}; };

View File

@@ -6,5 +6,5 @@
#pragma once #pragma once
#define APP_NAME "EMS-ESP" #define APP_NAME "EMS-ESP"
#define APP_VERSION "1.7.0b10" #define APP_VERSION "1.7.0b11"
#define APP_HOSTNAME "ems-esp" #define APP_HOSTNAME "ems-esp"