KartoffelToby / better_thermostat

This custom component for Home Assistant will add crucial features to your climate-controlling TRV (Thermostatic Radiator Valves) to save you the work of creating automations to make it smart. It combines a room-temperature sensor, window/door sensors, weather forecasts, or an ambient temperature probe to decide when it should call for heat and automatically calibrate your TRVs to fix the imprecise measurements taken in the radiator's vicinity.
https://better-thermostat.org
GNU Affero General Public License v3.0
829 stars 126 forks source link

Open and close a window most of the time doesn't reset heating mode correctly #1234

Open TBSniller opened 10 months ago

TBSniller commented 10 months ago

Prerequisites

 {
  "home_assistant": {
    "installation_type": "Home Assistant Supervised",
    "version": "2024.1.2",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "5.10.0-20-amd64",
    "supervisor": "2023.12.0",
    "host_os": "Debian GNU/Linux 11 (bullseye)",
    "docker_version": "20.10.22",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.33.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "better_thermostat": {
      "version": "1.5.0-beta3",
      "requirements": []
    },
    "hass_nuki_bt": {
      "version": "0.0.9",
      "requirements": [
        "pyNukiBT==0.0.7"
      ]
    },
    "dreame_vacuum": {
      "version": "v2.0.0b11",
      "requirements": [
        "pillow",
        "numpy",
        "pybase64",
        "requests",
        "pycryptodome",
        "python-miio",
        "py-mini-racer",
        "tzlocal",
        "paho-mqtt"
      ]
    },
    "nuki_ng": {
      "version": "0.2.1",
      "requirements": []
    },
    "valetudo_vacuum_camera": {
      "version": "v1.5.5",
      "requirements": [
        "pillow",
        "numpy"
      ]
    },
    "tapo_control": {
      "version": "5.4.13",
      "requirements": [
        "pytapo==3.3.18"
      ]
    }
  },
  "integration_manifest": {
    "domain": "better_thermostat",
    "name": "Better Thermostat",
    "after_dependencies": [
      "climate"
    ],
    "codeowners": [
      "@kartoffeltoby"
    ],
    "config_flow": true,
    "dependencies": [
      "climate",
      "recorder"
    ],
    "documentation": "https://github.com/KartoffelToby/better_thermostat",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/KartoffelToby/better_thermostat/issues",
    "requirements": [],
    "version": "1.5.0-beta3",
    "is_built_in": false
  },
  "data": {
    "info": {
      "name": "btrv-bad-01",
      "temperature_sensor": "sensor.temp_bad_01_temperature",
      "off_temperature": 20,
      "humidity_sensor": "sensor.temp_bad_01_humidity",
      "window_sensors": "binary_sensor.opensensor_bad_01_contact",
      "weather": "weather.tbhome",
      "window_off_delay": 0,
      "outdoor_sensor": null,
      "model": "BRT-100-TRV",
      "tolerance": 0.0,
      "window_off_delay_after": 0
    },
    "thermostat": {
      "climate.trv_bad_01": {
        "name": "trv-bad-01",
        "state": "heat",
        "attributes": {
          "hvac_modes": [
            "heat"
          ],
          "min_temp": 5.0,
          "max_temp": 35.0,
          "target_temp_step": 1.0,
          "preset_modes": [
            "none",
            "programming",
            "manual",
            "temporary_manual",
            "holiday"
          ],
          "current_temperature": 9.5,
          "temperature": 5.0,
          "hvac_action": "idle",
          "preset_mode": "manual",
          "battery": 94,
          "boost_heating": "OFF",
          "boost_heating_countdown": 0,
          "boost_heating_countdown_time_set": null,
          "child_lock": "UNLOCK",
          "current_heating_setpoint": 5,
          "device": {
            "applicationVersion": 64,
            "dateCode": "",
            "friendlyName": "trv-bad-01",
            "hardwareVersion": 1,
            "ieeeAddr": "0xcc86ecfffeb80570",
            "manufacturerID": 4098,
            "manufacturerName": "_TZE200_b6wax7g0",
            "model": "BRT-100-TRV",
            "networkAddress": 26187,
            "powerSource": "Battery",
            "stackVersion": 0,
            "type": "EndDevice",
            "zclVersion": 3
          },
          "eco_mode": "OFF",
          "eco_temperature": 20,
          "linkquality": 51,
          "local_temperature": 9.5,
          "local_temperature_calibration": -9,
          "max_temperature": 24,
          "min_temperature": 5,
          "position": 25,
          "preset": "manual",
          "programming_mode": null,
          "running_state": "idle",
          "system_mode": "heat",
          "valve_state": "CLOSED",
          "window": "CLOSED",
          "window_detection": "OFF",
          "friendly_name": "trv-bad-01",
          "supported_features": 17
        },
        "bt_config": {
          "calibration": "local_calibration_based",
          "calibration_mode": "heating_power_calibration",
          "protect_overheating": false,
          "no_off_system_mode": true,
          "heat_auto_swapped": false,
          "valve_maintenance": true,
          "child_lock": true,
          "homaticip": false
        },
        "bt_adapter": "mqtt",
        "bt_integration": "mqtt",
        "model": "BRT-100-TRV"
      }
    },
    "external_temperature_sensor": {
      "entity_id": "sensor.temp_bad_01_temperature",
      "state": "20.4",
      "attributes": {
        "state_class": "measurement",
        "unit_of_measurement": "\u00b0C",
        "device_class": "temperature",
        "friendly_name": "temp-bad-01 Temperature"
      },
      "last_changed": "2024-01-07T15:40:15.188994+00:00",
      "last_updated": "2024-01-07T15:40:15.188994+00:00",
      "context": {
        "id": "01HKJ99VYMTPTK8NZ9RZ1JA0P0",
        "parent_id": null,
        "user_id": null
      }
    },
    "window_sensor": {
      "entity_id": "binary_sensor.opensensor_bad_01_contact",
      "state": "off",
      "attributes": {
        "battery": 90,
        "battery_low": false,
        "contact": true,
        "device": {
          "applicationVersion": 70,
          "dateCode": "",
          "friendlyName": "opensensor-bad-01",
          "hardwareVersion": 1,
          "ieeeAddr": "0xa4c1384ae230d156",
          "manufacturerID": 4417,
          "manufacturerName": "_TZ3000_au1rjicn",
          "model": "TS0203",
          "networkAddress": 53813,
          "powerSource": "Battery",
          "stackVersion": 0,
          "type": "EndDevice",
          "zclVersion": 3
        },
        "linkquality": 27,
        "tamper": false,
        "voltage": 2900,
        "device_class": "door",
        "friendly_name": "opensensor-bad-01 T\u00fcr"
      },
      "last_changed": "2024-01-07T15:44:27.816061+00:00",
      "last_updated": "2024-01-07T15:44:28.816679+00:00",
      "context": {
        "id": "01HKJ9HKMGB7DKWAYCBAW496CF",
        "parent_id": null,
        "user_id": null
      }
    }
  }
}

