Closed adorobis closed 2 months ago
I've now even created an automation to reload openhasp 30 seconds after HA start. And it works. Looking at the error log above I have a suspission that openhasp intrgration tries to communicate to the MQTT broker before the connection to it is established by HA? And then it fails and does not try anymore. Btw, this might also explain why it works with the debug log on - it takes longer to load the openhasp integration and the MQTT integration is loaded by that time.
Same problem here. Can you share an openhasp reload automation example?
automation example
alias: System - reload openhasp integration on HA start
description: ""
trigger:
- platform: homeassistant
event: start
condition: []
action:
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- service: homeassistant.reload_config_entry
target:
device_id:
- a33aa113b69e17fe97ceadcb7690c07e
- 4c7796c8c47f6907734b66476bf7a5be
data: {}
mode: single
You'll get the device id when selecting a hasp device from GUI editor
Thanks, I'll include it in the automations.
Did an update a few days ago everything was still working. Lost power today and my screens aren't working. Thanks for providing a solution.
EDIT: I guess it wasn't my issue. It did not work for me.
I did see this in the DEBUG logs.
WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration openhasp with title: wt32 and entry_id: 7a3ad312332sd3b58f42da3bfafef125f, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.
https://github.com/HASwitchPlate/openHASP-custom-component/pull/137 fixed the startup issue for me. No need to reload the config_entry anymore. So please try https://github.com/HASwitchPlate/openHASP-custom-component/releases/tag/0.7.4 and see if it helps you too.
Nevertheless it still throws an error as mentioned by @adorobis AttributeError: 'MQTT' object has no attribute '_mqttc'
in the logs
Logger: custom_components.openhasp
Quelle: helpers/entity_platform.py:598
Integration: openHASP (Dokumentation, Probleme)
Erstmals aufgetreten: 17:41:18 (4 Vorkommnisse)
Zuletzt protokolliert: 17:41:18
Error adding entity openhasp.kueche for domain openhasp with platform openhasp
Error adding entity openhasp.bad for domain openhasp with platform openhasp
Error adding entity openhasp.buero for domain openhasp with platform openhasp
Error adding entity openhasp.kinderzimmer for domain openhasp with platform openhasp
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1361, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/openhasp/__init__.py", line 443, in async_added_to_hass
await async_publish(
File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 182, in async_publish
await mqtt_data.client.async_publish(
File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 635, in async_publish
msg_info = self._mqttc.publish(topic, payload, qos, retain)
^^^^^^^^^^^
AttributeError: 'MQTT' object has no attribute '_mqttc'
Released 0.7.4 please test
I've just rebooted HA and the integration seems to work ok now. Hope this will stay like that :) Many thanks!
great , thanks
Seems the issue is back (or similar). I'm now on HA 2024.9.0, openhasp 0.7.5 and see the following error after HA restart:
2024-09-04 23:40:13.800 ERROR (MainThread) [custom_components.openhasp] Error adding entity openhasp.hasp1 for domain openhasp with platform openhasp
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 909, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1365, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/openhasp/__init__.py", line 445, in async_added_to_hass
await async_publish(
File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 182, in async_publish
await mqtt_data.client.async_publish(
File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 635, in async_publish
msg_info = self._mqttc.publish(topic, payload, qos, retain)
^^^^^^^^^^^
AttributeError: 'MQTT' object has no attribute '_mqttc'
2024-09-04 23:40:13.820 ERROR (MainThread) [custom_components.openhasp] Error adding entity openhasp.hasp2 for domain openhasp with platform openhasp
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 909, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1365, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/openhasp/__init__.py", line 445, in async_added_to_hass
await async_publish(
File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 182, in async_publish
await mqtt_data.client.async_publish(
File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 635, in async_publish
msg_info = self._mqttc.publish(topic, payload, qos, retain)
^^^^^^^^^^^
AttributeError: 'MQTT' object has no attribute '_mqttc'
This looks like exactly the same error message as when I have raised it in July. Similarly like before it starts working ok after reloading the integration.
If you have the possibility to test something, it requires the replacement of a file in the installation to give it a test:
https://github.com/HASwitchPlate/openHASP-custom-component/pull/149#issuecomment-2333550266
If you can replace the /root/config/custom_components/openhasp/__init__.py
with the one from this PR and see if it fixes your issue.
Yes, it did the trick. No error message anymore and all works after HA restart. Many thanks! Is it going to be part of next release?
Yes, it did the trick. No error message anymore and all works after HA restart. Many thanks! Is it going to be part of next release?
That depends on @dgomes and @fvanroie :)
But I'm happy I found the way to fix this issue. With thanks to @dgomes who pointed me in the right direction.
So the 0.7.6 version is here and all works great again. Many thanks!
Version of the custom_component
0.7.3
Configuration
Describe the bug
After restarting HA the Openhasp integration does not load configured entities. Example error message in the log below, there are multiple ones like that for each entity of the openhasp device. Interestingly after enabling debug log and restarting HA all works ok, no errors in the log. After disabling the debug log and restarting again is like below. Reloading the integration in the running HA makes the integration work again ok. Very confusing.
Debug log