Skip to content

Commit

Permalink
1.10-fas
Browse files Browse the repository at this point in the history
	* introduced -minimal version for interim-upgrade on small sketch size
	* new "action" property for hass - thanks austwhite
	* keep only WLAN settings from compatibility Firmware
	* Fix too less page-buffor for startpage (reboot button missing)
	* Uptime seconds fix
  • Loading branch information
fashberg committed Apr 25, 2020
1 parent ff41a26 commit a851eb4
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 12 deletions.
8 changes: 8 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Version 1.10-fas
* introduced -minimal version for interim-upgrade on small sketch size
* new "action" property for hass - thanks austwhite
* keep only WLAN settings from compatibility Firmware
* Fix too less page-buffor for startpage (reboot button missing)
* Uptime seconds fix
* by Folke Ashberg <folke@ashberg.de>

## Version 1.09-fas
* WebThings back working (/things) - thanks erelor
* Optional sending of changed values to its own MQTT topic with no JSON - thanks Bettman66
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ To setup the device model, network options and other parameters, follow instrcut
Configuration.md
After initial setup, the device configuration is available via `http://<device_ip>/`

## Upgrading
You can Upgrade over the Air from other versions of ThermostatBecaWifi on the Web-GUI.
Please check all settings after Upgrade!

If you upgrade from original Klaus-Ahrenberg's Original-Version please note:
* Only WLAN settings are kept
* If you get "Not Enough Space" you can use WThermostat_1.xx-fas-minial.bin as interim-version.
* WLAN settings are kept
* no MQTT, no Beca-control, no Clock in -minimal
* Then Upgrade to normal-version
* Not neccessary when upgrading from fas to fas versions