Description

Some releases ago (sorry don't know, might be some months after AI temp release) my thermostats with window sensor behave incorrectly. My BTRV is turned on to heating, which also can be seen on UI (bottom left fire symbol is red, not the one between temp and humidity). After a window is opened the trv is turned off correcly (Also no bottom left fire symbol in UI in case of not working. Fire symbol when it's working like supposed). When I close the window the state goes back to heating like it should, but most of the time immediatly gets turned off again, which can also be seen in debug logs. This doesn't happen everytime, but I guess 90% of open/closes.

Steps to Reproduce

  1. Turn BTRV to heat 21°
  2. Open window
  3. Wait 15 minutes
  4. Close window

Expected behavior TRV goes back to the state it was when window is closed.

Actual behavior:

Most of the time TRV goes back to the state it was, but immediatly turns off again.

Versions

Issue happened also months ago on earlier versions BetterThermostat: 1.5.0-beta3
HA: 2024.1.2

Additional Information

Here are some debug logs from 1.5.0-beta and 1.5.0-beta3, because the messages look a bit different. In beta3 BTRV also detects some sensors as unavailable, which isn't correct from what I can see.

Debug logs from 1.5.0-beta:

2024-01-03 08:19:54.928 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 20.0 to 21.0
2024-01-03 08:19:54.929 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: calibration accepted by TRV climate.trv_bad_01
2024-01-03 08:19:54.929 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-03 08:19:54.940 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -8.0 | external_temp: 21.0, trv_temp: 21.0, calibration: -8.0
2024-01-03 08:42:10.939 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window opened, waiting 0 seconds before continuing
2024-01-03 08:42:10.944 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -8.0 | external_temp: 21.0, trv_temp: 21.0, calibration: -8.0
2024-01-03 08:42:10.944 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: control_trv: window is open or status of window is unknown, setting window open
2024-01-03 08:42:10.944 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 08:42:10.944 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_temperature: climate.trv_bad_01 from: 21.0 to: 5.0
2024-01-03 08:42:10.951 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: climate.trv_bad_01 / check_target_temp / _last: 5.0 - _current: 21.0
2024-01-03 08:48:06.967 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 21.0 to 11.5
2024-01-03 08:48:06.967 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 5.0 - _new_heating_setpoint: 5.0 - _last_temperature: 5.0
2024-01-03 08:48:06.971 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 1.0 | external_temp: 21.0, trv_temp: 11.5, calibration: -8.0
2024-01-03 08:48:06.972 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 08:48:06.972 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 08:50:01.797 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 21.0 to 19.7
2024-01-03 08:50:01.802 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 0.0 | external_temp: 19.7, trv_temp: 11.5, calibration: -8.0
2024-01-03 08:50:01.802 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 08:50:01.802 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 08:52:20.825 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window closed, waiting 0 seconds before continuing
2024-01-03 08:52:20.832 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 1.3 - heating power: 0.0136 - expected valve position: 96%
2024-01-03 08:52:20.832 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 19.7, trv_temp: 11.5, calibration: -8.0
2024-01-03 08:52:20.832 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 08:52:20.832 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: control_trv: window is closed, setting window closed restoring mode: heat
2024-01-03 08:52:20.832 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_local_temperature_calibration: climate.trv_bad_01 from: -8.0 to: -9.0
2024-01-03 08:52:21.599 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 11.5 to 10.5
2024-01-03 08:52:23.842 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat btrv-bad-01: set_hvac_mode heat
2024-01-03 09:03:44.033 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 10.5 to 11.0
2024-01-03 09:03:44.034 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: calibration accepted by TRV climate.trv_bad_01
2024-01-03 09:04:33.439 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 19.7 to 20.1
2024-01-03 09:04:33.444 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.9 - heating power: 0.0136 - expected valve position: 66%
2024-01-03 09:04:33.444 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.1, trv_temp: 11.0, calibration: -9.0
2024-01-03 09:04:33.444 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 09:19:57.437 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 20.1 to 20.4
2024-01-03 09:19:57.444 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.6 - heating power: 0.0136 - expected valve position: 44%
2024-01-03 09:19:57.444 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.4, trv_temp: 11.0, calibration: -9.0
2024-01-03 09:19:57.444 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 09:20:03.185 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 11.0 to 12.0
2024-01-03 09:20:03.189 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.6 - heating power: 0.0136 - expected valve position: 44%
2024-01-03 09:20:03.189 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.4, trv_temp: 12.0, calibration: -9.0
2024-01-03 09:20:03.189 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 09:35:21.913 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 20.4 to 20.5
2024-01-03 09:35:21.920 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.5 - heating power: 0.0136 - expected valve position: 37%
2024-01-03 09:35:21.920 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.5, trv_temp: 12.0, calibration: -9.0
2024-01-03 09:35:21.920 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 10:21:20.848 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 20.5 to 20.4
2024-01-03 10:21:20.855 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.6 - heating power: 0.0136 - expected valve position: 44%
2024-01-03 10:21:20.855 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.4, trv_temp: 12.0, calibration: -9.0
2024-01-03 10:21:20.855 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-03 10:25:17.498 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 12.0 to 11.0

