Browse Source

## 0.7.1 2022-11-26
* revert "thermostat logic every second, not depending on interval for measurements" as it caused performance issues
* enhance compatibility with current Home Assistant versions MQTT-HVAC integration (tested with Home Assistant 2022.11.4)
* add documentation: HomeAssistant.md
* update documentation

FloKra 1 year ago
parent
commit
a671e64932

+ 6 - 0
CHANGELOG.md

@@ -1,5 +1,11 @@
 # WiFiThermostat - Changelog
 
+## 0.7.1 2022-11-26
+* revert "thermostat logic every second, not depending on interval for measurements" as it caused performance issues
+* enhance compatibility with current Home Assistant versions MQTT-HVAC integration (tested with Home Assistant 2022.11.4)
+* add documentation: HomeAssistant.md
+* update documentation
+
 ## 0.7.0 2022-11-25
 * display active heating lock status
   *  lock symbol on LCD

+ 13 - 0
COMMANDS.md

@@ -51,3 +51,16 @@ Case-Insensitive.
 | confLog     | configuration regarding Logging
 
 
+## changing WiFi settings via Serial 
+
+Therefore the __set PARAM VALUE__ command is used:
+```
+set ssid1 [YOUR_SSID]
+set wpw1 [YOUR_WIFI_PASSWORD]
+set ssid2 [YOUR_FALLBACK_SSID]
+set wpw2 [YOUR_FALLBACK_WIFI_PASSWORD]
+saveconf
+restart
+```
+
+Please note that ``getconf`` and ``get wpw[x]`` won´t reveal a saved password. 

+ 80 - 0
HomeAssistant.md

@@ -0,0 +1,80 @@
+# Home Assistant Integration
+
+This Thermostat can be integrated in Home Assistant so that it can be controlled from there. 
+This is done using MQTT. 
+
+Currently it can only be integrated using manual YAML file based configuration. 
+
+## MQTT-HVAC integration (former 'Climate')
+
+Using the MQTT-HVAC integration all basic things can now be controlled: 
+- set temperature
+- mode (off or heat = on and off)
+- presets
+
+```yaml
+mqtt:
+  climate:
+    - name: Test-Thermostat
+      unique_id: TestThermo1
+      # current room temperature from sensor
+      current_temperature_topic: Test/WTherm/stat/temp
+      
+      # using topic /currSetTemp - reduction temperatures are shown in Home Assistant (but cannot be changed)
+      # using topic /setTemp - reduction temperatures are NOT shown in Home Assistant
+      temperature_state_topic: Test/WTherm/stat/currSetTemp
+    
+      # topic to control set temperature (only for "normal" preset, not reduction presets)
+      temperature_command_topic: Test/WTherm/cmd/setTemp
+
+      # control only possible if device is online
+      availability_topic: Test/WTherm/availability
+      payload_available: "online"
+      payload_not_available: "offline"
+      
+      # MQTT related settings
+      qos: 2
+      retain: false
+
+      # thermostat related settings
+      precision: 0.5
+      temp_step: 0.5
+      initial: 20.0
+      min_temp: 16.0
+      max_temp: 24.0
+    
+      # Presets
+      # Stat topic /presetHA sends "norm", "red1" or "red2".
+      # Command Topic setPreset understands these short names as well as numbers or the long names, 
+      # so it can be used here.
+      # Translation between short names and long (localized) names shown in Home Assistant is
+      # done using the templates below.
+      preset_mode_command_topic: Test/WTherm/cmd/setPreset
+      preset_mode_state_topic: Test/WTherm/stat/presetHA
+      preset_modes:
+        - Normal
+        - Reduction 1
+        - Reduction 2
+      preset_mode_value_template: >
+        {% if value == "norm" -%}Normal
+        {% elif value == "red1" -%}Reduction 1
+        {% elif value == "red2" -%}Reduction 2
+        {%- endif %}
+      preset_mode_command_template: >
+        {% if value == "Normal" -%}norm
+        {% elif value == "Reduction 1" -%}red1
+        {% elif value == "Reduction 2" -%}red2
+        {%- endif %}
+
+      # Mode
+      # This is in reality only "on" or "off", but as it is implemented like this in 
+      # Home Assistant, we can switch the "mode" to either "off" or "heat" now. 
+      # Stat topic /modeHA sends "off" or "heat", command topic /setMode understands these as well.
+      # As both "off" and "heat" are predefined in Home Assistant integration 
+      # (and shown with nice localized names in the UI) we don´t need templates here. 
+      mode_command_topic: "Test/WTherm/cmd/setMode"
+      mode_state_topic: "Test/WTherm/stat/modeHA"
+      modes: ["off", "heat"]
+
+```
+

+ 3 - 0
README.md

@@ -62,3 +62,6 @@ consists of:
 
 Screenshots here: [Web Interface](./WEBINTERFACE.md)
 
+## Home Assistant integration
+
+see details here: [Home Assistant](./HomeAssistant.md)

+ 3 - 0
README_DE.md

@@ -87,3 +87,6 @@ Nach einiger Zeit - und da auch in der Open Source Welt nichts 100% passendes od
 
 Screenshots hier: [Web Interface](./WEBINTERFACE.md)
 
