joleys / niko-home-control-II

Home Assistant Custom Integration for Niko Home Control II
MIT License
74 stars 21 forks source link

Error in HomeAssistant Log #98

Closed driesvandamme closed 8 months ago

driesvandamme commented 10 months ago

Any clue what the below error might mean?

Logger: custom_components.nhc2.nhccoco.coco Source: custom_components/nhc2/nhccoco/coco.py:158 Integration: Niko Home Control II (documentation, issues) First occurred: 5 december 2023 om 01:50:51 (296 occurrences) Last logged: 02:24:27

'NoneType' object has no attribute 'loop'

tijsverkoyen commented 10 months ago

Can you change the log level for the integration to debug. So that we get more debug info.

driesvandamme commented 10 months ago

Seems like it might have to do something with the Daikin integration of AC units within HC II

2023-12-06 12:06:51.695 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: 8579f707-ba45-4b2b-a7aa-3088490136a0. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'AmbientTemperature': '24.00'}]} 2023-12-06 12:06:51.695 ERROR (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop' 2023-12-06 12:07:13.340 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp). 2023-12-06 12:07:13.341 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_hvac] Airco Keuken changed. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'AmbientTemperature': '25.00'}]} 2023-12-06 12:07:13.341 DEBUG (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: 8579f707-ba45-4b2b-a7aa-3088490136a0. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'AmbientTemperature': '25.00'}]} 2023-12-06 12:07:13.341 ERROR (Thread-3 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop'

tijsverkoyen commented 10 months ago

@driesvandamme could you provide me with a device list, or check which device is "8579f707-ba45-4b2b-a7aa-3088490136a0"

Is suspect there is a (new) property AmbientTemperature

driesvandamme commented 10 months ago

REDACTED

tijsverkoyen commented 10 months ago

@driesvandamme could it be that this error only occurs when your Niko Controller has restarted?

driesvandamme commented 10 months ago

Happens multiple times throughout the day image

tijsverkoyen commented 9 months ago

@driesvandamme is debug still enabled? If so can you show an overview of a full day. And can you check if there is a message "controller changed" around the same time?

driesvandamme commented 9 months ago

It does look like it yes:

2023-12-13 13:58:34.876 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2023-12-13 13:58:34.876 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_hvac] Airco Keuken changed. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'CouplingStatus': 'NoInternet'}]}
2023-12-13 13:58:34.876 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: 8579f707-ba45-4b2b-a7aa-3088490136a0. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'CouplingStatus': 'NoInternet'}]}
2023-12-13 13:58:34.876 ERROR (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop'
2023-12-13 13:58:34.876 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_hvac] Airco Badkamer changed. Topic: hobby/control/devices/evt | Data: {'Uuid': 'bf249991-8a27-4687-b76a-579b99d0a6d6', 'Properties': [{'CouplingStatus': 'NoInternet'}]}
2023-12-13 13:58:34.876 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: bf249991-8a27-4687-b76a-579b99d0a6d6. Topic: hobby/control/devices/evt | Data: {'Uuid': 'bf249991-8a27-4687-b76a-579b99d0a6d6', 'Properties': [{'CouplingStatus': 'NoInternet'}]}
2023-12-13 13:58:34.876 ERROR (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop'
2023-12-13 13:58:52.467 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2023-12-13 13:58:52.467 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_hvac] Airco Keuken changed. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'CouplingStatus': 'Ok'}]}
2023-12-13 13:58:52.467 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: 8579f707-ba45-4b2b-a7aa-3088490136a0. Topic: hobby/control/devices/evt | Data: {'Uuid': '8579f707-ba45-4b2b-a7aa-3088490136a0', 'Properties': [{'CouplingStatus': 'Ok'}]}
2023-12-13 13:58:52.467 ERROR (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop'
2023-12-13 13:58:52.507 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2023-12-13 13:58:52.507 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_hvac] Airco Badkamer changed. Topic: hobby/control/devices/evt | Data: {'Uuid': 'bf249991-8a27-4687-b76a-579b99d0a6d6', 'Properties': [{'CouplingStatus': 'Ok'}]}
2023-12-13 13:58:52.507 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: bf249991-8a27-4687-b76a-579b99d0a6d6. Topic: hobby/control/devices/evt | Data: {'Uuid': 'bf249991-8a27-4687-b76a-579b99d0a6d6', 'Properties': [{'CouplingStatus': 'Ok'}]}
2023-12-13 13:58:52.507 ERROR (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop'
2023-12-13 14:01:47.871 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2023-12-13 14:01:47.872 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Device not in our instances list, therefor failed to invoke callback: 51cd4edf-2110-4e86-9462-793a320d99e5. Topic: hobby/control/devices/evt | Data: {'Uuid': '51cd4edf-2110-4e86-9462-793a320d99e5', 'Properties': [{'UpgradeStatus': 'RemoteVersionCheck'}]}
2023-12-13 14:01:48.271 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2023-12-13 14:01:48.271 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Device not in our instances list, therefor failed to invoke callback: 51cd4edf-2110-4e86-9462-793a320d99e5. Topic: hobby/control/devices/evt | Data: {'Uuid': '51cd4edf-2110-4e86-9462-793a320d99e5', 'Properties': [{'UpgradeStatus': 'Idle'}]}
2023-12-13 14:01:48.311 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2023-12-13 14:01:48.311 DEBUG (Thread-5 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Device not in our instances list, therefor failed to invoke callback: 51cd4edf-2110-4e86-9462-793a320d99e5. Topic: hobby/control/devices/evt | Data: {'Uuid': '51cd4edf-2110-4e86-9462-793a320d99e5', 'Properties': [{'UpgradeStatus': 'Idle'}, {'RemoteAvailableFWInfo': ''}]}
tijsverkoyen commented 9 months ago

Did you invoke these restarts? Could it be that your controller has a bad network connection?

driesvandamme commented 9 months ago

It's on a powerline, so I supose it's possible that there are connection drops sometimes :) They aren't manual restarts in any case

tijsverkoyen commented 9 months ago

I don't think there is much I can do about this at this point. As the code is not really prepared for recovering correctly after a restart of the controller. In essence to be sure that everything works correctly you need to restart Home Assistant after the Controller has been restarted.

Changing the code to allow for this is not really something which is easy. And to be honest: I don't have the time for it.

My best suggestion would be to make sure there is a stable network connection.

blatruwe commented 9 months ago

I had a similar entry in my logs. Can you disable the "energyhome" device in the devices and see if the issue is still present?

driesvandamme commented 9 months ago

I had a similar entry in my logs. Can you disable the "energyhome" device in the devices and see if the issue is still present?

It was already disabled, so no - wasn't this :) Pretty sure it's due to the unstable connection.

dimitridelanghe commented 8 months ago

I had a similar entry in my logs. Can you disable the "energyhome" device in the devices and see if the issue is still present?

It was already disabled, so no - wasn't this :) Pretty sure it's due to the unstable connection.

bwa, i have the same and i'm pretty sure i have a stable an good network setup :)

But it's indeed something with the ernergy module (which is disabled with me) It's also not important so low prio 😄

2024-02-04 12:35:51.785 DEBUG (Thread-19 (_thread_main)) [custom_components.nhc2.nhccoco.devices.controller] Controller changed (hobby/control/devices/evt == /control/devices/rsp).
2024-02-04 12:35:51.785 DEBUG (Thread-19 (_thread_main)) [custom_components.nhc2.nhccoco.devices.generic_energyhome] energyhome changed. Topic: hobby/control/devices/evt | Data: {'Uuid': 'xxxxxxxxxxxxxxxxxxxxxxxxx', 'Properties': [{'ReportInstantUsage': 'True'}]}
2024-02-04 12:35:51.785 DEBUG (Thread-19 (_thread_main)) [custom_components.nhc2.nhccoco.coco] Failed to invoke callback: xxxxxxxxxxxxxxxxxxxxxxxxx. Topic: hobby/control/devices/evt | Data: {'Uuid': 'xxxxx-xxxxxxxxx', 'Properties': [{'ReportInstantUsage': 'True'}]}
2024-02-04 12:35:51.785 ERROR (Thread-19 (_thread_main)) [custom_components.nhc2.nhccoco.coco] 'NoneType' object has no attribute 'loop'
Traceback (most recent call last):
  File "/config/custom_components/nhc2/nhccoco/coco.py", line 150, in _on_message
    self._device_instances[device[MQTT_DATA_PARAMS_DEVICES_UUID]].on_change(topic, device)
  File "/config/custom_components/nhc2/nhccoco/devices/generic_energyhome.py", line 76, in on_change
    callback()
  File "/config/custom_components/nhc2/entities/generic_energyhome_report_instant_usage.py", line 64, in on_change
    self.schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1161, in schedule_update_ha_state
    self.hass.loop.call_soon_threadsafe(self.async_write_ha_state)
    ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'loop'
driesvandamme commented 8 months ago

@tijsverkoyen - Would it be possible to check first if the updated entity has an attribute 'loop' ? And if not, don't call the schedule_update_ha_state() ?

Then again, it might just be 'hiding' the problem. It doesn't have any bad implications except the errors in the HA log

tijsverkoyen commented 8 months ago

Would it be possible to check first if the updated entity has an attribute 'loop' ? And if not, don't call the schedule_update_ha_state() ? Then again, it might just be 'hiding' the problem. It doesn't have any bad implications except the errors in the HA log

That would be hiding the issue idd. This error indicates that there is something wrong. As far as I understand it means that the hass instance is not present in the code from Home Assistant itself. So hiding the issue seems like a bad idea.

If it only happens on the Energy Home device, I would suggest disabling it.