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
727 stars 123 forks source link

BT Task Exception on new install with EcoBee thermostat #1253

Open TallGeekyCool opened 6 months ago

TallGeekyCool commented 6 months ago

Home Assistant Blue / Hardkernel ODROID-N2/N2+

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.1.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.6", "docker": true, "arch": "aarch64", "timezone": "America/Chicago", "os_name": "Linux", "os_version": "6.1.71-haos", "supervisor": "2023.12.1", "host_os": "Home Assistant OS 11.4", "docker_version": "24.0.7", "chassis": "embedded", "run_as_root": true }, "custom_components": { "smartthinq_sensors": { "version": "0.36.2", "requirements": [ "pycountry>=20.7.3", "xmltodict>=0.12.0", "charset_normalizer>=2.0.0" ] }, "teamtracker": { "version": "0.1", "requirements": [ "arrow", "aiofiles" ] }, "smartthinq": { "version": "1.0.0", "requirements": [ "wideq>=1.4.0" ] }, "tdarr": { "version": "1.13", "requirements": [] }, "battery_notes": { "version": "1.4.0", "requirements": [] }, "hacs": { "version": "1.33.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "smartsleep": { "version": "4.0.0.1", "requirements": [ "pysomneo>=2.5.2,<4" ] }, "auto_areas": { "version": "2.0.0", "requirements": [] }, "adaptive_lighting": { "version": "1.20.0", "requirements": [ "ulid-transform" ] }, "holidays": { "version": "1.9.10", "requirements": [ "python-dateutil>=2.8.2", "holidays>=0.35" ] }, "sonos_cloud": { "version": "0.3.5", "requirements": [] }, "better_thermostat": { "version": "1.4.0", "requirements": [] }, "alexa_media": { "version": "4.9.0", "requirements": [ "alexapy==1.27.10", "packaging>=20.3", "wrapt>=1.14.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.4.0", "is_built_in": false }, "data": { "info": { "name": "Better Thermostat", "temperature_sensor": "sensor.my_ecobee3_temperature", "off_temperature": 20, "tolerance": 0.0, "cooler": "climate.my_ecobee3", "humidity_sensor": "sensor.my_ecobee3_humidity", "outdoor_sensor": "sensor.front_door_outside_module_temperature_2", "window_sensors": null, "weather": null, "window_off_delay": 0, "window_off_delay_after": 0, "model": "ecobee3 Smart Thermostat" }, "thermostat": { "climate.my_ecobee3": { "name": "My ecobee3", "state": "heat_cool", "attributes": { "hvac_modes": [ "heat_cool", "heat", "cool", "off" ], "min_temp": 44.6, "max_temp": 95.0, "target_temp_step": 0.5, "fan_modes": [ "auto", "on" ], "preset_modes": [ "Away", "Home", "Sleep" ], "current_temperature": 67.7, "temperature": null, "target_temp_high": 74.0, "target_temp_low": 68.0, "current_humidity": 28, "fan_mode": "auto", "hvac_action": "idle", "preset_mode": "Home", "fan": "off", "climate_mode": "Home", "equipment_running": "", "fan_min_on_time": 5, "friendly_name": "My ecobee3", "supported_features": 27 }, "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": "ecobee", "bt_integration": "ecobee", "model": "ecobee3 Smart Thermostat" } }, "external_temperature_sensor": { "entity_id": "sensor.my_ecobee3_temperature", "state": "62.6", "attributes": { "state_class": "measurement", "unit_of_measurement": "\u00b0F", "device_class": "temperature", "friendly_name": "My ecobee3 Temperature" }, "last_changed": "2024-01-17T21:00:18.071287+00:00", "last_updated": "2024-01-17T21:00:18.071287+00:00", "context": { "id": "01HMCKK2RQPRXTZ10RDBR5RJP2", "parent_id": null, "user_id": null } }, "window_sensor": "-" } }

Description

Better Thermostat never starts properly with EcoBee thermostat

Steps to Reproduce

  1. Install the Better Thermostat according to the https://better-thermostat.org/ instructions
  2. Restart Home Assistant but the Better Thermostat is "unavailable

Expected behavior:

I expect Better Thermostat to be available :-)

Actual behavior:

The better Thermostat is listed as "unavailable" in HA

Versions

HA version: Core 2024.1.3 Supervisor 2023.12.1 Operating System 11.4 Frontend 20240104.0 BT version: 1.4.0

Additional Information

From the logs in HA: This error originated from a custom integration.