## Screenshots
Main Screen:
![setup_main](docs/Setup_Main.png)
Expand Down Expand Up @@ -105,6 +117,8 @@ For manual Configuration here is an example for your configuration.yaml file:
climate:
- platform: mqtt
name: Room_Thermostat
action_topic: "home/room/stat/things/thermostat/properties"
action_template: "{{ value_json['action'] }}"
temperature_command_topic: "home/room/cmnd/things/thermostat/properties/targetTemperature"
temperature_state_topic: "home/room/stat/things/thermostat/properties"
temperature_state_template: "{{ value_json['targetTemperature'] }}"
Expand Down Expand Up @@ -148,12 +162,13 @@ The state report is sent with MQTT-retain-flag enabled.
"schedulesMode":"off|auto",
"ecoMode":false,
"locked":false,
"state":"off|heating", //only_available,_if_hardware_modified
"state":"off|heating", //only_available, if hardware is modified
"floorTemperature":20, //only_BHT-002-GBLW
"fanMode":"auto|low|medium|high", //only_BAC-002-ALW
"systemMode":"cool|heat|fan_only", //only_BAC-002-ALW
"mode":"off|auto|heat" // BHT-002: combined Mode for better home assistant support.
"mode":"off|autoheat|autocool|autofan|heat|cool|fan_only" // BAC-002-ALW
"action":"off|idle|heating|cooling|fan" // read only current action, idle only available if hardware is modified, cooling/fan only BAC-002
}
```

Expand Down
49 changes: 45 additions & 4 deletions WThermostat/WBecaDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const static char MQTT_HASS_AUTODISCOVERY_CLIMATE[] PROGMEM = R"=====(
"unique_id": "%s",
"dev":{"ids":["%s"],"name":"%s","mdl":"%s","sw":"%s","mf":"WThermostatBeca"},
"~": "%s",
"action_stat_t":"~/stat/things/thermostat/properties",
"action_stat_tpl":"{{value_json.action}}",
"mode_cmd_t":"~/cmnd/things/thermostat/properties/mode",
"mode_stat_t":"~/stat/things/thermostat/properties",
"mode_stat_tpl":"{{value_json.mode}}",
Expand Down Expand Up @@ -103,6 +105,11 @@ const char* MODE_AUTOFAN = "autofan";
const char* MODE_HEAT = "heat";
const char* MODE_COOL = "cool";
const char* MODE_FAN = "fan_only";
const char* ACTION_OFF = "off";
const char* ACTION_COOLING = "cooling";
const char* ACTION_HEATING = "heating";
const char* ACTION_IDLE = "idle";
const char* ACTION_FAN = "fan";

const byte STORED_FLAG_BECA = 0x36;
const char SCHEDULES_PERIODS[] = "123456";
Expand Down Expand Up @@ -252,10 +259,25 @@ class WBecaDevice: public WDevice {
}
this->mode->addEnumString(MODE_HEAT);
this->mode->setOnChange(std::bind(&WBecaDevice::modeToMcu, this, std::placeholders::_1));
this->mode->setOnValueRequest([this](WProperty* p) {updateMode();});
this->mode->setOnValueRequest([this](WProperty* p) {updateModeAndAction();});
this->mode->setMqttSendChangedValues(true);
this->addProperty(mode);

this->action = new WProperty("action", "action", STRING);
this->action->setAtType("ThermostatactionProperty");
this->action->addEnumString(ACTION_OFF);
this->action->addEnumString(ACTION_HEATING);
if (isSupportingHeatingRelay() || isSupportingCoolingRelay()) this->action->addEnumString(ACTION_IDLE);
if (getThermostatModel() == MODEL_BHT_002_GBLW) {
}
if (getThermostatModel() == MODEL_BAC_002_ALW) {
this->action->addEnumString(ACTION_COOLING);
this->action->addEnumString(ACTION_FAN);
}
this->action->setMqttSendChangedValues(true);
this->action->setReadOnly(true);
this->addProperty(action);


if (getThermostatModel() == MODEL_BHT_002_GBLW) {
//disable Cooling Relay if enabled on heating-thermostat
Expand All @@ -272,6 +294,7 @@ class WBecaDevice: public WDevice {
this->state->addEnumString(STATE_HEATING);
this->state->addEnumString(STATE_COOLING);
this->state->setMqttSendChangedValues(true);
this->state->setOnValueRequest([this](WProperty* p) {updateModeAndAction();});
this->addProperty(state);
}

Expand Down Expand Up @@ -1014,7 +1037,8 @@ class WBecaDevice: public WDevice {
WProperty* targetTemperature;
WProperty* actualTemperature;
WProperty* actualFloorTemperature;
WProperty* mode;
WProperty* mode;
WProperty* action;
WProperty* schedulesMode;
WProperty* systemMode;
WProperty* fanMode;
Expand Down Expand Up @@ -1498,8 +1522,7 @@ class WBecaDevice: public WDevice {
}
}


void updateMode() {
void updateModeAndAction() {
if (!this->deviceOn->getBoolean()){
this->mode->setString(MODE_OFF);
} else if (this->schedulesMode->equalsString(SCHEDULES_MODE_AUTO)){
Expand Down Expand Up @@ -1529,6 +1552,24 @@ class WBecaDevice: public WDevice {
} else {
network->log()->error(F("Bug. Can't find mode (on+noauto+?)"));
}

// mode to action
if (this->mode->equalsString(MODE_OFF)) this->action->setString(ACTION_OFF);
else if (getThermostatModel() == MODEL_BAC_002_ALW) {
if ((isSupportingCoolingRelay() || isSupportingHeatingRelay()) && this->state->equalsString(STATE_OFF)){
this->action->setString(ACTION_IDLE);
} else if (this->systemMode->equalsString(SYSTEM_MODE_HEAT)){
this->action->setString(ACTION_HEATING);
} else if (this->systemMode->equalsString(SYSTEM_MODE_COOL)){
this->action->setString(ACTION_COOLING);
} else if (this->systemMode->equalsString(SYSTEM_MODE_FAN)){
this->action->setString(ACTION_FAN);
}
} else if (getThermostatModel() == MODEL_BHT_002_GBLW){
if ((isSupportingCoolingRelay() || isSupportingHeatingRelay()) && this->state->equalsString(STATE_OFF)){
this->action->setString(ACTION_IDLE);
} else this->action->setString(ACTION_HEATING);
}
}

void lockedToMcu(WProperty* property) {
Expand Down
4 changes: 2 additions & 2 deletions WThermostat/WClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ class WClock : public WDevice {
if (!notify && lastRun > now-1000) return;
lastRun=now;

network->log()->verbose(F("Clock: epoch: %d,timezone_diff: %d, millis: %d, nextSync: %d, lastTry: %d, lastSync: %d"),
getEpochTime(), Rtc.time_timezone, now, nextSync, lastTry, lastNtpSync);
//network->log()->verbose(F("Clock: epoch: %d,timezone_diff: %d, millis: %d, nextSync: %d, lastTry: %d, lastSync: %d"),
// getEpochTime(), Rtc.time_timezone, now, nextSync, lastTry, lastNtpSync);

Rtc.local_time = Rtc.utc_time + Rtc.time_timezone;
BreakTime(Rtc.local_time, RtcTime);
Expand Down
20 changes: 16 additions & 4 deletions WThermostat/WThermostat.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#include <Arduino.h>

#include "../lib/WAdapter/WAdapter/WNetwork.h"
#ifndef MINIMAL
#include "WBecaDevice.h"
#include "WClock.h"
#include "WLogDevice.h"

#endif
#define APPLICATION "Thermostat Beca"
#define VERSION "1.09-fas"
#define VERSION "1.10-fas"

#ifdef MINIMAL
#define FULLVERSION VERSION "-minimal"
#elif DEBUG
#define FULLVERSION VERSION "-debug"
#else
#define FULLVERSION VERSION
#endif

#ifdef DEBUG // use platform.io environment to activate/deactive
#define SERIALDEBUG true // enables logging to serial console
Expand All @@ -23,15 +32,18 @@
#endif

WNetwork *network;
#ifndef MINIMAL
WLogDevice *logDevice;
WBecaDevice *becaDevice;
WClock *wClock;
#endif

void setup() {
Serial.begin(SERIALSPEED);

// Wifi and Mqtt connection
network = new WNetwork(SERIALDEBUG, APPLICATION, VERSION, NO_LED);
network = new WNetwork(SERIALDEBUG, APPLICATION, FULLVERSION, NO_LED);
#ifndef MINIMAL
network->setOnNotify([]() {
if (network->isSoftAPDesired()){
becaDevice->reportNetworkToMcu(mcuNetworkMode::MCU_NETWORKMODE_SMARTCONFIG);
Expand Down Expand Up @@ -94,7 +106,7 @@ void setup() {
// https://www.home-assistant.io/integrations/climate.mqtt/
return becaDevice->sendMqttHassAutodiscover();
});

#endif
network->startWebServer();

}
Expand Down
Binary file removed WThermostat_1.09-fas.bin
Binary file not shown.
Binary file added WThermostat_1.10-fas-minimal.bin
Binary file not shown.
Binary file added WThermostat_1.10-fas.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/WAdapter
9 changes: 9 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ build_cache_dir = .pio/cache
extra_configs = platformio_override.ini
default_envs =
wmthermostat
wmthermostat-minimal
wmthermostat-debug

[common]
framework = arduino
board = esp01_1m
board_build.flash_mode = dout
; defaults: see https://github.com/platformio/platform-espressif8266/blob/master/boards/esp01_1m.json
; default "ldscript": "eagle.flash.1m256.ld"
; we don't need 256kByte spiffs memory
board_build.ldscript = eagle.flash.1m.ld
platform = espressif8266@2.4.0
platform_packages =
Expand All @@ -29,6 +33,7 @@ build_flags =
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190703
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
-DVTABLES_IN_FLASH
-D ATOMIC_FS_UPDATE -Os
-fno-exceptions
-lstdc++
-Wl,-Map,firmware.map
Expand Down Expand Up @@ -76,6 +81,10 @@ lib_deps = ${common.lib_deps}
build_flags = ${common.build_flags}
-D NDEBUG

[env:wmthermostat-minimal]
build_flags = ${common.build_flags}
-D NDEBUG -D MINIMAL

[env:wmthermostat-debug]
platform = espressif8266@2.4.0
board = nodemcuv2
Expand Down

0 comments on commit a851eb4

Please sign in to comment.