Skip to content

Commit

Permalink
1.21
Browse files Browse the repository at this point in the history
* reimplemented Away-Mode with Preset (Heating and A/C)
* fixed scheduler-Mode with Preset 'Scheduler' (A/C)
* updated docs and samples
  • Loading branch information
fashberg committed Sep 11, 2022
1 parent 3ee61a3 commit 6776f27
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 26 deletions.
19 changes: 19 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## Version 1.21-fas

* reimplemented Away-Mode with Preset (Heating and A/C)
* fixed scheduler-Mode with Preset 'Scheduler' (A/C)
* updated docs and samples

## Version 1.20-fas

### Changes in this Release

* HA 2022.9 compatibility #153, #146. Thanks to @labodj
* Update to latest dependencies and compatibility @labodj/@fashberg
* decreased minimum temp by @zawasp / #98
* removed away-mode @jressel01 #148

### And Build CI updates

* moved from travis-ci to github-actions @fashberg

## Version 1.19-fas

* Fix/Enhancement #54: If enabled, all single Properties are sent out every notification interval, not only if changed
Expand Down
41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,16 @@ Live WebLog Screen:

## Integration in Home Assistant

![homeassistant](docs/images/homeassistant.png) ![hass_discovery](docs/images/hass_discovery.png)
![homeassistant](docs/images/homeassistant.png)
![homeassistant](docs/images/hass_detail.png)
![hass_discovery](docs/images/hass_discovery.png)

### Controlling BAC in HomeAssistant

* Use Operation to Switch between 'heat', 'cool', 'fan_only' and 'off'
* Use Preset to switch between 'None' (manual), 'Scheduler' and 'eco'
* Changing temp disables scheduler and switches to preset 'None'

![homeassistant](docs/images/hass-bac.png)

### HASS Autodiscovery
Expand Down Expand Up @@ -213,15 +219,14 @@ climate:
temperature_state_template: "{{value_json.targetTemperature}}"
current_temperature_topic: "home/room/stat/things/thermostat/properties"
current_temperature_template: "{{value_json.temperature}}"
away_mode_command_topic: "home/room/cmnd/things/thermostat/properties/ecoMode"
away_mode_state_topic: "home/room/stat/things/thermostat/properties"
away_mode_state_template: "{{value_json.ecoMode}}"
mode_command_topic: "home/room/cmnd/things/thermostat/properties/mode"
mode_state_topic: "home/room/stat/things/thermostat/properties"
mode_state_template: "{{value_json.mode}}"
payload_on: true
payload_off: false
modes: [ "heat", "auto", "off" ]
preset_mode_command_topic: "home/room/cmnd/things/thermostat/properties/preset"
preset_mode_state_topic: "home/room/stat/things/thermostat/properties"
preset_mode_value_template: "{{value_json.preset}}"
preset_modes: ["away"]
min_temp: 5
max_temp: 35
temp_step: 0.5
Expand Down Expand Up @@ -256,12 +261,6 @@ climate:
fan_mode_command_topic: "home/bedroom/cmnd/things/thermostat/properties/fanMode"
fan_mode_state_topic: "home/bedroom/stat/things/thermostat/properties"
fan_mode_state_template: "{{value_json.fanMode}}"
hold_command_topic: "home/bedroom/cmnd/things/thermostat/properties/holdState"
hold_state_topic: "home/bedroom/stat/things/thermostat/properties"
hold_state_template: "{{value_json.holdState}}"
hold_modes: [ "scheduler", "manual","eco" ]
payload_on: true
payload_off: false
modes: [ "heat", "cool", "fan_only", "off" ]
min_temp: 16
max_temp: 32
Expand All @@ -280,10 +279,10 @@ climate:
temperature_command_topic: "home/wohnzimmer/cmnd/things/thermostat/properties/targetTemperature"
temperature_state_topic: "home/wohnzimmer/stat/things/thermostat/properties"
current_temperature_topic: "home/wohnzimmer/stat/things/thermostat/properties"
away_mode_command_topic: "home/wohnzimmer/cmnd/things/thermostat/properties/ecoMode"
away_mode_state_topic: "home/wohnzimmer/stat/things/thermostat/properties"
mode_command_topic: "home/wohnzimmer/cmnd/things/thermostat/properties/mode"
mode_state_topic: "home/wohnzimmer/stat/things/thermostat/properties"
preset_mode_command_topic: "home/wohnzimmer/cmnd/things/thermostat/properties/preset"
preset_mode_state_topic: "home/wohnzimmer/stat/things/thermostat/properties"
<<: &commonbeca
payload_available: "Online"
payload_not_available: "Offline"
Expand All @@ -292,9 +291,9 @@ climate:
current_temperature_template: "{{value_json.temperature}}"
mode_state_template: "{{value_json.mode}}"
away_mode_state_template: "{{value_json.ecoMode}}"
payload_on: true
payload_off: false
modes: [ "heat", "auto", "off" ]
preset_mode_value_template: "{{value_json.preset}}"
preset_modes: ["away"]
min_temp: 5
max_temp: 35
temp_step: 0.5
Expand All @@ -310,6 +309,8 @@ climate:
away_mode_state_topic: "home/flur/stat/things/thermostat/properties"
mode_command_topic: "home/flur/cmnd/things/thermostat/properties/mode"
mode_state_topic: "home/flur/stat/things/thermostat/properties"
preset_mode_command_topic: "home/flur/cmnd/things/thermostat/properties/preset"
preset_mode_state_topic: "home/flur/stat/things/thermostat/properties"
<<: *commonbeca
- platform: mqtt
name: WC_Thermostat
Expand All @@ -322,6 +323,8 @@ climate:
away_mode_state_topic: "home/wc/stat/things/thermostat/properties"
mode_command_topic: "home/wc/cmnd/things/thermostat/properties/mode"
mode_state_topic: "home/wc/stat/things/thermostat/properties"
preset_mode_command_topic: "home/wc/cmnd/things/thermostat/properties/preset"
preset_mode_state_topic: "home/wc/stat/things/thermostat/properties"
<<: *commonbeca
```
Expand All @@ -340,7 +343,7 @@ There is also a detailed view available:
## Device-Functions
### Json structures
### JSON structures
The software provides different messages:
Expand Down Expand Up @@ -482,6 +485,10 @@ mosquitto_pub -t "home/test/cmnd/things/thermostat/mcucommand" -m "55 aa 00 1c 0
```

