Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermostats unavailable with Z2M v2.0.0 #1549

Open
SpencersGithub opened this issue Jan 5, 2025 · 28 comments
Open

Thermostats unavailable with Z2M v2.0.0 #1549

SpencersGithub opened this issue Jan 5, 2025 · 28 comments
Assignees
Labels

Comments

@SpencersGithub
Copy link

This morning all my BT thermostats were grayed out.
The physical thermostats are still working and I can control the temperature through them.
HA version 2025.1 and Zigbee2MQTT 2.0.0.
BT thermostats were still working after the current HA and Zigbee2MQTT upgrades.
Thermostats used are Aqara SRTS-A01 and Bosch BTH-RA.
Updating to 1.7.0-Beta2 did not fix the issue.
I added a new BT thermostat (Test 2) for testing and it was also grayed out, can be seen in the log file.

config_entry-better_thermostat-01JGTQRBXQ9A37YEEKNGHGG9WP.json

home-assistant_better_thermostat_2025-01-05T08-02-19.154Z.log

@SpencersGithub SpencersGithub added the new bug incoming bug issue label Jan 5, 2025
@ianfab2000
Copy link

I got the same issue after I updated to HA 2025.1.

@SpencersGithub
Copy link
Author

They have partially come back.
3 rooms are fully working now plus the test device that was grayed out earlier.
1 room is still showing unavailable and 1 room is showing available but adjusting doesn't do anything.

@ianfab2000
Copy link

Any actions from your side to get them back working?

@SpencersGithub
Copy link
Author

No, first they turned gray and 3 hours later some of them came back, 2 of them are still not working.

@dannykorpan
Copy link

Same problem here, after update to 2025.1.

@SpencersGithub
Copy link
Author

Did some more testing by removing and re-adding BT thermostats.
It seems (at least some of) my problems were related to the setting "Your weather entity to get the outdoor temperature". There I have the choice between weather.home and weather.openweathermap. If I choose openweathermap the new added BT thermostat will be grayed out.
This does not explain of course why all BT thermostats were working this morning when I got up and 30 minutes later they were grayed out.

@KartoffelToby
Copy link
Owner

I testing HA 2025.1 with z2m 2.0 and 1.7.0 Beta for a while.

For me every works fine so far.

As i can tell you from a first quick look its you window sensor thats not online in ha.

Can you Check the Sensor in z2m and ha?

@KartoffelToby
Copy link
Owner

Some bug that i had in the first place was that the Option Home Assistent Integration in z2m was not working, even if the enable Checkbox was checkt. A simple toggle of, save, and toggle on save fixed it for me

@SpencersGithub
Copy link
Author

I testing HA 2025.1 with z2m 2.0 and 1.7.0 Beta for a while.

For me every works fine so far.

As i can tell you from a first quick look its you window sensor thats not online in ha.

Can you Check the Sensor in z2m and ha?

Unfortunately all the BT thermostats are working again at this point. I checked the window sensors and all are online.
I may need to wait until something fails again.
I will also try the the toggle/save next time.
At least now I have a better idea what to look for.
Thanks so far.

@uwen70
Copy link

uwen70 commented Jan 5, 2025

I have the same problem. First installation of BT today.
HA 2025.1, z2m 2.0, BT 1.7.0-beta2

The log shows a new start of HA and the following config of an BT thermostat.
home-assistant(1).log
config_entry-better_thermostat-01JGW6X5VPY1R8PQ25Z9HJF5VF.json

@ZenHgita
Copy link

ZenHgita commented Jan 6, 2025

I consistently encounter this issue whenever I update or restart HA: all thermostats become unavailable. What works for me—though it’s quite annoying—is manually reconfiguring each thermostat. I delete the outside temperature sensor, save the settings, and the thermostat in question usually reappears. After that, I re-enable the outside temperature sensor. Most of the time, it works on the first try.

@folfy
Copy link
Collaborator

folfy commented Jan 6, 2025

@uwen70 Thanks, the log file is very important and helpful.
Anyone else having issues, please also provide log-files, or it will not be possible to figure out the common cause. So far it seems to be related to Z2M actually not initializing correctly, which might be an actual Z2M bug, or an issue in BT just not getting updated that the entities are available.

2025-01-05 22:49:04.464 INFO (MainThread) [custom_components.better_thermostat.adapters.mqtt] better_thermostat BT Wohnzimmer: waiting for TRV/climate entity with id 'number.thermostat_wohnzimmer_local_temperature_calibration' to become fully available...
@uwen70 Can you verify if the entity "number.thermostat_wohnzimmer_local_temperature_calibration" is actually available when you're having issues (i.e. it's an issue in BT), or if it's actually a problem with the entity on Z2M side, it rly being not available?

@SpencersGithub
Copy link
Author

