Open hesspoint opened 1 month ago
Just a few more things I tested, not that it matters since this projects seems to bed dead anyways but what the heck:
I tried the buttons in the integration
All of these buttons do work fine and they do what they are supposed to. However they also immediately throw that error message that it cannot reach the host and that the action was not executed.
It is clear that once these actions are performed the host is no longer reachable. But why does the integration try to reach the host again after performing the button action just fine?
And that is the issue which kills my scripts.
I solved the issue with the help of ChatGPT
The issue is in the api.py I modified the async def system_call(self, path: str) by adding an error handling for aiohttp.ClientConnectionError
except (aiohttp.ClientConnectionError, aiohttp.ServerDisconnectedError) as e:
LOGGER.error("Connection error: %s. Check if the MagicMirror service is running.", e)
This is the modified part
async def system_call(self, path: str) -> None:
"""Get request."""
get_url = f"{self.base_url}/{path}"
LOGGER.debug("GET url=%s. headers=%s", get_url, self.headers)
assert self._session is not None
try:
await self._session.get(
url=get_url,
headers=self.headers,
)
except (aiohttp.ClientConnectionError, aiohttp.ServerDisconnectedError) as e:
LOGGER.error("Connection error: %s. Check if the MagicMirror service is running.", e)
# Optionally: Implement a retry mechanism here
#except aiohttp.ServerDisconnectedError:
# LOGGER.info("Error: The connection was closed early by the remote host.")
With that it now works great again and it does not stop my scripts. Could you work this into your code?
Thanks
Version of the custom_component
latest of everything: MM, MM HA integration 1.5.0b5, latest fork of MMM-Remote Control MM module from sindrebroch, Core 2024.9.3, Supervisor 2024.09.1, Operating System 13.1
Configuration
domain: button entity_id: button.bathroom_magicmirror_shutdown_host type: press continue_on_error: true
Add your logs here.
Executed: September 26, 2024 at 08:52:32 Error: Cannot connect to host 192.xxx.xxx.xxx:8080 ssl:default [Connect call failed ('192.xxx.xxx.xxx', 8080)]
Describe the bug
A clear and concise description of what the bug is.
In my "night mode" script I shutdown the Pi on with the MM runs by using the Shutdown Host button.
This has worked fine but since a while it shows the error above that it cannot connect to host.
In fact it does trigger the shutdown of the Pi just fine. However by throwing this error it somehow stops my script from executing anything after that, even I added continue_on_error: true which should in fact ignore the error and continue but it does not.
If I trigger the shutdown host button manually e.g. in the device page the behavior is the same.
I also tried shutting down the pi by directly connecting to the MM remote UI via a webbrowser (not in HA) and there it shuts down normally. So it seems to be the HA integration and not the MMM-Remote Control Module in MM itself.
Debug log
This error originated from a custom integration.
Logger: custom_components.magicmirror Source: helpers/update_coordinator.py:386 integration: Magic Mirror (documentation, issues) First occurred: September 24, 2024 at 13:15:48 (9 occurrences) Last logged: 21:23:26
Error fetching magicmirror data: Cannot connect to host 192.xxx.xxx.xxx:8080 ssl:default [Connect call failed ('192.xxx.xxx.xxx', 8080)]