### MQTT Explorer

For MQTT Troubleshooting i suggest MQTT Explorer, which can be found at <https://github.com/thomasnordquist/MQTT-Explorer>

## How it works

### Hardware and serial communication
Expand Down
67 changes: 59 additions & 8 deletions WThermostat/WBecaDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ const static char MQTT_HASS_AUTODISCOVERY_CLIMATE[] PROGMEM = R"=====(
"temp_stat_tpl":"{{value_json.targetTemperature}}",
"curr_temp_t":"~/stat/things/thermostat/properties",
"curr_temp_tpl":"{{value_json.temperature}}",
"pl_on":true,
"pl_off":false,
"pr_mode_cmd_t":"~/cmnd/things/thermostat/properties/preset",
"pr_mode_stat_t":"~/stat/things/thermostat/properties",
"pr_mode_val_tpl":"{{value_json.preset}}",
"pr_modes":["away"],
"min_temp":5,
"max_temp":"35",
"temp_step":"%s",
Expand Down Expand Up @@ -81,12 +83,10 @@ const static char MQTT_HASS_AUTODISCOVERY_AIRCO[] PROGMEM = R"=====(
"fan_mode_cmd_t":"~/cmnd/things/thermostat/properties/fanMode",
"fan_mode_stat_t":"~/stat/things/thermostat/properties",
"fan_mode_stat_tpl":"{{value_json.fanMode}}",
"hold_cmd_t":"~/cmnd/things/thermostat/properties/holdState",
"hold_stat_t":"~/stat/things/thermostat/properties",
"hold_stat_tpl":"{{value_json.holdState}}",
"hold_modes":["scheduler","manual","eco"],
"pl_on":true,
"pl_off":false,
"pr_mode_cmd_t":"~/cmnd/things/thermostat/properties/preset",
"pr_mode_stat_t":"~/stat/things/thermostat/properties",
"pr_mode_val_tpl":"{{value_json.preset}}",
"pr_modes":["away", "scheduler"],
"min_temp":"10",
"max_temp":"35",
"temp_step":"%s",
Expand Down Expand Up @@ -178,6 +178,9 @@ const char* MODE_AUTO PROGMEM = "auto";
const char* MODE_HEAT PROGMEM = "heat";
const char* MODE_COOL PROGMEM = "cool";
const char* MODE_FAN PROGMEM = "fan_only";
const char* PRESET_NONE PROGMEM = "none";
const char* PRESET_AWAY PROGMEM = "away";
const char* PRESET_SCHEDULER PROGMEM = "scheduler";
const char* ACTION_OFF PROGMEM = "off";
const char* ACTION_COOLING PROGMEM = "cooling";
const char* ACTION_HEATING PROGMEM = "heating";
Expand Down Expand Up @@ -227,6 +230,8 @@ const char* PROP_FANMODE PROGMEM = "fanMode";
const char* TITL_FANMODE PROGMEM = "Fan";
const char* PROP_MODE PROGMEM = "mode";
const char* TITL_MODE PROGMEM = "Mode";
const char* PROP_PRESET PROGMEM = "preset";
const char* TITL_PRESET PROGMEM = "Preset";
const char* PROP_ACTION PROGMEM = "action";
const char* TITL_ACTION PROGMEM = "Action";
const char* PROP_STATE PROGMEM = "state";
Expand All @@ -236,6 +241,7 @@ const char* PROP_MCUID PROGMEM = "mcuId";
const char* ATTYPE_SCHEDULESMODE PROGMEM = "ThermostatSchedulesModeProperty";
const char* ATTYPE_HOLDSTATE PROGMEM = "ThermostatHoldStateProperty";
const char* ATTYPE_MODE PROGMEM = "ThermostatModeProperty";
const char* ATTYPE_PRESET PROGMEM = "ThermostatPresetProperty";
const char* ATTYPE_FANMODE PROGMEM = "FanModeProperty";
const char* ATTYPE_ACTION PROGMEM = "ThermostatActionProperty";
const char* ATTYPE_HEATINGCOOLING PROGMEM = "HeatingCoolingProperty";
Expand Down Expand Up @@ -490,6 +496,19 @@ class WBecaDevice: public WDevice {
this->mode->setMqttSendChangedValues(true);
this->addProperty(mode);

this->preset = new WProperty(PROP_PRESET, TITL_PRESET, STRING);
this->preset->setVisibility(ALL);
this->preset->setAtType(ATTYPE_PRESET);
this->preset->addEnumString(PRESET_NONE);
this->preset->addEnumString(PRESET_AWAY);
if (getThermostatModel() == MODEL_BAC_002_ALW) {
this->preset->addEnumString(PRESET_SCHEDULER);
}
this->preset->setOnChange(std::bind(&WBecaDevice::presetToMcu, this, std::placeholders::_1));
this->preset->setOnValueRequest([this](WProperty* p) {updatePreset();});
this->preset->setMqttSendChangedValues(true);
this->addProperty(preset);

this->action = new WProperty(PROP_ACTION, TITL_ACTION, STRING);
this->action->setAtType(ATTYPE_ACTION);
this->action->addEnumString(ACTION_OFF);
Expand Down Expand Up @@ -1416,6 +1435,7 @@ class WBecaDevice: public WDevice {
WProperty* actualTemperature;
WProperty* actualFloorTemperature;
WProperty* mode;
WProperty* preset;
WProperty* action;
WProperty* schedulesMode;
WProperty* holdState;
Expand Down Expand Up @@ -2077,6 +2097,26 @@ class WBecaDevice: public WDevice {
}
}


void presetToMcu(WProperty* property) {
network->log()->trace(F("presetToMcu %s"), property->c_str());
if (this->mode->equalsString(MODE_OFF)){
//noop
} else if (this->preset->equalsString(PRESET_AWAY)){
this->ecoMode->setBoolean(true);
} else if (getThermostatModel() == MODEL_BAC_002_ALW && this->preset->equalsString(PRESET_SCHEDULER)){
this->ecoMode->setBoolean(false);
this->schedulesMode->setString(SCHEDULES_MODE_AUTO);
this->holdState->setString(HOLD_STATE_SCHEDULER);
} else {
this->ecoMode->setBoolean(false);
if (getThermostatModel() == MODEL_BAC_002_ALW){
this->schedulesMode->setString(SCHEDULES_MODE_OFF);
this->holdState->setString(HOLD_STATE_MANUAL);
}
}
}

void updateModeAndAction() {
if (!this->deviceOn->getBoolean()){
this->mode->setString(MODE_OFF);
Expand Down Expand Up @@ -2119,6 +2159,17 @@ class WBecaDevice: public WDevice {
}
}


void updatePreset() {
if (this->ecoMode->getBoolean()){
this->preset->setString(PRESET_AWAY);
} else if (getThermostatModel() == MODEL_BAC_002_ALW && this->schedulesMode->equalsString(SCHEDULES_MODE_AUTO)){
this->preset->setString(PRESET_SCHEDULER);
} else {
this->preset->setString(PRESET_NONE);
}
}

void lockedToMcu(WProperty* property) {
if (!this->receivingDataFromMcu) {
//55 AA 00 06 00 05 06 01 00 01 01
Expand Down
Binary file modified docs/images/hass-bac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/hass_detail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/homeassistant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default_envs = wthermostat
[common]
# appversion is just devel, during github-actions its set to branch-date-hash or tagname by platformio_override.ini
# you can set your own in your local platformio_override.ini (see platformio_override.sample.ini)
appversion = 1.20.dev
appversion = 1.21.dev
framework = arduino
board = esp01_1m
board_build.flash_mode = dout
Expand Down

0 comments on commit 6776f27

Please sign in to comment.