Debug logs from 1.5.0-beta3:


2024-01-07 15:45:26.471 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 22.0 to 23.0
2024-01-07 15:45:26.472 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: calibration accepted by TRV climate.trv_bad_01
2024-01-07 15:45:26.472 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-07 15:45:26.476 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -2.0 | external_temp: 21.2, trv_temp: 23.0, calibration: 0.0
2024-01-07 15:45:26.476 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_local_temperature_calibration: climate.trv_bad_01 from: 0.0 to: -2.0
2024-01-07 15:45:29.484 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat btrv-bad-01: set_hvac_mode heat
2024-01-07 15:45:34.876 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 23.0 to 21.0
2024-01-07 15:45:34.876 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: calibration accepted by TRV climate.trv_bad_01
2024-01-07 15:45:34.876 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-07 15:45:34.880 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -2.0 | external_temp: 21.2, trv_temp: 21.0, calibration: -2.0
2024-01-07 15:45:44.888 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 21.2 to 21.3
2024-01-07 15:45:44.895 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -2.0 | external_temp: 21.3, trv_temp: 21.0, calibration: -2.0
2024-01-07 15:56:48.933 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 21.0 to 20.0
2024-01-07 15:56:48.933 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-07 15:56:48.936 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -1.0 | external_temp: 21.3, trv_temp: 20.0, calibration: -2.0
2024-01-07 15:56:48.936 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_local_temperature_calibration: climate.trv_bad_01 from: -2.0 to: -1.0
2024-01-07 15:56:51.942 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat btrv-bad-01: set_hvac_mode heat
2024-01-07 16:22:02.382 DEBUG (MainThread) [custom_components.better_thermostat.utils.watcher] better_thermostat btrv-bad-01: binary_sensor.opensensor_bad_01_contact is unavailable. with state unavailable
2024-01-07 16:22:02.392 DEBUG (MainThread) [custom_components.better_thermostat.utils.watcher] better_thermostat btrv-bad-01: binary_sensor.opensensor_bad_01_contact is unavailable. with state unavailable
2024-01-07 16:22:09.076 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window state did not change, skipping event
2024-01-07 16:22:10.260 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-07 16:22:10.261 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window state did not change, skipping event
2024-01-07 16:22:10.261 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-07 16:22:10.266 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 0.0 | external_temp: 21.3, trv_temp: 20.0, calibration: -1.0
2024-01-07 16:22:13.267 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 0.0 | external_temp: 21.3, trv_temp: 20.0, calibration: -1.0
2024-01-07 16:24:15.845 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 21.0 - _new_heating_setpoint: 21.0 - _last_temperature: 21.0
2024-01-07 16:24:15.856 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 0.0 | external_temp: 21.3, trv_temp: 20.0, calibration: -1.0
2024-01-07 16:29:27.082 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window opened, waiting 0 seconds before continuing
2024-01-07 16:29:27.090 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 0.0 | external_temp: 21.3, trv_temp: 20.0, calibration: -1.0
2024-01-07 16:29:27.090 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: control_trv: window is open or status of window is unknown, setting window open
2024-01-07 16:29:27.090 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 16:29:27.090 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_temperature: climate.trv_bad_01 from: 21.0 to: 5.0
2024-01-07 16:29:27.099 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: climate.trv_bad_01 / check_target_temp / _last: 5.0 - _current: 21.0
2024-01-07 16:35:23.343 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 20.0 to 17.0
2024-01-07 16:35:23.343 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: calibration accepted by TRV climate.trv_bad_01
2024-01-07 16:35:23.343 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: trigger_trv_change test / _old_heating_setpoint: 5.0 - _new_heating_setpoint: 5.0 - _last_temperature: 5.0
2024-01-07 16:35:23.351 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 2.0 | external_temp: 21.3, trv_temp: 17.0, calibration: -2.0
2024-01-07 16:35:23.351 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 16:35:23.351 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 16:40:15.193 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 21.3 to 20.4
2024-01-07 16:40:15.200 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 1.0 | external_temp: 20.4, trv_temp: 17.0, calibration: -2.0
2024-01-07 16:40:15.200 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 16:40:15.200 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 16:44:27.824 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window closed, waiting 0 seconds before continuing
2024-01-07 16:44:27.832 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.6 - heating power: 0.0078 - expected valve position: 77%
2024-01-07 16:44:27.832 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.4, trv_temp: 17.0, calibration: -2.0
2024-01-07 16:44:27.832 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: sending 5°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 16:44:27.832 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: control_trv: window is closed, setting window closed restoring mode: heat
2024-01-07 16:44:27.832 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_local_temperature_calibration: climate.trv_bad_01 from: -2.0 to: -9.0
2024-01-07 16:44:28.519 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 17.0 to 10.0
2024-01-07 16:44:28.818 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window state did not change, skipping event
2024-01-07 16:44:30.843 DEBUG (MainThread) [custom_components.better_thermostat.adapters.generic] better_thermostat btrv-bad-01: set_hvac_mode heat
2024-01-07 16:50:25.269 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: TRV climate.trv_bad_01 sends new internal temperature from 10.0 to 9.5
2024-01-07 16:50:25.272 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat btrv-bad-01: calibration accepted by TRV climate.trv_bad_01

