zacs / ha-dualmodegeneric

Generic thermostat capable of heating and cooling
68 stars 26 forks source link

Error at startup. Thermostat still works. #43

Closed mgoulet65 closed 2 years ago

mgoulet65 commented 2 years ago

I am running on HA Blue. I get the following error (just once) each startup. The thermostat seems to still function fine in both heat and cool mode. Just wondering if this is something I can fix or should worry about.

2021-12-11 15:49:33 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback DualModeGenericThermostat.async_added_to_hass.._async_startup(<Event homeassistant_start[L]>) at /config/custom_components/dualmode_generic/climate.py:382 Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run self._context.run(self._callback, self._args) File "/usr/src/homeassistant/homeassistant/core.py", line 835, in _onetime_listener self._hass.async_run_job(listener, event) File "/usr/src/homeassistant/homeassistant/core.py", line 452, in async_run_job return self.async_run_hass_job(HassJob(target), args) File "/usr/src/homeassistant/homeassistant/core.py", line 433, in async_run_hass_job hassjob.target(*args) TypeError: _async_startup() takes 0 positional arguments but 1 was given

XLR-24 commented 2 years ago

I have exact the same error in my HA 2021.12.2 log details.

david-kalbermatten commented 2 years ago

Noticed that as well. Probably introduced with #40 Because the contributor changed the signature of the function while HA expects to be able to pass the "unused" variable event along. Hence the error at the end of the stack trace...

TypeError: _async_startup() takes 0 positional arguments but 1 was given

This function gets called and itself calls another function which finally tries to run the def _async_startup() function which doesn't accept args anymore because of the change in #40

# core.py - Lines 833 - 837

@callback
def _onetime_listener(event: Event) -> None:
    """Remove listener from event bus and then fire listener."""
    nonlocal filterable_job
    if hasattr(_onetime_listener, "run"):
        return
    # Set variable so that we will never run twice.
    # Because the event bus loop might have async_fire queued multiple
    # times, its possible this listener may already be lined up
    # multiple times as well.
    # This will make sure the second time it does nothing.
    setattr(_onetime_listener, "run", True)
    assert filterable_job is not None
    self._async_remove_listener(event_type, filterable_job)
    self._hass.async_run_job(listener, event) # <--- This line causes the error

filterable_job = (HassJob(_onetime_listener), None)

return self._async_listen_filterable_job(event_type, filterable_job)

I created a PR #45 with a fix for it.