mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
This commit is contained in:
123
src/ems-esp.cpp
123
src/ems-esp.cpp
@@ -371,6 +371,38 @@ void _renderBoolValue(const char * prefix, uint8_t value) {
|
|||||||
myDebug(buffer);
|
myDebug(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// figures out the thermostat mode
|
||||||
|
// returns 0xFF=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day
|
||||||
|
uint8_t _getThermostatMode() {
|
||||||
|
int thermoMode = EMS_VALUE_INT_NOTSET;
|
||||||
|
|
||||||
|
if (ems_getThermostatModel() == EMS_MODEL_RC20) {
|
||||||
|
if (EMS_Thermostat.mode == 0) {
|
||||||
|
thermoMode = 0; // low
|
||||||
|
} else if (EMS_Thermostat.mode == 1) {
|
||||||
|
thermoMode = 1; // manual
|
||||||
|
} else if (EMS_Thermostat.mode == 2) {
|
||||||
|
thermoMode = 2; // auto
|
||||||
|
}
|
||||||
|
} else if (ems_getThermostatModel() == EMS_MODEL_RC300) {
|
||||||
|
if (EMS_Thermostat.mode == 0) {
|
||||||
|
thermoMode = 1; // manual
|
||||||
|
} else if (EMS_Thermostat.mode == 1) {
|
||||||
|
thermoMode = 2; // auto
|
||||||
|
}
|
||||||
|
} else { // default for all thermostats
|
||||||
|
if (EMS_Thermostat.mode == 0) {
|
||||||
|
thermoMode = 3; // night
|
||||||
|
} else if (EMS_Thermostat.mode == 1) {
|
||||||
|
thermoMode = 4; // day
|
||||||
|
} else if (EMS_Thermostat.mode == 2) {
|
||||||
|
thermoMode = 2; // auto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thermoMode;
|
||||||
|
}
|
||||||
|
|
||||||
// Show command - display stats on an 's' command
|
// Show command - display stats on an 's' command
|
||||||
void showInfo() {
|
void showInfo() {
|
||||||
// General stats from EMS bus
|
// General stats from EMS bus
|
||||||
@@ -550,7 +582,7 @@ void showInfo() {
|
|||||||
myDebug_P(PSTR(" Thermostat: %s"), ems_getThermostatDescription(buffer_type));
|
myDebug_P(PSTR(" Thermostat: %s"), ems_getThermostatDescription(buffer_type));
|
||||||
|
|
||||||
// Render Current & Setpoint Room Temperature
|
// Render Current & Setpoint Room Temperature
|
||||||
if ((ems_getThermostatModel() == EMS_MODEL_EASY)) {
|
if (ems_getThermostatModel() == EMS_MODEL_EASY) {
|
||||||
// Temperatures are *100
|
// Temperatures are *100
|
||||||
_renderShortValue("Set room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 10); // *100
|
_renderShortValue("Set room temperature", "C", EMS_Thermostat.setpoint_roomTemp, 10); // *100
|
||||||
_renderShortValue("Current room temperature", "C", EMS_Thermostat.curr_roomTemp, 10); // *100
|
_renderShortValue("Current room temperature", "C", EMS_Thermostat.curr_roomTemp, 10); // *100
|
||||||
@@ -572,42 +604,20 @@ void showInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render Thermostat Date & Time
|
// Render Thermostat Date & Time
|
||||||
myDebug_P(PSTR(" Thermostat time is %02d:%02d:%02d %d/%d/%d"),
|
// not for EASY
|
||||||
EMS_Thermostat.hour,
|
if ((ems_getThermostatModel() != EMS_MODEL_EASY)) {
|
||||||
EMS_Thermostat.minute,
|
myDebug_P(PSTR(" Thermostat time is %02d:%02d:%02d %d/%d/%d"),
|
||||||
EMS_Thermostat.second,
|
EMS_Thermostat.hour,
|
||||||
EMS_Thermostat.day,
|
EMS_Thermostat.minute,
|
||||||
EMS_Thermostat.month,
|
EMS_Thermostat.second,
|
||||||
EMS_Thermostat.year + 2000);
|
EMS_Thermostat.day,
|
||||||
|
EMS_Thermostat.month,
|
||||||
// thermostat mode (-1=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day)
|
EMS_Thermostat.year + 2000);
|
||||||
int thermoMode = -1;
|
|
||||||
|
|
||||||
if (ems_getThermostatModel() == EMS_MODEL_RC20) {
|
|
||||||
if (EMS_Thermostat.mode == 0) {
|
|
||||||
thermoMode = 0; // low
|
|
||||||
} else if (EMS_Thermostat.mode == 1) {
|
|
||||||
thermoMode = 1; // manual
|
|
||||||
} else {
|
|
||||||
thermoMode = 2; // auto
|
|
||||||
}
|
|
||||||
} else if (ems_getThermostatModel() == EMS_MODEL_RC300) {
|
|
||||||
if (EMS_Thermostat.mode == 0) {
|
|
||||||
thermoMode = 1; // manual
|
|
||||||
} else if (EMS_Thermostat.mode == 1) {
|
|
||||||
thermoMode = 2; // auto
|
|
||||||
}
|
|
||||||
} else { // default for all thermostats
|
|
||||||
if (EMS_Thermostat.mode == 0) {
|
|
||||||
thermoMode = 3; // night
|
|
||||||
} else if (EMS_Thermostat.mode == 1) {
|
|
||||||
thermoMode = 4; // day
|
|
||||||
} else {
|
|
||||||
thermoMode = 2; // auto
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render Termostat Mode
|
// Render Termostat Mode, if we have a mode
|
||||||
|
uint8_t thermoMode = _getThermostatMode(); // 0xFF=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day
|
||||||
|
|
||||||
if (thermoMode == 0) {
|
if (thermoMode == 0) {
|
||||||
myDebug_P(PSTR(" Mode is set to low"));
|
myDebug_P(PSTR(" Mode is set to low"));
|
||||||
} else if (thermoMode == 1) {
|
} else if (thermoMode == 1) {
|
||||||
@@ -618,8 +628,6 @@ void showInfo() {
|
|||||||
myDebug_P(PSTR(" Mode is set to night"));
|
myDebug_P(PSTR(" Mode is set to night"));
|
||||||
} else if (thermoMode == 4) {
|
} else if (thermoMode == 4) {
|
||||||
myDebug_P(PSTR(" Mode is set to day"));
|
myDebug_P(PSTR(" Mode is set to day"));
|
||||||
} else {
|
|
||||||
myDebug_P(PSTR(" Mode is set to ?"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,12 +809,16 @@ void publishValues(bool force) {
|
|||||||
rootThermostat[THERMOSTAT_HC] = _int_to_char(s, EMSESP_Status.heating_circuit);
|
rootThermostat[THERMOSTAT_HC] = _int_to_char(s, EMSESP_Status.heating_circuit);
|
||||||
|
|
||||||
// different logic depending on thermostat types
|
// different logic depending on thermostat types
|
||||||
if ((ems_getThermostatModel() == EMS_MODEL_EASY) || (ems_getThermostatModel() == EMS_MODEL_FR10) || (ems_getThermostatModel() == EMS_MODEL_FW100)) {
|
if (ems_getThermostatModel() == EMS_MODEL_EASY) {
|
||||||
|
if (EMS_Thermostat.setpoint_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
||||||
|
rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 100;
|
||||||
|
if (EMS_Thermostat.curr_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
||||||
|
rootThermostat[THERMOSTAT_CURRTEMP] = (double)EMS_Thermostat.curr_roomTemp / 100;
|
||||||
|
} else if ((ems_getThermostatModel() == EMS_MODEL_FR10) || (ems_getThermostatModel() == EMS_MODEL_FW100)) {
|
||||||
if (EMS_Thermostat.setpoint_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
if (EMS_Thermostat.setpoint_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
||||||
rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 10;
|
rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 10;
|
||||||
if (EMS_Thermostat.curr_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
if (EMS_Thermostat.curr_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
||||||
rootThermostat[THERMOSTAT_CURRTEMP] = (double)EMS_Thermostat.curr_roomTemp / 10;
|
rootThermostat[THERMOSTAT_CURRTEMP] = (double)EMS_Thermostat.curr_roomTemp / 10;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (EMS_Thermostat.setpoint_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
if (EMS_Thermostat.setpoint_roomTemp != EMS_VALUE_SHORT_NOTSET)
|
||||||
rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 2;
|
rootThermostat[THERMOSTAT_SELTEMP] = (double)EMS_Thermostat.setpoint_roomTemp / 2;
|
||||||
@@ -827,32 +839,7 @@ void publishValues(bool force) {
|
|||||||
rootThermostat[THERMOSTAT_CIRCUITCALCTEMP] = EMS_Thermostat.circuitcalctemp;
|
rootThermostat[THERMOSTAT_CIRCUITCALCTEMP] = EMS_Thermostat.circuitcalctemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// thermostat mode (-1=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day)
|
uint8_t thermoMode = _getThermostatMode(); // 0xFF=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day
|
||||||
int thermoMode = -1;
|
|
||||||
|
|
||||||
if (ems_getThermostatModel() == EMS_MODEL_RC20) {
|
|
||||||
if (EMS_Thermostat.mode == 0) {
|
|
||||||
thermoMode = 0; // low
|
|
||||||
} else if (EMS_Thermostat.mode == 1) {
|
|
||||||
thermoMode = 1; // manual
|
|
||||||
} else {
|
|
||||||
thermoMode = 2; // auto
|
|
||||||
}
|
|
||||||
} else if (ems_getThermostatModel() == EMS_MODEL_RC300) {
|
|
||||||
if (EMS_Thermostat.mode == 0) {
|
|
||||||
thermoMode = 1; // manual
|
|
||||||
} else if (EMS_Thermostat.mode == 1) {
|
|
||||||
thermoMode = 2; // auto
|
|
||||||
}
|
|
||||||
} else { // default for all thermostats
|
|
||||||
if (EMS_Thermostat.mode == 0) {
|
|
||||||
thermoMode = 3; // night
|
|
||||||
} else if (EMS_Thermostat.mode == 1) {
|
|
||||||
thermoMode = 4; // day
|
|
||||||
} else {
|
|
||||||
thermoMode = 2; // auto
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Termostat Mode
|
// Termostat Mode
|
||||||
if (thermoMode == 0) {
|
if (thermoMode == 0) {
|
||||||
@@ -1854,9 +1841,9 @@ void setup() {
|
|||||||
INIT_MARKERS(0);
|
INIT_MARKERS(0);
|
||||||
LA_PULSE(50);
|
LA_PULSE(50);
|
||||||
|
|
||||||
// GPIO15 has a pull down, so we must set it to HIGH
|
// GPIO15 has a pull down, so we must set it to HIGH
|
||||||
pinMode(15, OUTPUT);
|
pinMode(15, OUTPUT);
|
||||||
digitalWrite(15,1);
|
digitalWrite(15, 1);
|
||||||
|
|
||||||
// init our own parameters
|
// init our own parameters
|
||||||
initEMSESP();
|
initEMSESP();
|
||||||
@@ -1868,7 +1855,7 @@ void setup() {
|
|||||||
|
|
||||||
// set up myESP for Wifi, MQTT, MDNS and Telnet
|
// set up myESP for Wifi, MQTT, MDNS and Telnet
|
||||||
myESP.setTelnet(TelnetCommandCallback, TelnetCallback); // set up Telnet commands
|
myESP.setTelnet(TelnetCommandCallback, TelnetCallback); // set up Telnet commands
|
||||||
myESP.setWIFI(NULL, NULL, WIFICallback); // empty ssid and password as we take this from the config file
|
myESP.setWIFI(NULL, NULL, WIFICallback); // empty ssid and password as we take this from the config file
|
||||||
|
|
||||||
// MQTT host, username and password taken from the SPIFFS settings
|
// MQTT host, username and password taken from the SPIFFS settings
|
||||||
myESP.setMQTT(
|
myESP.setMQTT(
|
||||||
|
|||||||
@@ -220,7 +220,6 @@ const uint32_t EMS_BUS_TIMEOUT = 15000; // timeout in ms before recogni
|
|||||||
const uint32_t EMS_POLL_TIMEOUT = 5000000; // timeout in microseconds before recognizing the ems bus is offline (5 seconds)
|
const uint32_t EMS_POLL_TIMEOUT = 5000000; // timeout in microseconds before recognizing the ems bus is offline (5 seconds)
|
||||||
|
|
||||||
// init stats and counters and buffers
|
// init stats and counters and buffers
|
||||||
// uses -255 or 255 for values that haven't been set yet (EMS_VALUE_INT_NOTSET and EMS_VALUE_FLOAT_NOTSET)
|
|
||||||
void ems_init() {
|
void ems_init() {
|
||||||
// overall status
|
// overall status
|
||||||
EMS_Sys_Status.emsRxPgks = 0;
|
EMS_Sys_Status.emsRxPgks = 0;
|
||||||
@@ -248,8 +247,8 @@ void ems_init() {
|
|||||||
EMS_Thermostat.day = 0;
|
EMS_Thermostat.day = 0;
|
||||||
EMS_Thermostat.month = 0;
|
EMS_Thermostat.month = 0;
|
||||||
EMS_Thermostat.year = 0;
|
EMS_Thermostat.year = 0;
|
||||||
EMS_Thermostat.mode = 255; // dummy value
|
EMS_Thermostat.mode = EMS_VALUE_INT_NOTSET;
|
||||||
EMS_Thermostat.day_mode = 255; // dummy value
|
EMS_Thermostat.day_mode = EMS_VALUE_INT_NOTSET;
|
||||||
EMS_Thermostat.device_id = EMS_ID_NONE;
|
EMS_Thermostat.device_id = EMS_ID_NONE;
|
||||||
EMS_Thermostat.write_supported = false;
|
EMS_Thermostat.write_supported = false;
|
||||||
EMS_Thermostat.hc = 1; // default heating circuit is 1
|
EMS_Thermostat.hc = 1; // default heating circuit is 1
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define APP_NAME "EMS-ESP"
|
#define APP_NAME "EMS-ESP"
|
||||||
#define APP_VERSION "1.8.1b21"
|
#define APP_VERSION "1.8.1b22"
|
||||||
#define APP_HOSTNAME "ems-esp"
|
#define APP_HOSTNAME "ems-esp"
|
||||||
|
|||||||
Reference in New Issue
Block a user