Logger: homeassistant Source: custom_components/better_thermostat/utils/controlling.py:112 Integration: Better Thermostat (documentation, issues) First occurred: January 13, 2024 at 4:20:53 PM (1 occurrences) Last logged: January 13, 2024 at 4:20:53 PM

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/better_thermostat/climate.py", line 833, in startup await control_trv(self, trv) File "/config/custom_components/better_thermostat/utils/controlling.py", line 112, in control_trv self.cur_temp >= self.bt_target_cooltemp - self.tolerance


TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
wtom commented 6 months ago

For now, remove the devise as AC, then it should work.

TallGeekyCool commented 6 months ago

Should I remove EcoBee or Better Thermostat? "the device" is a little vague

ajaxbits commented 3 months ago

Also reporting this issue:

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.4.4",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.2",
    "docker": true,
    "arch": "aarch64",
    "timezone": "America/Chicago",
    "os_name": "Linux",
    "os_version": "6.1.73-haos-raspi",
    "supervisor": "2024.04.0",
    "host_os": "Home Assistant OS 12.2",
    "docker_version": "25.0.5",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "var": {
      "version": "0.15.3",
      "requirements": []
    },
    "vesync": {
      "version": "1.3.0",
      "requirements": [
        "pyvesync==2.1.10"
      ]
    },
    "watchman": {
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "sun2": {
      "version": "3.2.1",
      "requirements": []
    },
    "lightener": {
      "version": "v2.3.0",
      "requirements": []
    },
    "adaptive_lighting": {
      "version": "1.21.1",
      "requirements": [
        "ulid-transform"
      ]
    },
    "thermal_comfort": {
      "version": "2.2.2",
      "requirements": []
    },
    "better_thermostat": {
      "version": "1.5.1",
      "requirements": []
    },
    "powercalc": {
      "version": "v1.11.8",
      "requirements": [
        "numpy>=1.21.1"
      ]
    },
    "battery_notes": {
      "version": "2.2.7",
      "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.5.1",
    "is_built_in": false
  },
  "data": {
    "info": {
      "name": "Central Air",
      "temperature_sensor": "sensor.main_temperature_sensor_temperature",
      "off_temperature": 20,
      "tolerance": 0.0,
      "target_temp_step": 0.0,
      "cooler": "climate.thermostat",
      "humidity_sensor": "sensor.main_temperature_sensor_humidity",
      "weather": null,
      "window_sensors": null,
      "outdoor_sensor": null,
      "window_off_delay": 0,
      "window_off_delay_after": 0,
      "model": "3157100"
    },
    "thermostat": {
      "climate.thermostat": {
        "name": "Thermostat",
        "state": "off",
        "attributes": {
          "hvac_modes": [
            "off",
            "heat",
            "cool",
            "emergency_heating"
          ],
          "min_temp": 45,
          "max_temp": 86,
          "target_temp_step": 1.0,
          "fan_modes": [
            "auto",
            "on"
          ],
          "current_temperature": 76,
          "target_temp_high": 73,
          "target_temp_low": 73,
          "fan_mode": "auto",
          "hvac_action": "idle",
          "friendly_name": "Thermostat",
          "supported_features": 394
        },
        "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": "mqtt",
        "bt_integration": "mqtt",
        "model": "3157100"
      }
    },
    "external_temperature_sensor": {
      "entity_id": "sensor.main_temperature_sensor_temperature",
      "state": "73.8",
      "attributes": {
        "state_class": "measurement",
        "unit_of_measurement": "\u00b0F",
        "device_class": "temperature",
        "friendly_name": "Main Temperature Sensor Temperature"
      },
      "last_changed": "2024-04-30T01:15:34.745527+00:00",
      "last_reported": "2024-04-30T01:15:34.746926+00:00",
      "last_updated": "2024-04-30T01:15:34.745527+00:00",
      "context": {
        "id": "01HWP94HESENXECCHVFA2FCAJG",
        "parent_id": null,
        "user_id": null
      }
    },
    "window_sensor": "-"
  }
}
ajaxbits commented 3 months ago

@TallGeekyCool, I found the cause for my issue.

My thermostat is hooked up via Zigbee2MQTT and exposes its temperature reading as current_temperature as a value on its HASS state.

I changed this line in climate.py in my custom_components directory on my HA server to get its value from the proper current_temperature key, instead of the temperature key:

if self.cooler_entity_id is not None:
    self.bt_target_cooltemp = convert_to_float(
        str(
            self.hass.states.get(self.cooler_entity_id).attributes.get(
                "current_temperature" # <- MY CHANGE HERE
            )
        ),
        self.name,
        "startup()",
    )

I would make a PR, but I'm wondering, @KartoffelToby, what the best way to handle this situation is. Thanks!