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
834 stars 126 forks source link

Target temperature changing at random #1387

Open kbunto opened 2 months ago

kbunto commented 2 months ago

Disclaimer: My first bug report, will updated with other information if I missed the mark here. May also be resolved if anyone know where I can find the trigger for target temperature changes in BT.

Prerequisites

hvac_modes: heat, off min_temp: 5 max_temp: 30 target_temp_step: 0.5 preset_modes: none current_temperature: 26.3 temperature: 25 hvac_action: idle preset_mode: none window_open: false call_for_heat: true last_change: 2024-09-09T08:27:01.815908 saved_temperature: null humidity: 53 main_mode: off tolerance: 0 heating_power: 0.0115 errors: [] batteries: {"sensor.bathroom_air_temperature": {"battery": "77", "battery_id": "sensor.bathroom_air_battery"}, "sensor.bathroom_air_humidity": {"battery": "77", "battery_id": "sensor.bathroom_air_battery"}, "climate.bathroom_floor": {"battery": "31", "battery_id": "sensor.bathroom_floor_battery"}} friendly_name: Bathroom_floor_virtual supported_features: 401

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.9.1",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.4",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Oslo",
    "os_name": "Linux",
    "os_version": "6.6.46-haos",
    "supervisor": "2024.08.0",
    "host_os": "Home Assistant OS 13.1",
    "docker_version": "26.1.4",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "better_thermostat": {
      "documentation": "https://github.com/KartoffelToby/better_thermostat",
      "version": "1.6.0",
      "requirements": []
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "2.0.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "nordpool": {
      "documentation": "https://github.com/custom-components/nordpool/",
      "version": "0.0.14",
      "requirements": [
        "nordpool>=0.2",
        "backoff"
      ]
    },
    "home_connect_alt": {
      "documentation": "https://github.com/ekutner/home-connect-hass",
      "version": "1.1.7",
      "requirements": [
        "home-connect-async==0.8.0"
      ]
    }
  },
  "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.6.0",
    "is_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 0.0001070479629561305
    },
    "636449213170863fc7f034ab12afd6fe": {
      "wait_import_platforms": -1.7203250619932078,
      "config_entry_setup": 1.863598430994898
    },
    "c619aad3aa64d82a61e7679af01d5717": {
      "wait_import_platforms": -1.8634021090110764,
      "config_entry_setup": 1.871203135990072
    }
  },
  "data": {
    "info": {
      "name": "Bathroom_floor_virtual",
      "temperature_sensor": "sensor.bathroom_air_temperature",
      "tolerance": 0.0,
      "target_temp_step": 0.0,
      "humidity_sensor": "sensor.bathroom_air_humidity",
      "weather": "weather.forecast_home_2",
      "off_temperature": 25,
      "window_sensors": null,
      "outdoor_sensor": null,
      "cooler": null,
      "window_off_delay": 0,
      "window_off_delay_after": 0,
      "model": "SRTS-A01"
    },
    "thermostat": {
      "climate.bathroom_floor": {
        "name": "Bathroom_floor",
        "state": "heat",
        "attributes": {
          "hvac_modes": [
            "off",
            "heat"
          ],
          "min_temp": 5.0,
          "max_temp": 30.0,
          "target_temp_step": 0.5,
          "preset_modes": [
            "none",
            "manual",
            "away",
            "auto"
          ],
          "current_temperature": 30.4,
          "temperature": 29.5,
          "preset_mode": "manual",
          "friendly_name": "Bathroom_floor",
          "supported_features": 401
        },
        "bt_config": {
          "calibration": "target_temp_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": "mqtt",
        "bt_integration": "mqtt",
        "model": "SRTS-A01"
      }
    },
    "external_temperature_sensor": {
      "entity_id": "sensor.bathroom_air_temperature",
      "state": "26.3",
      "attributes": {
        "state_class": "measurement",
        "unit_of_measurement": "\u00b0C",
        "device_class": "temperature",
        "friendly_name": "Bathroom_air Temperature"
      },
      "last_changed": "2024-09-09T11:14:50.238617+00:00",
      "last_reported": "2024-09-09T11:14:50.238617+00:00",
      "last_updated": "2024-09-09T11:14:50.238617+00:00",
      "context": {
        "id": "01J7B7WP7YQPQZ3NSK0VFNR0KA",
        "parent_id": null,
        "user_id": null
      }
    },
    "window_sensor": "-"
  }
}

Description

Target temperature changing to 30 deg. C at seemingly random times. Strangely it only happens for one of two SRTS-A01 in my better thermostat setup.

Steps to Reproduce

Unknown, happens rarely and I have not found a pattern.

Expected behavior:

Target temperature to stay where it should.

Actual behavior:

Target temperature changes at seemingly random times to 30 deg. C.

Versions

BT: 1.6.0 HA: 2024.9.1

Additional Information

maglat commented 1 month ago

Same hardware (Aqara SRTS-A01) + same HA version + same issue. Target temperature is set to 22C. Value randomly change to 5C, to 27C. Heating mod change from heating to off randomly.

kbunto commented 1 month ago

Same hardware (Aqara SRTS-A01) + same HA version + same issue. Target temperature is set to 22C. Value randomly change to 5C, to 27C. Heating mod change from heating to off randomly.

+5 seems logical, my setpoint is 25 and temperature was changed to 30.

wtom commented 1 month ago

Activate child lock on the BT settings should fix it.

maglat commented 1 month ago

