uebelack / python-maxcube-api

A python api to control the Max! Cube thermostats.
https://github.com/uebelack/python-maxcube-api
MIT License
21 stars 26 forks source link

Maxcube TypeError during setup, devices do not show up anymore #20

Closed onkelbeh closed 3 years ago

onkelbeh commented 4 years ago

I have posted this already at Home Assistant Issues.

Home Assistant release with the issue: Home Assistant 0.102.0b1 x86_64 python_version 3.7.5

Last working Home Assistant release (if known): last winter, ~0.85.x - ~0.89.x

Operating environment (Hass.io/Docker/Windows/etc.): Native Installation on Gentoo Linux

Integration: maxcube-api-0.1.0

Description of problem: Errors on Init of maxcube-api, devices do not show up in Home Assistant

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

maxcube:
  gateways:
    - host: 172.16.2.154
      port: 62910

Traceback (if applicable):

2019-11-16 11:24:56 INFO (SyncWorker_4) [homeassistant.loader] Loaded maxcube from homeassistant.components.maxcube
2019-11-16 11:24:57 INFO (MainThread) [homeassistant.setup] Setting up maxcube
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] Cube (rf=036d02, firmware=01.13)
2019-11-16 11:24:59 INFO (SyncWorker_6) [homeassistant.loader] Loaded threshold from homeassistant.components.threshold
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] WallThermostat (type=3, rf=096F9B, room=WS, name=Wandthermostat 1, min=4.5, max=30.5, actual=22.5, target=21.0)
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] Thermostat (type=1, rf=0CD664, room=WS, name=Bodenheizung, mode=0, min=4.5, max=30.5, actual=None, target=21.0, valve=0)
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] Thermostat (type=1, rf=039D06, room=KUCHE, name=Thermostat 1, mode=1, min=4.5, max=30.5, actual=None, target=15.0, valve=0)
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] WallThermostat (type=3, rf=0799BB, room=WZ, name=Wandthermostat 1, min=4.5, max=30.5, actual=18.9, target=10.0)
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] Thermostat (type=1, rf=071350, room=WZ, name=Thermostat 1, mode=1, min=4.5, max=30.5, actual=None, target=10.0, valve=0)
2019-11-16 11:24:59 INFO (SyncWorker_2) [maxcube.cube] Thermostat (type=1, rf=038C0A, room=SZ, name=Thermostat 1, mode=1, min=4.5, max=30.5, actual=None, target=10.0, valve=0)
2019-11-16 11:25:00 INFO (MainThread) [homeassistant.setup] Setup of domain maxcube took 2.9 seconds.
2019-11-16 11:25:00 INFO (MainThread) [homeassistant.components.climate] Setting up climate.maxcube
2019-11-16 11:25:00 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform maxcube
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.7/site-packages/homeassistant/components/maxcube/climate.py", line 39, in setup_platform
    if cube.is_thermostat(device) or cube.is_wallthermostat(device):
TypeError: is_thermostat() takes 1 positional argument but 2 were given
2019-11-16 11:25:02 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.maxcube
2019-11-16 11:25:02 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up platform maxcube
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.7/site-packages/homeassistant/components/maxcube/binary_sensor.py", line 20, in setup_platform
    if cube.is_windowshutter(device):
TypeError: is_windowshutter() takes 1 positional argument but 2 were given

Additional information: Device linked to Cube:

Cube already reset to Factory, Firmware updated.

Afaik this integragtion will not run anymore with a current release of Home Assistant. Is anyone using maxcube-api with > 0.101.0?

onkelbeh commented 4 years ago

Created a very dirty hack to make it run again, two files at the integraton had to be changed, in my case these are in /usr/lib/python3.7/site-packages/homeassistant/components/maxcube:

In binary_sensor.py i changed

if cube.is_windowhutter(device):
                devices.append(MaxCubeShutter(handler, name, device.rf_address))

to

# if cube.is_windowhutter(device):
if device.type == 4:
    devices.append(MaxCubeShutter(handler, name, device.rf_address))

In climate.py I changed

if cube.is_thermostat(device) or cube.is_wallthermostat(device):
    devices.append(MaxCubeClimate(handler, name, device.rf_address))

to

# if cube.is_thermostat(device) or cube.is_wallthermostat(device):
if device.type == 3 or device.type == 1:
    devices.append(MaxCubeClimate(handler, name, device.rf_address))

and voila, my wife is not freezing anymore :-) hope this will be fixed.

Bildschirmfoto 2019-11-17 um 09 22 37
onkelbeh commented 4 years ago

I made a patch for temporarily fixing the issue. Perhaps it helps someone.

onkelbeh commented 3 years ago

Sorry, was using the wrong commit id for the test against Home Assitant. Just fixed this: https://github.com/onkelbeh/HomeAssistantRepository/commit/17b4f8536e90a6d618cdf018febd4141c774e564