I just restarted HA and all BT thermostats were grayed out again.
If you look for example at the last line in the log file, it was waiting for 'binary_sensor.badezimmer_fenster_contact'
home-assistant_better_thermostat_2025-01-06T12-48-00.332Z.log

The sensor was present in Z2M
Screenshot_20250106_135025

But not in HA
Screenshot_20250106_134947

I did what you recommend and disabled/enabled HA Integration in Z2M and all BT thermostats came back online.

@folfy
Copy link
Collaborator

folfy commented Jan 6, 2025

@SpencersGithub Thanks, so at least in your case it looks like a true Z2M bug then, not BT being at fault.

@KartoffelToby Maybe we can throw a "repair" indication to HA at some point, i.e. after waiting 60s for something? So users at least see what's going wrong / why BT is not working. I'd implement it, but first I have to get more familiar with the HA API for this 😐

@KartoffelToby
Copy link
Owner

@folfy That's a great idea! It's something I've wanted to work on for a long time. Currently, BT only throws errors if some devices go "offline" while it's running.

offtopic: can you ping me on discord, we can connect there, and i can set you as an Contributor in the BT Server too.

@uwen70
Copy link

uwen70 commented Jan 6, 2025

@uwen70 Can you verify if the entity "number.thermostat_wohnzimmer_local_temperature_calibration" is actually available when you're having issues (i.e. it's an issue in BT), or if it's actually a problem with the entity on Z2M side, it rly being not available?

No, this attribute is not available. The list of attributes is short:

hvac_modes:
  - "off"
  - auto
  - heat
min_temp: 5
max_temp: 30
target_temp_step: 0.5
current_temperature: 21
temperature: 23
hvac_action: heating
friendly_name: Thermostat Wohnzimmer
supported_features: 385

It looks like the new z2m 2.0 reduces the number of attributes it transmits to HA, not just from thermostats. I can't say whether this is a bug or a feature. Maybe you have to request the required attributes? But there are already several issue reports on z2m:
25543, 25603, 25523

@airmonitor
Copy link

I've encountered error as well after upgrading HA to 2025.1

Logger: homeassistant.setup
Source: setup.py:334
First occurred: 21:42:23 (1 occurrences)
Last logged: 21:42:23