Activate child lock on the BT settings should fix it.

looks like this fixed it for me. what about the temperature sensor setting. keep internal or set to external. I set to external so when internal, the thermostat do not reduce heating on a wrong room temperature. I am aware that the external only is meant for the aqara native integration and setting to external inside home assistant wont receive any temperature data. what i disabled as well is the window detection which is handled by better thermostat as well.

kbunto commented 1 month ago

Activate child lock on the BT settings should fix it.

looks like this fixed it for me. what about the temperature sensor setting. keep internal or set to external. I set to external so when internal, the thermostat do not reduce heating on a wrong room temperature. I am aware that the external only is meant for the aqara native integration and setting to external inside home assistant wont receive any temperature data. what i disabled as well is the window detection which is handled by better thermostat as well.

Regarding setting temperature sensor to external and thus preventing HA/BT to recieve the temperature reading from the thermostat. How then does the thermostat active? Does not BT achieve this by manipulating the setpoint in reference to the reported temperature from the actuator?

Im interested in a definite answer for this as my actuator is mounted in a technical closet where the temperature sometimes is above 30 degree - exceeding the maximum setpoint of the actuator and thus preventing it from turning on the heating.

--- EDIT --- LIKELY SOLUTION ---

Realized after typing out my question that I can achieve what I want by setting the temperature sensor in Z2M to external and using the slider to set the temperature to a static 20 degrees.

tco99ttocs commented 1 month ago

got similar problem with version 1.6 and 1.4, but with avm 301 and external tuya sensors. It randomly switches the target temperature. But there is a fix temperature, where he is goining back, its the target temp which is set from AVM in the 301. The workaround with enabeling the child lock in BT didn't work

KartoffelToby commented 1 week ago

BT will change the Target temp based on the Sensor and TRV data, this is how it works ;) but sometime devices make false true events, so the childlock "hack" work, but the childlock shoud be enabled on the org. device. if someone can provide better logs i can figure out whats wrong.

antstorm commented 6 days ago

I'm also experiencing this issue. My setup is a bit more complex with the scheduler-component used to drive the target temperatures, however it feels like scheduler is not the one causing this.

Here's the schedule with 4 expected trigger events throughout the day: Screenshot 2024-11-05 at 12 34 10

Here's what the actual target temperature looks like with 4 unexpected changes: Screenshot 2024-11-05 at 12 32 57

Please let me know if there's any logs that I can try to dig out. From what I saw — only a few changes appear in the logbook, but have zero context associated (what and why caused the change).

P.S. Thanks a lot for building and maintaining this addon, extremely useful for UFH and TRVs.

antstorm commented 6 days ago

Ok, I've enabled debug logging and managed to get the logs for a random temperature change. Based on the scheduler my target temperature changed from 19C to 17C at 16:00, but then a minute later went up to 17.5C for no apparent reason:

Screenshot 2024-11-05 at 16 42 19

And here are the relevant log entries:

2024-11-05 16:00:00.001 DEBUG (MainThread) [custom_components.better_thermostat.climate] better_thermostat Downstairs Study Thermostat: HA set target temperature to 17.0 & None
2024-11-05 16:00:00.002 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.downstairs_study_trv - new setpoint calibration: 17.5 | external_temp: 20.3, target_temp: 17.0, trv_temp: 20.4
2024-11-05 16:00:00.002 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_temperature: climate.downstairs_study_trv from: 19.5 to: 17.5
2024-11-05 16:00:00.018 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: climate.downstairs_study_trv / check_target_temp / _last: 17.5 - _current: 17.5
2024-11-05 16:01:15.324 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat None: external_temperature changed from 20.3 to 20.2
2024-11-05 16:01:15.325 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.downstairs_study_trv - new setpoint calibration: 17.0 | external_temp: 20.2, target_temp: 17.0, trv_temp: 20.4
2024-11-05 16:01:15.325 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: TO TRV set_temperature: climate.downstairs_study_trv from: 17.5 to: 17.0
2024-11-05 16:01:15.339 DEBUG (MainThread) [custom_components.better_thermostat.utils.controlling] better_thermostat None: climate.downstairs_study_trv / check_target_temp / _last: 17.0 - _current: 17.0
2024-11-05 16:01:31.902 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat None: trigger_trv_change test / _old_heating_setpoint: 17.0 - _new_heating_setpoint: 17.5 - _last_temperature: 17.0
2024-11-05 16:01:31.902 DEBUG (MainThread) [custom_components.better_thermostat.events.trv] better_thermostat None: TRV climate.downstairs_study_trv decoded TRV target temp changed from 17.0 to 17.5
2024-11-05 16:01:31.903 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.downstairs_study_trv - new setpoint calibration: 17.5 | external_temp: 20.2, target_temp: 17.5, trv_temp: 20.4
2024-11-05 16:02:45.325 DEBUG (MainThread) [custom_components.better_thermostat.events.temperature] better_thermostat None: external_temperature changed from 20.2 to 20.3
2024-11-05 16:02:45.325 DEBUG (MainThread) [custom_components.better_thermostat.calibration] better_thermostat None: climate.downstairs_study_trv - new setpoint calibration: 17.5 | external_temp: 20.3, target_temp: 17.5, trv_temp: 20.4

The question is — what does decoded TRV target temp changed from 17.0 to 17.5 mean and why did it happen? From the looks of the log message it's related to the TRV, but at the same exact timestamp (down to second) the target temperature of the BT got updated.