Screenshot from UI before window is opened and is set to heat: image

Screenshot from UI when window is opened (first working, second not working): image image

Screenshot from UI after window is closed:
image

Log when everything works as expected from 1.5.0-beta3:

2024-01-07 17:10:13.453 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat btrv-bad-01: external_temperature changed from 20.4 to 20.7
2024-01-07 17:10:13.460 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.3 - heating power: 0.0071 - expected valve position: 42%
2024-01-07 17:10:13.460 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.7, trv_temp: 11.0, calibration: -9.0
2024-01-07 17:10:17.357 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window opened, waiting 0 seconds before continuing
2024-01-07 17:10:17.364 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: 0.0 | external_temp: 20.7, trv_temp: 11.0, calibration: -9.0
2024-01-07 17:10:17.364 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: control_trv: window is open or status of window is unknown, setting window open
2024-01-07 17:10:17.364 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: sending 5.0°C to the TRV because this device has no system mode off and heater should be off
2024-01-07 17:10:17.364 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_temperature: climate.trv_bad_01 from: 21.0 to: 5.0
2024-01-07 17:10:17.372 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: climate.trv_bad_01 / check_target_temp / _last: 5.0 - _current: 21.0
2024-01-07 17:10:51.207 DEBUG (MainThread) [custom_components.better_thermostat.events.window] better_thermostat btrv-bad-01: Window closed, waiting 0 seconds before continuing
2024-01-07 17:10:51.212 DEBUG (MainThread) [custom_components.better_thermostat.utils.helpers] better_thermostat btrv-bad-01: climate.trv_bad_01 / heating_power_valve_position - temp diff: 0.3 - heating power: 0.0071 - expected valve position: 42%
2024-01-07 17:10:51.212 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat btrv-bad-01: climate.trv_bad_01 - new local calibration: -9.0 | external_temp: 20.7, trv_temp: 11.0, calibration: -9.0
2024-01-07 17:10:51.212 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: control_trv: window is closed, setting window closed restoring mode: heat
2024-01-07 17:10:51.212 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: TO TRV set_temperature: climate.trv_bad_01 from: 5.0 to: 21.0
2024-01-07 17:10:51.222 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat btrv-bad-01: climate.trv_bad_01 / check_target_temp / _last: 21.0 - _current: 5.0

