tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
301 stars 50 forks source link

[Bug] No device tracking #228

Closed skulumani closed 2 years ago

skulumani commented 2 years ago

Describe the issue

Have Mikrotik router integration set up but no devices are being tracked.

How to reproduce the issue

  1. Install mikrotik router integration
  2. Use user with proper mikrotik permission
  3. Enable "Track network devices" in configuration options
  4. No device_tracker sensors appear within integration

Expected behavior

Expect that all network devices show up within homeassistant

Screenshots

image

image

image

Software versions

Diagnostics data

config_entry-mikrotik_router-3ed14618eae654730434af485d991b52.json.txt

Traceback/Error logs

No logs

Additional context

Seems to have only recently stopped tracking network devices. Perhaps a routeros update or Homeassistant?

tomaae commented 2 years ago

Are you sure there is nothing in the HA log? I can see device tracking information to be available in diagnostic data. If you cannot find anything, I will need debugs to see if we can figure it out.

skulumani commented 2 years ago

home-assistant.log

Here's a log after turning on debug logging for the integration. See this error for my two APs but none of the other devices.

2022-08-07 10:37:57 ERROR (MainThread) [homeassistant.util.logging] Exception in update_controller when dispatching 'mikrotik_router-update-Mikrotik': ()
Traceback (most recent call last):
  File "/config/custom_components/mikrotik_router/device_tracker.py", line 49, in update_controller
    update_items(
  File "/config/custom_components/mikrotik_router/device_tracker.py", line 90, in update_items
    trackers[item_id].async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 677, in async_schedule_update_ha_state
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 525, in async_write_ha_state
    raise RuntimeError(f"Attribute hass is None for {self}")
RuntimeError: Attribute hass is None for <Entity Downstairs WAP: home>
tomaae commented 2 years ago

Looks like a conflict. First, try to remove the router from HA, make sure all entities are deleted, restart HA and readd the router.

skulumani commented 2 years ago

Thanks for the help. Removing mikrotik integration then restarting seemed to help.

Appreciate it! And the great integration

skulumani commented 2 years ago

Looks like the same issue is occurring. I've tried completely deleting the database volume in docker and recreating it, removing the integration and restarting HA, then re-add.

Still seeing this error in the log

Logger: homeassistant.util.logging
Source: util/logging.py:167
First occurred: 12:12:44 AM (5 occurrences)
Last logged: 12:12:49 AM

Exception in update_controller when dispatching 'mikrotik_router-update-Mikrotik': () Traceback (most recent call last): File "/config/custom_components/mikrotik_router/model.py", line 42, in update_controller model_update_items( File "/config/custom_components/mikrotik_router/model.py", line 159, in model_update_items if tmp := _register_entity(sensors, item_id, uid, uid_sensor): File "/config/custom_components/mikrotik_router/model.py", line 76, in _register_entity _sensors[_item_id].async_schedule_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 677, in async_schedule_update_ha_state self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 525, in async_write_ha_state raise RuntimeError(f"Attribute hass is None for {self}") RuntimeError: Attribute hass is None for <Entity Downstairs WAP: home>

Not sure if you have any other suggestions

tomaae commented 2 years ago

are you using 2.1? if so, run integration in debug and we will see what we can find out.

skulumani commented 2 years ago

Appreciate the help. I am on 2.1 now. Here's a log

home-assistant.log

tomaae commented 2 years ago

I need you to run integration in debug, standard errors wont help here.

skulumani commented 2 years ago

Thanks I can do that. Is there documentation on how to enable debug mode for the integration?

I see on the main readme, instructions for debug logging but am unsure how to accomplish anything further.

Thanks

tomaae commented 2 years ago

thats all you need to do. debug logs will appear in ha log

skulumani commented 2 years ago

Here are some logs. Split it up into 450MB files

Bitwarden will delete in 30 days I believe.

tomaae commented 2 years ago

you didnt needed to run it that long :) Can you give me entity info for "Galaxy S20"? Best would be directly from entity db, but if oyu dont know how, look for it in developer tools>states

skulumani commented 2 years ago

image

Does this work?

you didnt needed to run it that long :)

I forgot about it overnight. The log was 2.5GB and I had a bunch of trouble even getting it open :)

tomaae commented 2 years ago

first 2 minutes are usually fine :)

is there no other sensor with similar name? that one does not belong to this integration. If not, have a look for "Downstairs WAP". Thats another one raising an error.

skulumani commented 2 years ago

I'm not sure what is happening. I just renabled the "track network devices" option and it seems to be working now

Screenshot_20220818-210528

tomaae commented 2 years ago

I have no idea what is happening here. Data seems to be perfectly fine. Did you do any change in HA in between? While this should be no issue, just to be sure, are you using any other integration to track devices on network? Did any device left or joined the network? Could be wireless device.

That error coming from Galaxy S20 entity is weird one tho. Could you try it with that device active and using your wifi network (not in sleep mode) and another time with it turned off completly so it wont be connected for sure?

skulumani commented 2 years ago

I don't think I've made any changes. I have added/removed the integration many times, and tried to clear/purge and deleted the entire database on several occasions. The integration and HA was in the same state as the logs, except I disabled and renabled the device tracking through the UI.

But the Galaxy S20 has been a constant issue for me. I think it uses some kind of wifi sleep mode so it constantly disconnects and ruins my presence detection.

I'll try to do some more testing with that device now that the device tracking seems to be working. The only other device trackers I use are the mobile apps, but those only provide data when on the local network so they're much less useful than the network detection.

Now that it seems to be working I don't want to do anything in case I upset the HA gods.

On Thu, Aug 18, 2022, 23:15 Tomaae @.***> wrote:

I have no idea what is happening here. Data seems to be perfectly fine. Did you do any change in HA in between? While this should be no issue, just to be sure, are you using any other integration to track devices on network? Did any device left or joined the network? Could be wireless device.

That error coming from Galaxy S20 entity is weird one tho. Could you try it with that device active and using your wifi network (not in sleep mode) and another time with it turned off completly so it wont be connected for sure?

— Reply to this email directly, view it on GitHub https://github.com/tomaae/homeassistant-mikrotik_router/issues/228#issuecomment-1220197087, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIFUZWRL4FDZJ4JVRBLHF3VZ333TANCNFSM552JNGZA . You are receiving this because you modified the open/close state.Message ID: @.*** com>

tomaae commented 2 years ago

I think the issue will return for you, we just need to pinpoint it and find the cause. It really depends on sleep mode S20 uses. Some devices can act like that, which is unfortunate.

github-actions[bot] commented 2 years 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 2 years ago

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