+## Home Assistant integration
+
+Details hier: [Home Assistant](./HomeAssistant.md)

BIN
releases/bin/WiFiThermostat.ino.d1_mini.20221126_v0.7.1.bin


BIN
releases/src/WiFiThermostat_0.7.1.zip


+ 1 - 1
src/fwversion.h

@@ -1,6 +1,6 @@
 // DEFINE NAMES
 #define FIRMWARE_NAME "WiFiThermostat"
-#define FIRMWARE_VERSION "0.7.0"
+#define FIRMWARE_VERSION "0.7.1"
 #define FIRMWARE_URL "https://git.flokra.at/flo/WiFiThermostat"
 #define FIRMWARE_COPYRIGHT "FloKra"
 #define FIRMWARE_COPYRIGHT_URL "https://www.flokra.at/"

+ 5 - 1
src/mqtt.ino

@@ -152,6 +152,8 @@ void mqttCallback(char *topic, unsigned char *payload, uint16_t length)
       tmpHeatMode = 1;
     else if (strcmp(tmpPayload, "ein") == 0)
       tmpHeatMode = 1;
+    else if (strcmp(tmpPayload, "heat") == 0)
+      tmpHeatMode = 1;
     else if (atoi(tmpPayload) == 0)
       tmpHeatMode = 0;
     else if (atoi(tmpPayload) == 1)
@@ -220,7 +222,7 @@ void mqttCallback(char *topic, unsigned char *payload, uint16_t length)
       sprintf(buf, "MQTT IN: setPause to %u", _setTo);
       sendLog(buf, LOGLEVEL_INFO);
     }
-    
+
     cmdInQueue = false; // payload is processed in "commands"
   }                     //if topic = mqtt_topic_in_setPause
 
@@ -265,6 +267,8 @@ void mqttCallback(char *topic, unsigned char *payload, uint16_t length)
       tmpPreset = 2;
     else if (strcmp(tmpPayload, "none") == 0)
       tmpPreset = 0;
+    else if (strcmp(tmpPayload, "norm") == 0)
+      tmpPreset = 0;
     else if (strcmp(tmpPayload, "red1") == 0)
       tmpPreset = 1;
     else if (strcmp(tmpPayload, "red2") == 0)

+ 13 - 3
src/mqtt_out.ino

@@ -58,6 +58,11 @@ void publishCurrentThermostatValues(bool force = false)
     sprintf(tmp_topic_out, "%s/%s", confMqtt.mqtt_topic_out, "modeName");
     mqttclient.publish(tmp_topic_out, currentModeName, confMqtt.mqtt_outRetain);
 
+
+    sprintf(tmp_topic_out, "%s/%s", confMqtt.mqtt_topic_out, "modeHA");
+    if(heatingMode == 0) mqttclient.publish(tmp_topic_out, "off", confMqtt.mqtt_outRetain);
+    else if(heatingMode == 1) mqttclient.publish(tmp_topic_out, "heat", confMqtt.mqtt_outRetain);
+
     if (confBas.saveToMqttRetained && heatingMode != heatingMode_lastPublished)
     {
       // MQTT retained save setMode
@@ -84,9 +89,11 @@ void publishCurrentThermostatValues(bool force = false)
 
     sprintf(tmp_topic_out, "%s/%s", confMqtt.mqtt_topic_out, "presetHA");
     if (preset == 0)
-      mqttclient.publish(tmp_topic_out, "none", confMqtt.mqtt_outRetain);
-    else
-      mqttclient.publish(tmp_topic_out, currentPresetName, confMqtt.mqtt_outRetain);
+      mqttclient.publish(tmp_topic_out, "norm", confMqtt.mqtt_outRetain);
+    else if (preset == 1)
+      mqttclient.publish(tmp_topic_out, "red1", confMqtt.mqtt_outRetain);
+    else if (preset == 2)
+      mqttclient.publish(tmp_topic_out, "red2", confMqtt.mqtt_outRetain);
 
     if (confBas.saveToMqttRetained && preset != preset_lastPublished)
     {
@@ -311,6 +318,9 @@ void publishDeleteRetainedOutMessages()
     sprintf(tmp_topic_out, "%s/%s", confMqtt.mqtt_topic_out, "modeName");
     mqttclient.publish(tmp_topic_out, "", true);
 
+    sprintf(tmp_topic_out, "%s/%s", confMqtt.mqtt_topic_out, "modeHA");
+    mqttclient.publish(tmp_topic_out, "", true);
+
     sprintf(tmp_topic_out, "%s/%s", confMqtt.mqtt_topic_out, "preset");
     mqttclient.publish(tmp_topic_out, "", true);
 

+ 1 - 3
src/scheduler.ino

@@ -54,7 +54,7 @@ void everySecond()
   {
     countMeasureInterval = 0;
     measureTempHum();
-    //thermostat();
+    thermostat();
   }
 
   if(heatingPause > 0) {
@@ -67,8 +67,6 @@ void everySecond()
     publish_heatingLockTime();
   }
 
-  thermostat();
-
   if (countDisplayInterval < confBas.displayInterval)
     countDisplayInterval++;
   else