tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
292 stars 48 forks source link

[Bug] Device tracker entities lost after 2.1.3 upgrade #301

Closed clau-bucur closed 10 months ago

clau-bucur commented 11 months ago

Describe the issue

After upgrading to 2.1.3 the already existing device_tracker entities got disabled and new entites were created with different entiy_id.

How to reproduce the issue

Expected behavior

The order defined in #86 to remain in place.

Screenshots

image New device tracker: device_tracker.attic_light Old, now unavailable, device tracker: device_tracker.light_attic

Software versions

alexdelprete commented 11 months ago

I'm not using device tracking feature, but I noticed this error popping up in HA logs on every restart:

Logger: homeassistant.components.device_tracker
Source: custom_components/mikrotik_router/device_tracker.py:72
Integration: Device Tracker (documentation, issues)
First occurred: 04:42:10 (2 occurrences)
Last logged: 05:07:10

Error while setting up mikrotik_router platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/mikrotik_router/device_tracker.py", line 110, in async_setup_entry
    await async_add_entities(hass, config_entry, dispatcher)
  File "/config/custom_components/mikrotik_router/device_tracker.py", line 89, in async_add_entities
    await async_update_controller(
  File "/config/custom_components/mikrotik_router/device_tracker.py", line 72, in async_update_controller
    data = coordinator.data[entity_description.data_path]
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Software versions:

tomaae commented 11 months ago

Order didnt changed, thats looks like device hostname was renamed. can you give more examples?

alexdelprete commented 11 months ago

can you give more examples?

This happened at last restart, couple of hours ago:

image

clau-bucur commented 11 months ago

Order didnt changed, thats looks like device hostname was renamed. can you give more examples?

The thing is that I did not change a bit on my MT setup. The things changed as soon as I upgraded from 2.1.2 to 2.1.3 and rebooted HA.

I have watchdogs setup to notify me when device trackers go offline, and they kicked in after reboot because of the entity_id changes.

@tomaae I'll enable debug for the component and attach it here if you need that.

tomaae commented 11 months ago

Check why there are 2 names, what defines the device as "attic light" and "light attic" in mikrotik. Based on that I can check it.

tomaae commented 11 months ago

can you give more examples?

This happened at last restart, couple of hours ago:

image This is not related, I have opened it as new issue #302

clau-bucur commented 11 months ago

Check why there are 2 names, what defines the device as "attic light" and "light attic" in mikrotik. Based on that I can check it.

I don't really get it. I can't find anywhere in Mikrotik where it's refered as attic light.

  1. DNS comment and hostname: image
  2. DHCP comment (this should get used) and hostname: image

The same is for all the rest of my similar light devices: image

image

Looking at other devices I think that the device tracker entity_id is now derived from the HomeAssistant device name. Take for example this HomeAssistant device called Garden. In Mikrotik it's named Light Garden as you can see above. Earlier it's device tracker entity was device_tracker.light_garden. Now it looks like this: image image

tomaae commented 11 months ago

yes, entity id is derivated from device name. thats how it always been. there is no separate way to specify entity id to be different from device name

clau-bucur commented 11 months ago

Understood. Then it means upgrade de HA 2023.9 triggered the changes actually.

Thanks!

tomaae commented 11 months ago

no, you have misunderstood. it was like that before, nothing should have changed.

clau-bucur commented 11 months ago

Then I don't get what happened on my system, really.

I upgraded Mikrotik from 2.1.2 to 2.1.3 then HA from 2023.8.? to 2023.09.2. HA upgrade triggered a restart, after which the changed entities appeared 😕

tomaae commented 11 months ago

no idea really, we will need to run it in debug. possibly there will be a clue

tomaae commented 11 months ago

@clau-bucur can you test it now with 2.1.4 and include debugs and diagnostics?

clau-bucur commented 11 months ago

Enabled debug for component, upgraded to 2.14, then rebooted HA. Here are the logs. Let me know if more details are neede. home-assistant_mikrotik_router_2023-09-18T11-41-13.585Z.log

tomaae commented 11 months ago

can you also share your integration diagnostics?

clau-bucur commented 11 months ago

Here they are. config_entry-mikrotik_router-58cc03fe1493050f257e1c438b246a5c.json.txt

tomaae commented 11 months ago

"attic light" is not mentioned anywhere, except generated entity id. I have a suspicion that this was not defined by integration, as I dont see any possibility of that. If could be caused by new HA device linking. So it could be attac taken from device name and light from entity and truncating "attac" at the end as some sort of name consolidation. Can you rest of the screen from your first screenshot and also setting pages for both entities you underscored as red? Also can you test if that tracker entity really reacts to correct device?

clau-bucur commented 10 months ago

All these changes seem to be caused by changes in the Tasmota integration, starting with HA 2023.09. Some info can be found under: https://github.com/home-assistant/core/issues/100089

I have adjusted my device names to account for the changes.

We can close this one as seems it's not related to this integration. Thank you for your time!

tomaae commented 10 months ago

well, that explains why we could not find it anywhere, no matter how fine comb we used :)

Zarox666 commented 10 months ago

I seem to have the same with Shelly devices. But there was no change on the side of the Shelly integration.