Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33 from SpaceTeddy/master
Browse files Browse the repository at this point in the history
RC35: MQTT day/night/auto mode; sets setpoint temperature in type 0x3D depends on current night/day Mode
  • Loading branch information
proddy authored Jan 12, 2019
2 parents 408fb9e + 5cda8a5 commit b51018c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/ems-esp.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* EMS-ESP
*
*
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
*
* See ChangeLog.md for history
Expand Down Expand Up @@ -782,8 +782,10 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
myDebug("MQTT topic: thermostat mode value %s", message);
if (strcmp((char *)message, "auto") == 0) {
ems_setThermostatMode(2);
} else if (strcmp((char *)message, "manual") == 0) {
} else if (strcmp((char *)message, "day") == 0) {
ems_setThermostatMode(1);
} else if (strcmp((char *)message, "night") == 0) {
ems_setThermostatMode(0);
}
}

Expand Down Expand Up @@ -912,7 +914,7 @@ void _showerColdShotStop() {
}
}

/*
/*
* Shower Logic
*/
void showerCheck() {
Expand Down
18 changes: 12 additions & 6 deletions src/ems.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* ems.cpp
*
*
* handles all the processing of the EMS messages
*
*
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
*/

Expand Down Expand Up @@ -50,7 +50,7 @@ void _process_RC35StatusMessage(uint8_t * data, uint8_t length);
// Easy
void _process_EasyStatusMessage(uint8_t * data, uint8_t length);

/*
/*
* Recognized EMS types and the functions they call to process the telegrams
*/
const _EMS_Type EMS_Types[] = {
Expand Down Expand Up @@ -165,6 +165,7 @@ void ems_init(uint8_t boiler_modelid, uint8_t thermostat_modelid) {
EMS_Thermostat.month = 0;
EMS_Thermostat.year = 0;
EMS_Thermostat.mode = 255; // dummy value
EMS_Thermostat.day_mode = 255; // dummy value

EMS_Thermostat.type_id = EMS_ID_NONE;
EMS_Thermostat.read_supported = false;
Expand Down Expand Up @@ -329,7 +330,7 @@ uint8_t _crcCalculator(uint8_t * data, uint8_t len) {
return crc;
}

/**
/**
* function to turn a telegram int (2 bytes) to a float. The source is *10
* negative values are stored as 1-compliment (https://medium.com/@LeeJulija/how-integers-are-stored-in-memory-using-twos-complement-5ba04d61a56c)
*/
Expand Down Expand Up @@ -974,7 +975,7 @@ void _process_RC30StatusMessage(uint8_t * data, uint8_t length) {
void _process_RC35StatusMessage(uint8_t * data, uint8_t length) {
EMS_Thermostat.setpoint_roomTemp = ((float)data[EMS_TYPE_RC35StatusMessage_setpoint]) / (float)2;
EMS_Thermostat.curr_roomTemp = _toFloat(EMS_TYPE_RC35StatusMessage_curr, data);

EMS_Thermostat.day_mode = bitRead(data[EMS_OFFSET_RC35Get_mode_day], 1); //get day mode flag
EMS_Sys_Status.emsRefreshed = true; // triggers a send the values back to Home Assistant via MQTT
}

Expand Down Expand Up @@ -1566,7 +1567,12 @@ void ems_setThermostatTemp(float temperature) {
EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC30StatusMessage;
} else if ((model_id == EMS_MODEL_RC35) || (model_id == EMS_MODEL_ES73)) {
EMS_TxTelegram.type = EMS_TYPE_RC35Set;
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_day; // day mode only for now
if (EMS_Thermostat.day_mode == 0){
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_night;
} else if (EMS_Thermostat.day_mode == 1){
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_day;
}

EMS_TxTelegram.comparisonPostRead = EMS_TYPE_RC35StatusMessage;
}

Expand Down
1 change: 1 addition & 0 deletions src/ems.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ typedef struct {
float setpoint_roomTemp; // current set temp
float curr_roomTemp; // current room temp
uint8_t mode; // 0=low, 1=manual, 2=auto
bool day_mode; // 0=night, 1=day
uint8_t hour;
uint8_t minute;
uint8_t second;
Expand Down
7 changes: 4 additions & 3 deletions src/ems_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "ems.h"

/*
/*
* Boiler...
*/
#define EMS_TYPE_UBAMonitorFast 0x18 // is an automatic monitor broadcast
Expand All @@ -27,7 +27,7 @@
#define EMS_VALUE_UBAParameterWW_wwComfort_Comfort 0x00 // the value for comfort
#define EMS_VALUE_UBAParameterWW_wwComfort_Eco 0xD8 // the value for eco

/*
/*
* Thermostat...
*/

Expand Down Expand Up @@ -59,6 +59,7 @@
#define EMS_OFFSET_RC35Set_mode 7 // position of thermostat mode
#define EMS_OFFSET_RC35Set_temp_day 2 // position of thermostat setpoint temperature for day time
#define EMS_OFFSET_RC35Set_temp_night 1 // position of thermostat setpoint temperature for night time
#define EMS_OFFSET_RC35Get_mode_day 1 // position of thermostat day mode

// Easy specific
#define EMS_TYPE_EasyStatusMessage 0x0A // reading values on an Easy Thermostat
Expand Down Expand Up @@ -117,7 +118,7 @@ const _Model_Type Model_Types[] = {
{EMS_MODEL_EASY, 202, 0x18, "TC100 (e.g. Nefit Easy or CT100)"}

};
/*
/*
* Known thermostat types and their abilities
*/
const _Thermostat_Type Thermostat_Types[] = {
Expand Down
4 changes: 2 additions & 2 deletions src/my_config.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* my_config.h
*
*
* All configurations and customization's go here
*
*
* Paul Derbyshire - https://github.com/proddy/EMS-ESP
*/

Expand Down

0 comments on commit b51018c

Please sign in to comment.