Setup failed for custom integration 'better_thermostat': Unable to import component: cannot import name 'SUPPORT_TARGET_TEMPERATURE' from 'homeassistant.components.climate.const' (/usr/src/homeassistant/homeassistant/components/climate/const.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1015, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._get_component, True
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1075, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/better_thermostat/__init__.py", line 8, in <module>
    from .const import (
    ...<6 lines>...
    )
  File "/config/custom_components/better_thermostat/const.py", line 12, in <module>
    from homeassistant.components.climate.const import SUPPORT_TARGET_TEMPERATURE
ImportError: cannot import name 'SUPPORT_TARGET_TEMPERATURE' from 'homeassistant.components.climate.const' (/usr/src/homeassistant/homeassistant/components/climate/const.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1035, in async_get_component
    self._component_future.result()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1027, in async_get_component
    comp = self._get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1075, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/better_thermostat/__init__.py", line 8, in <module>
    from .const import (
    ...<6 lines>...
    )
  File "/config/custom_components/better_thermostat/const.py", line 12, in <module>
    from homeassistant.components.climate.const import SUPPORT_TARGET_TEMPERATURE
ImportError: cannot import name 'SUPPORT_TARGET_TEMPERATURE' from 'homeassistant.components.climate.const' (/usr/src/homeassistant/homeassistant/components/climate/const.py)

@folfy
Copy link
Collaborator

folfy commented Jan 7, 2025

cannot import name 'SUPPORT_TARGET_TEMPERATURE' from 'homeassistant.components.climate.const'

@airmonitor Yeah ehm, that definitely shouldn't happen and doesn't seem to be related to the Z2M issue reported here - Could you please open a seperate bug report issue here, with all the required info mentioned/you'll see in the template (Better Thermostat version, HW, full log/diagnostic data, etc.)? Thanks!

@Fierys
Copy link

Fierys commented Jan 8, 2025

Yes, the list of thermostat attributes has changed a lot in version 2.0.0.

Found in this article:

Entity attributes (homeassistant.legacy_entity_attributes setting) has been removed. This means that entities discovered by Zigbee2MQTT will no longer have entity attributes (Home Assistant entity attributes are accessed via e.g. states.binary_sensor.my_sensor.attributes).

If this is relevant to our problem, how can we implement it?
Now i'm on 1.42 and my sensors are made like this:

  - sensor:

          - name: lr1_thermostat_current_heating_setpoint
            state: "{{state_attr('climate.0x2c1165fffe7bb27c', 'current_heating_setpoint') | float|round(1) }}"
            unit_of_measurement: °C
            icon: mdi:temperature-celsius

          - name: lr1_thermostat_local_temperature
            state: "{{state_attr('climate.0x2c1165fffe7bb27c', 'local_temperature') | float|round(1) }}"
            unit_of_measurement: °C
            icon: mdi:temperature-celsius

          - name: lr1_thermostat_local_temperature_calibration
            state: "{{state_attr('climate.0x2c1165fffe7bb27c', 'local_temperature_calibration') | float|round(1) }}"
            unit_of_measurement: °C
            icon: mdi:temperature-celsius

@denandy83
Copy link

For me, when I checked the developer tools, the climate entities i based my BT devices on were set to state 'unknown'.
I added the entities, and manually set them to heat, after which they became available again in BT.

@rickgardner077
Copy link

For me, the problem persists although I tried all the different things mentioned above in this thread - setting "Home Assistant Integration to 'off' and then to 'on' in Z2M (still on v 1.42.0 if relevant). Also tried setting the state of the TRV entitty to 'heat' with no success.

All BT entities remain in state unavailable

@folfy
Copy link
Collaborator

folfy commented Jan 8, 2025

@ALL - We cannot diagnose anything without logs. @SpencersGithub provided the logs and appropiate screenshots, to make clear that his issue was the window sensor simply being unavailable in Z2M, which BT cannot do anything about (except maybe showing a more helpful error about the actual issue somewhere in the future).

@airmonitor - Please follow my instructions before on creating a seperate issue with logs, as said it seems to be totally unrelated (looking more like a problem with your HA installation even, maybe outdated version). Otherwise your issue won't / can't be analyzed further.

Everyone else:

Please provide at least version information and the following logs, if you want any support

diagnostic data
IMPORTANT:
Download and paste the diagnostic data from your Better Thermostat Entity(s) below.
https://www.home-assistant.io/docs/configuration/troubleshooting/#download-diagnostics

debug log
Depending on how complicated you issue is, it might be necessary to enable debug logging for BT,
reproduce the issue, and then upload this logfile here.
https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging

@folfy folfy changed the title Thermostats unavailable Thermostats unavailable with Z2M v2.0.0 Jan 9, 2025
@slackuu
Copy link

slackuu commented Jan 9, 2025

Same problem here, I'm using Better Thermostat just to override the current temperature on the zigbee boiler thermostat. I have downgraded Z2M to version 1.4.2 and the problem still occurs. I will try to upload the logs soon.

@folfy
Copy link
Collaborator

folfy commented Jan 9, 2025

@slackuu Odd, the issue fo @uwen70 seems to be related to the number.*_local_temperature_calibration missing now since Z2M v2.0. If it's not working with 1.4.2 either for you, it might be a different problem, so we have to check the logs then.

Summarizing the rest

@KartoffelToby You said it's working for you in 2.0 - Are you maybe using target temperature based calibration, and that's why you didn't observe the problem?

@rickgardner077 Having also issues with 1.4.2 actually, but missing debug logs

@SpencersGithub had a window sensor being unavailable, so just a "normal" issue totally outside of BT.

@airmonitor Unrelated / different issue, but to be checked if a new issue with actual logs is available

@others No more infos/logs provided/known

@NC1609
Copy link

NC1609 commented Jan 12, 2025

I encountered the same issue. In Zigbee2MQTT, the "Scale Protection" setting was displayed with a question mark. I toggled the switch off and on, ensuring it showed "OFF" and "ON" respectively. After this adjustment, the problem was resolved.

As a tip from me: Check your thermostats in Zigbee2MQTT and see if there are any unknown entities under the settings. Toggle the switches to make sure these entities are recognized and displayed properly.

I am using the latest version of Zigbee2MQTT and Home Assistant.

@wessamlauf
Copy link

I am having the same issue .... :/

Image

@csidirop
Copy link

Not sure if that helps: I'm still on HA 2024.10.4 and Z2M 2.1.1 commit: 1accb8b6 and Better Thermostat 1.7.0-beta3. After restarting HA they need maybe around one more minute after everything (including BT) is up than they are shown again.
In the meantime its all greyed out.

@pr8x
Copy link

pr8x commented Feb 22, 2025

Same issue. Started happening with upgrade to HA 2025.1. It just loops that:

-22 16:49:22.409 INFO (MainThread) [custom_components.better_thermostat.climate] better_thermostat Living Room Thermostat 2.0: Starting version 1.6.1. Waiting for entity to be ready...
2025-02-22 16:49:22.409 INFO (MainThread) [custom_components.better_thermostat.climate] better_thermostat Living Room Thermostat 2.0: waiting for TRV/climate entity with id 'climate.living_room_thermostat_thermostat' to become fully available...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests