How to combine device tracker - device connecting to router gives random mac address

Device connecting to router randomly get different mac address so in known devices i get
time to time a new device.

the name for newly added device is always the same but changes number at the end.

Question: how to combine device tracker entities that are today and will appear in the future to have as one device?

Assuming that the device is a mobile / tablet (running a recent iOS / Android release) the correct (and easiest) way to resolve this is to set the device to use the device MAC instead of a randomised address.
For Android this can be done in the advanced settings for that Wireless Network - I don’t use iOS so not familiar with where to resolve this on an Apple device.

2 Likes

MAC is used from router integration side with HA. QUestion is more about how to combine those 10+ and growing number of known devices (entities are created but with new name every time, but naming is systematical - android XXXXX_10, android XXXXXX_11) - so how to combine them?

I understood the question and the context - you want to combine future device_trackers generated by a single device each time it connects to the router. If the android device is set to randomise it’s MAC on connection to the router, it will be associated to a newly generated device_tracker on each connection. The router is seeing the device as a new device, and the device_tracker integration is behaving as it should.

I know of no consistent and reliable way to programmatically combine multiple device_tracker entities within HA, although I suppose it might be possible. This approach would still inevitably leave you with multiple redundant device_trackers in your entity registry, additional maintenance work and potential impact on your system that seems unnecessary IMHO.

Is there a particular reason you are against resolving the issue with a single client-side change?

You understood right.

The device itself is too dumb (kid smartwatch) and it has no possibilities to interract with OS.
Entities are changing, but naming convention is the same, even friendly name is exactly the same.

P.S. Not all the time devices connects it is making new entity, so not a big deal of several new per month :slight_smile:

Ah - that makes sense now. Thanks for clarifying.

Some thoughts (untested, off the top of my head) based on some quick Googling and a dig around our office HA developer tools and my own config files.

  • The device_tracker_new_device event should give you the new entity ids as they are created. You should be able to use a template condition to match the expected tracker name pattern.

  • You can in fact maintain a group programmatically (or so I’ve learned):

service: group.set
data:
   object_id: test_group
   name: My test group
   view: true
   icon: 'mdi:camera'
   control: hidden
   visible: true 
   entities: 'domain.entity_id1, domain.entity_id2'
   add_entities: 'domain.entity_id1, domain.entity_id2'
   all: true

NB: all Enable this option if the group should only turn on when all entities are on.

You should then be able to reference the group in automations.

Good luck!