Thank you!

dumbodumbos commented 9 months ago

Hello. I'm seeing the same problem. When you open the window, everything turns off correctly (the temperature is set to +5). When closing the window, the thermostat is still off

maparth commented 9 months ago

Hello,

I'd like to report that I am experiencing a similar issue as mentioned in this thread. The problem occurs with the TRVs not automatically turning on after closing the corresponding windows. Currently, they automatically and correctly turn off after opening the window, but upon closing the window, I have to manually turn them on again.

TRV Model: GS361A-H04 Integration: Zigbee2Mqtt Better Thermostat version: 1.4.0 Tested with Home Assistant version: 2023.10.5 and 2024.1.0

eugenkaltenegger commented 9 months ago

+1

TBSniller commented 7 months ago

Found the corresponding line which is reasonable for this issue: https://github.com/KartoffelToby/better_thermostat/blob/6a349d9c54772395a06d3dc79c41a566106f9f71/custom_components/better_thermostat/events/trv.py#L206 Replacing it with a logger line confirms that it would mostly switch the BT off when a window is opened and now everything is working fine for me.

As looking at the code I guess it is to reflect the current state of the real trv, but it was forgotten that it can't be turned back on again due to https://github.com/KartoffelToby/better_thermostat/blob/6a349d9c54772395a06d3dc79c41a566106f9f71/custom_components/better_thermostat/events/trv.py#L160

@KartoffelToby Whats the real purpuse of this and are these lines really needed? Maybe it should never be that the integration is controlling its own hvac_state https://github.com/KartoffelToby/better_thermostat/blob/6a349d9c54772395a06d3dc79c41a566106f9f71/custom_components/better_thermostat/events/trv.py#L204-L209

Btw should be same issue to #1270 Please let me know if I can do something more to help Thanks!