arjenbos / ha_alpha_home

A custom Home Assistant integration for Alpha Innotec heat pumps.
Apache License 2.0
5 stars 1 forks source link

Current temperature and battery cannot be read out on sense_control thermostat units #5

Open DrBlokmeister opened 1 year ago

DrBlokmeister commented 1 year ago

Great integration! I was thinking of improving my python skills and writing my own, but then I found this. Really happy with it! 😊

After installing and setting up, I could only change the temperature setpoint, not the current temperature or battery settings. After a few hours of digging, I managed a containment by modifying const.py and base_coordinator.py. The changes are below:

const.py changed to:

from homeassistant.const import Platform

DOMAIN = "alpha_innotec"

MANUFACTURER = "Alpha Innotec"

PLATFORMS = [
    Platform.SENSOR,
    Platform.CLIMATE,
]

MODULE_TYPE_FLOOR = "floor"
MODULE_TYPE_SENSOR = "sense_control" #changed from sensor

MODULE_TYPES = [
    MODULE_TYPE_FLOOR,
    MODULE_TYPE_SENSOR
]

base_coordinator.py changed line 43:

if module_details["type"] == MODULE_TYPE_SENSOR:
    current_temperature = module_details["currentTemperature"] #changed from actualTemperature
    battery_percentage = module_details["battery"]
arjenbos commented 1 year ago

Hi @DrBlokmeister,

Thanks for sharing! I created a pull request based on your information. Why did you changed the value of constant "MODULE_TYPE_SENSOR"? I think your change will break the integration for others. So, I added an extra else if in base_coordinator.py. Also, you say that you changed the key currentTemperature from actualTemperature, but it looks like key was already currentTemperature.

Please check the linked pull request and maybe test it in your home assistant installation?

DrBlokmeister commented 1 year ago

Oops! The change was in ccontroller_api.py, line 126.

I agree that my change will likely break the integration for others. I'll have a look next week to see if it works.

arjenbos commented 1 year ago

Created a new PR - https://github.com/arjenbos/ha_alpha_innotec/pull/14

DrBlokmeister commented 1 year ago

Just updated to the latest version and modified the files in the PR (moved the code change to coordinator.py instead of base_coordinator.py). The integration won't load anymore. A log entry is attached below (I redacted my home address):

2023-11-11 08:50:19.906 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry <HOME ADDRESS REDACTED> for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 557, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 136, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 202, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!
2023-11-11 08:50:19.915 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry <HOME ADDRESS REDACTED> for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 557, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 175, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 202, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!
2023-11-11 08:50:19.925 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry <HOME ADDRESS REDACTED> for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 557, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 201, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 202, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

I rolled back to the previous version and modified the files in the PR. This works. I can view the current temperature and battery percentage with my sense control units.

So the PR works as intended, however not with the current version anymore.

arjenbos commented 1 year ago

I do not think that this error is related to any change I made recently. I need to update the PR before I can merge it, but nice to know that the initial changes work as intended. In that case I can safely deploy the changes.