tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
302 stars 51 forks source link

[Feature] not reachable device as valid state #329

Closed PavelD closed 9 months ago

PavelD commented 10 months ago

Hello,

Problem :

I have a few PWR line devices and not all are available all the time.

When the device is not connected then log is full of the host unreachable and Unexpected error fetching errors.

See the log snippet in the end of the ticket.

Solution:

I want to be able to mark devices where the unreachable state is 100 % valid.

This device will be just Unavailable with no further error log.

Workaround:

One of the solutions is to disable device in /config/integrations/integration/mikrotik_router.

But it is not automatically enabled, when this mikrotik device is back online.

Log records :


homeassistant    | 2023-11-23 20:55:55.917 ERROR (MainThread) [custom_components.mikrotik_router.coordinator] Unexpected error fetching Mikrotik PWR OUT data: 'homeassistant'
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
homeassistant    |     self.data = await self._async_update_data()
homeassistant    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/config/custom_components/mikrotik_router/coordinator.py", line 549, in _async_update_data
homeassistant    |     await self.hass.async_add_executor_job(self.get_access)
homeassistant    |   File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
homeassistant    |     result = self.fn(*self.args, **self.kwargs)
homeassistant    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    |   File "/config/custom_components/mikrotik_router/coordinator.py", line 687, in get_access
homeassistant    |     tmp_user[self.config_entry.data[CONF_USERNAME]]["group"]
homeassistant    |     ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant    | KeyError: 'homeassistant'```
tomaae commented 10 months ago

what is this device?

PavelD commented 9 months ago

Hello, it's https://mikrotik.com/product/pwr_line_eu and I'm using that device in my garden house to extend network in the garden when it's needed.

tomaae commented 9 months ago

is it just this device that causes the issue, or regular routers too?

PavelD commented 9 months ago

Hi, I tried to disconnect my wifi and the error is slightly different. It is not showing trace from coordinator at all. Just a few lines only.

homeassistant    | 2023-12-11 23:50:38.002 ERROR (SyncWorker_4) [custom_components.mikrotik_router.mikrotikapi] Mikrotik wifi.xxxxx.cz error while building list for path /system/resource : timed out
homeassistant    | 2023-12-11 23:50:38.003 ERROR (MainThread) [custom_components.mikrotik_router.coordinator] Error fetching Mikrotik WIFI data: Mikrotik Disconnected
tomaae commented 9 months ago

ok, thats a problem. that means power line device works differently. I dont have such device, so this may be difficult to figure out. Can you try to simulate the issue while debug is active?

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] commented 9 months ago

This issue was closed because it has been stalled for 5 days with no activity.