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
714 stars 124 forks source link

Heating won`t start (hvac_mode: heat) after turned OFF by dashboard/ window sensor or automation with SET hvac_mode: OFF #1141

Open ChristophFeile opened 8 months ago

ChristophFeile commented 8 months ago

Prerequisites

{
 {
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2023.7.0.dev20230626",
    "dev": true,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "5.15.84-v8+",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.33.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "scheduler": {
      "version": "v0.0.0",
      "requirements": []
    },
    "better_thermostat": {
      "version": "1.4.0",
      "requirements": []
    }
  },
  "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.4.0",
    "is_built_in": false
  },
  "data": {
    "info": {
      "name": "Better Thermostat Bathroom",
      "temperature_sensor": "sensor.thermometer_bad_temperature",
      "off_temperature": 20,
      "tolerance": 0.0,
      "humidity_sensor": "sensor.thermometer_bad_humidity",
      "window_sensors": "binary_sensor.fensterkontakt_bad_opening",
      "weather": "weather.openweathermap",
      "outdoor_sensor": null,
      "cooler": null,
      "window_off_delay": 0,
      "window_off_delay_after": 0,
      "model": "TS0601"
    },
    "thermostat": {
      "climate.heizung_bad_thermostat": {
        "name": "Heizung Bad Thermostat",
        "state": "heat",
        "attributes": {
          "hvac_modes": [
            "off",
            "heat"
          ],
          "min_temp": 10.0,
          "max_temp": 30.5,
          "current_temperature": 22.3,
          "temperature": 19.5,
          "hvac_action": "idle",
          "system_mode": "[<SystemMode.Heat: 4>]/heat",
          "occupancy": 1,
          "occupied_heating_setpoint": 1950,
          "friendly_name": "Heizung Bad Thermostat",
          "supported_features": 1
        },
        "bt_config": {
          "calibration": "local_calibration_based",
          "calibration_mode": "heating_power_calibration",
          "protect_overheating": false,
          "no_off_system_mode": false,
          "heat_auto_swapped": false,
          "child_lock": false,
          "homaticip": false
        },
        "bt_adapter": "zha",
        "bt_integration": "zha",
        "model": "TS0601"
      }
    },
    "external_temperature_sensor": {
      "entity_id": "sensor.thermometer_bad_temperature",
      "state": "21.2",
      "attributes": {
        "state_class": "measurement",
        "unit_of_measurement": "\u00b0C",
        "device_class": "temperature",
        "friendly_name": "Thermometer Bad Temperature"
      },
      "last_changed": "2023-11-13T19:31:23.480906+00:00",
      "last_updated": "2023-11-13T19:31:23.480906+00:00",
      "context": {
        "id": "01HF52NJ6R93TNH9G2KCNEGRGD",
        "parent_id": null,
        "user_id": null
      }
    },
    "window_sensor": {
      "entity_id": "binary_sensor.fensterkontakt_bad_opening",
      "state": "off",
      "attributes": {
        "migrated_to_cache": true,
        "device_class": "opening",
        "friendly_name": "Fensterkontakt Bad Opening"
      },
      "last_changed": "2023-11-13T19:31:23.429832+00:00",
      "last_updated": "2023-11-13T19:31:23.429832+00:00",
      "context": {
        "id": "01HF52NJ55GG46EC80FM5GVAZJ",
        "parent_id": null,
        "user_id": null
      }
    }
  }
}
}

Description

When heating is turned OFF (by Window opening or OFF switch in Dashboard), it will not turn on to "heat" when window is closed or HEating button pressd on dahsboard.

Steps to Reproduce

  1. open window / press OFF on dashboard or in automation with entity better thermostat type: set_hvac_mode hvac_mode: 'off'
  2. close window/ press ON on dahsboard or in automation with entity better thermostat type: set_hvac_mode hvac_mode: heat

  3. check on thermostat on heating, it´s still shows "OFF" dashboard shows "heating"even thermostat is still "OFF"

Expected behavior: thermostat turns ON

checking integration with standard thermostat device "climate.heizung_bad_thermostat" and dahsboard it works like expected dashboard / on/ off or also in automation with. type: set_hvac_mode hvac_mode: 'off' type: set_hvac_mode hvac_mode: heat Works as expected

heating turns ob with hvac_mode: heat Actual behavior: heating still remains OFF with " hvac_mode: heat"

Versions

Additional Information

acid115 commented 8 months ago

Yes, the code is buggy. You have to change the code and set mode to heat on every temperature set.... It is easy and it works. Dont know why the code owner does not fix this....

GravitySandwichh commented 8 months ago

Experiencing a somewhat similar issue with these thermostats. BetterThermostat is turning off my heaters at random causing my house to be freezing. I had to make an automation that keeps turning it back on but it's really annoying.

image image

ChristophFeile commented 8 months ago

Yes, the code is buggy. You have to change the code and set mode to heat on every temperature set.... It is easy and it works. Dont know why the code owner does not fix this....

That is good to know, that it´s easy to fix. Can you remeber what file needs to be edited and do you have a code? One of the files in the main folder of better_thermostat? image

acid115 commented 8 months ago

Yes, climate.py I did some changes, that work for me. My BTs doesnt change to hvacmode=off randomly anymore, except if window/door is open. That is a big problem a lot of people have. I use a schedule to change the temperature over the day, or when i leave my home, or if no motion is detected in a room, but i dont need to switch off. So every temp change results in a hvacmode=heat. Also if the hvacmode is unknown (default was off), i beleave that this is the problem why the software switches to off randomly. And i have set the max temperature of the real trvs from 30/35 to a fixed value of 25, because 30 is too high for me (overheating sometimes).

You can download the file here: https://file.io/kvtrPCyEn2Aa

Compare it with your version and merge the lines you need.

wtom commented 8 months ago

Yes, the code is buggy. You have to change the code and set mode to heat on every temperature set.... It is easy and it works. Dont know why the code owner does not fix this....

It's open source, everyone can create a PR and it's more than welcome.

ChristophFeile commented 8 months ago

Yes, climate.py I did some changes, that work for me. My BTs doesnt change to hvacmode=off randomly anymore, except if window/door is open. That is a big problem a lot of people have. I use a schedule to change the temperature over the day, or when i leave my home, or if no motion is detected in a room, but i dont need to switch off. So every temp change results in a hvacmode=heat. Also if the hvacmode is unknown (default was off), i beleave that this is the problem why the software switches to off randomly. And i have set the max temperature of the real trvs from 30/35 to a fixed value of 25, because 30 is too high for me (overheating sometimes).

You can download the file here: https://file.io/kvtrPCyEn2Aa

Compare it with your version and merge the lines you need.

Thanks for the code. I will try

acid115 commented 8 months ago

Forget it, i have some trouble now with these changes.... The real trvs does not really stop heating, if target temp is reached. BT sets the target temp of real trv to the current temp of the real trv, if bt-target-temp is smaller than messured temp by ext. temperature sensor.

Now i have ti find out, why the hvacmode switches off sometimes...randomly...

ChristophFeile commented 8 months ago

Forget it, i have some trouble now with these changes.... The real trvs does not really stop heating, if target temp is reached. BT sets the target temp of real trv to the current temp of the real trv, if bt-target-temp is smaller than messured temp by ext. temperature sensor.

Now i have ti find out, why the hvacmode switches off sometimes...randomly...

Yes I can agree, I tested and it´s no difference

I added This at line 161: ... self.bt_hvac_mode = HVACMode.HEAT .. [Code] and another section similar.

Also after HVACmode=OFF, the TRV didn´t turn to Heat again

ChristophFeile commented 8 months ago

After no sucess with this: self.bt_hvac_mode = HVACMode.HEAT I tested following as service:

climate.set_hvac_mode hvac_mode: Off on BT entity -> as aspected TRV OFF climate.set_hvac_mode hvac_mode: Heat on BT entity -> reaction: dashboard shows Heating ON, but TRV stays OFF

now tested climate.set_hvac_mode hvac_mode: Heat on REAL entity of TRV -> TRV turns ON to HEAT

I gues there is some bug in the implementation of climate.set_hvac_mode hvac_mode: Heat in the better thermostat code.

Does anybody knows where to fix?

ChristophFeile commented 7 months ago

OK, my workaraound, I created an automation that watches the window opening sensor. If it´s closed, it calls a service to set HVAC mode to HEAT of the real TRV. If someone knows how to fix directly in Better thermostat I apreciate.

Kaot93 commented 7 months ago

I'm having the same problem, bypassed it by writing an automation.

But also I can't use overheating protection due to this bug, if BT switches off the thermostat it stays off.

Secret0007 commented 7 months ago

OK, my workaraound, I created an automation that watches the window opening sensor. If it´s closed, it calls a service to set HVAC mode to HEAT of the real TRV. If someone knows how to fix directly in Better thermostat I apreciate.

Hello Christoph,

I have the same problem with my following combination:

I have also reported the problem in detail here:

https://community.simon42.com/t/problem-mit-kombination-bosch-hkt-ii-hacs-bosch-shc-tschamm-integration-better-thermostat/12931

Can you tell me where you installed your workaround? Maybe you can give me the code?

Many thanks for your help.

ChristophFeile commented 7 months ago

Hey Secret007, thats quiet easy. Just over the GUI, you need no code. Create an automation. Watch your window contact, if closed, set climate HVAC mode to heat. But important, you have to use the real thermostat, NOT the better thermostat.

image

MetroAffe commented 7 months ago

This only happens to me when external room temperature sensors are set up. Without them, everything works great. Could you please test this scenario as well?

ChristophFeile commented 6 months ago

I tested, I removed external temperature sensor from better thermostat entity. The behavior changed, when opening the window, the thermostat was NOT turned OFF, but also did not reduced temperature. Different, but not what expected.

Peviox commented 5 months ago

i have the same problem with my ts0601. when i open the window the hvac mode stays at "heating" for a random amount of time and at some point changes to "off" and doesnt turn back on. this also happens randomly throughout the day. mainly when the target is lower than the current externally meassured temperature (when turning down the temp e.g. at night). my workaround for this is a very simple automation, that listens to the hvac mode of each BT entity and if it changes to off, it changes back to on a second later. its not a nice solution to a problem, that shouldnt exist but it works. the biggest problem is, that if the trv is on and this problem occours, even tho the mode changes a second later the trv fully closes and opens back up. from the log files i cant make out why this happens

grafik

my automation:

alias: turn BT AZ to heat
description: ""
trigger:
  - platform: state
    entity_id:
      - climate.bt_az
    for:
      hours: 0
      minutes: 0
      seconds: 1
    to: "off"
condition: []
action:
  - device_id: e2e179e45ab1be059621b2077232f35f
    domain: climate
    entity_id: eafb58f4a0d4ca2d1da9eca01122b417
    type: set_hvac_mode
    hvac_mode: heat
mode: single