Closed emresumengen closed 4 years ago
Hey there @engrbm87, mind taking a look at this issue as its been labeled with a integration (mikrotik
) you are listed as a codeowner for? Thanks!
Hello @emresumengen , devices are identified by their MAC address, if you are using Wireless interface for detection then make sure that the device with same mac address is showing in the registration table in both hubs.
Hello @engrbm87, As these are two independent mikrotik APs, their wireless registration tables are also independent of each other. But, the device is seen on either R1 (10.0.0.1) or AP1 (10.0.0.2) registration table, depending on which device the client is connected to.
For example (my phone mRxs with mac C0:A6:00:27:E4:37): on R1 (10.0.0.1) clearly is connected:
/interface wireless registration-table print where mac-address="C0:A6:00:27:E4:37"
# INTERFACE RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME
0 ;;; mrXS
wlan1-5g C0:A6:00:27:E4:37 no -83dBm@6Mbps 6Mbps 24s
and HA shows the device HOME.
Similarly, when I'm in the other room, same device is seen as such in AP1's registration table. But then HA shows it AWAY.
Essentially, it cannot be seen registered in the wireless registration table in both hubs at the same time, unless it's CAPsMAN, which means the registration table is centralized. Again, this is a setup where the devices are not centralized.
This was working perfectly fine, without CAPsMAN.
@engrbm87, any comments or questions? I can try to help diagnose further, if necessary to find a solution.
I also have 2 hubs with separate registration tables and the entities are updating just fine. Can you please confirm if you have enabled force_dhcp or arp_ping? Also if you check the integration page are the devices showing under the second hub when the device is connected to that one?
Hello @engrbm87 , No, I don't have force_dhcp or arp_ping enabled on either of the hubs. Configuration is like this:
Also, some devices are shown under each hub on the integration page. I tried to check for a specific device to see if it's shown under the specific hub, but when I click either of them, the page lists all devices found from Mikrotik integrations, independent of which. So, even if I click hub1 (R1), it shows all devices including that are connected to 2nd hub (AP1).
One thing to add, though: Some devices (like my phone - mRxs at the bottom) are shown as "Mikrotik, Mikrotik" as the "integration", while others only show "Mikrotik"...
I'm guessing this implies the relevant device is discovered through both hubs?
Still, this device is shown as Away when my phone roams to AP1.
While connected to R1:
But, when I move and roam to AP1:
The device is clearly still connected to the network.
[emre@mrmt-ap1] > /interface wireless registration-table print where mac-address="C0:A6:00:27:E4:37"
# INTERFACE RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME
0 wlan1-5g C0:A6:00:27:E4:37 no -60dBm@6Mbps 866.... 2m12s
Do you have any devices that show Home while connected to AP1? What happens when these connect to R1?
No, not really. But it's mainly because I'm tracking only a few devices (mobile phones), and they are exhibiting this problem. I tried now, as an example, to turn off my Wifi, wait for HA to show me AWAY, walk to AP1 range, and reconnect. Even after 10 minutes, HA still showing me AWAY.
I can try to remove the integrations, reboot, add them back and then test with a mobile phone. I'll update as soon as I finish testing, but honestly, I don't think it will work as expected.
Hey @engrbm87 ,
I did some testing... First removed both Mikrotik integrations, rebooted, and added through the configuration flow. Did not choose arp_ping or force_dhcp, and left detection_time at default (300?)...
I used a laptop (mac address 30:35:AD:CA:6A:00) for the test. This laptop normally resides in AP1 coverage. So, it was first detected through it's integration. It was showing HOME...
While in AP1 coverage (where it was first detected while installing the integrations):
[emre@mrmt-ap1] > interface wireless registration-table print where mac-address="30:35:AD:CA:6A:00"
# INTERFACE RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME
0 ;;; Asemin-MBA
wlan1-5g 30:35:AD:CA:6A:00 no -58dBm@6Mbps 173.... 1h4m11s
[emre@mrmt-ap1] >
Then I moved it into R1 coverage area... At first, it kept showing HOME. Everything was intact, besides the fact that the device had a name now (out of the blue, probably because R1 has DHCP leases and AP1 does not?).
While in R1 coverage (at first):
Then, after a few minutes (without changing anything, laptop still in R1 coverage), it started showing AWAY.
While still in R1 coverage (after some time, like 5-6 minutes):
Nothing else changed.
When I took it back to AP1 coverage area, it started showing as HOME again...
It just is not logical, at least to me. Hopefully these tests show where the issue is.
By the way, when I move devices between the rooms, I get the below errors from [homeassistant.core]:
2020-03-17 23:42:09 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 425, in _async_add_entity
raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: device_tracker.mrpro10. Platform mikrotik does not generate unique IDs
2020-03-17 23:59:09 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 425, in _async_add_entity
raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: device_tracker.30_35_ad_ca_6a_00. Platform mikrotik does not generate unique IDs
2020-03-18 00:26:49 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 425, in _async_add_entity
raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: device_tracker.50_ec_50_41_e6_69. Platform mikrotik does not generate unique IDs
Within those logs, the entity device_tracker.30_35_ad_ca_6a_00 is the laptop I was moving around, as well as my iPad Pro (device_tracker.mrpro10) and the Xiaomi Hub (device_tracker.50_ec_50_41_e6_69) which sits in the overlapping wireless coverage area (thus, roaming from one to the other time-to-time).
Hello @engrbm87 ,
Anything else I can check?
This looks like a problem with the integration. Were you able to look into it (and hopefully identify the culprit)?
Because of this issue, I have no tracking at all, since 106.5... Would really appreciate a workaround or a solution...
@balloob, need your help on this. What is happening is that when the device moves to another hub configured as a different integration, the integration tries to create the entity but it already exists. This stops the integration from updating the entity and the device_tracker becomes away
because it is no longer connected to the first hub.
That means that the unique IDs are not unique. The unique IDs of an entity should be based on a unique identifier of the hub + device.
But in our case we don't want to create a new entity. This is the same entity but discovered by a different hub. How can we link the entity (or device) to update via the new hub once it has been discovered by it?
Devices are linked via the device registry, by setting the correct device id, eg mac address.
Multiple entities can be linked to the same device, so we probably want one entity per hub, for each device.
Hello @MartinHjelmare , having mulitple device_tracker entities linked to the same device will not solve our problem. The user expects one device_tracker entity to represent the device state (home
or away
).
is there a way to check if an entity already exists and then have it updated through a different integration (for example by subscribing to the other integration topic and update its state).
The person integration can have multiple device tracker entities tracking for each person. Is it really a problem to have two or more entities per device?
This would work for tracking persons, but for tracking other types of devices I don't think this would be practical. An idea would be to have a state for the registered device itself based on the states of the linked entities but that would require new code as devices don't have state right now.
Unless there is a way to update an entity from multiple hubs (integrations) I guess our only option is to have multiple entities per device. What do you recommend?
Alternative solution is that you structure the integration differently. Your code should abstract the different hubs and just provide entities with an attribute which hub saw it instead of going through each hub and add entities for it.
Thank you for the idea. If you can help me on this I would appreciate it. Is there any existing integration that uses this structure so that I can follow it. I am not an expert coder but I would like to enhance this integration.
I have no time to help with that.
I can give you a quick pointer. You need to create a class that is queried for available entities. That class will hold all data for all the hubs and exposes them to Home Assistant through the existing code, but as if it is 1 hub.
Unless there is a way to update an entity from multiple hubs (integrations) I guess our only option is to have multiple entities per device.
Hello @engrbm87 ,
I personally can say that using person
entity as well as the composite custom-component
, I can definitely make do with multiple entities per device (one per hub). But, if I can add the entities manually to a hub (like we did with known_devices.yaml
file, instead of waiting for the device to be discovered automatically), it would be pretty well.
Just my 2 cents...
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
Running multiple independent Mikrotik APs (hubs?), HA integration seems to be able to track clients only on 1 of the APs (1st one added?). When the client roams to the 2nd AP, it is marked AWAY.
Environment
Problem-relevant
configuration.yaml
Traceback/Error logs
Additional information
I am running 2 x Mikrotik APs on the same network. I cannot run CAPsMAN because of Mikrotik limitations. APs are 10.0.0.1 and 10.0.0.2. They are both added through configuration flow, and logs indicate HA connects to them both (at first). But then it seems that only 1st one is being queried. In the above logs, device_tracker.asemin (B0:48:1A:72:55:A1) was connected to the 2nd AP (10.0.0.2) but HA showed it as AWAY.