I have a device on my network that always changes the last 6 digits of its mac address when it connects.
Is there any way, maybe with templates or similar, to use wildcards to add all these devices under a single person entity, or perhaps a sensor? (i.e. device_tracker.AA_BB_CC_* to give me all devices beginning with that combination…)
Appreciate any pointers in the right direction.
Personally, I’d look into turning that MAC randomization feature off for your home network. E.g., on my Samsung Android phone, it’s a setting per WiFi network: Randomized MAC or Phone MAC.
Thanks, but unfortunately it doesn’t seem to be switchable on the device itself. It’d be a handy fix.
So hoping for a solution on the HASS side for the moment…
Ok. The only solution I can think of right now is to use the device_tracker.see
service to sort of make a composite/compound device tracker out of these via an automation, then use that for the person
entity. If you could tell me what attributes these entities have, I could provide a concrete example.
Thanks, Phil.
I’m not 100% sure I follow tho, do you mean the device tracker entity attributes?
If so they only have source_type
and friendly_name
, which is automatically populated with the current mac address of the device when it connects.
And source_type
is router
?
Ok, how about something like this:
- trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
template: >
{{ trigger.event.data.entity_id|regex_match('device_tracker\.AA_BB_CC_.*') }}
action:
- service: device_tracker.see
data_template:
dev_id: AA_BB_CC
source_type: router
location_name: "{{ trigger.event.data.new_state.state }}"
This should create/update entity device_tracker.AA_BB_CC
whenever any device tracker entity is created or updates whose entity_id starts with device_tracker.AA_BB_CC_
.
Amazing, thank you. I’ll try this out and see how I get on.
No problem. I used that service before I wrote my custom composite tracker integration. (Which, BTW, I would have recommended if I had thought it would solve your problem, but it wouldn’t. )
Thank you for this example. It has a couple new things in it for me to learn.
One question though, won’t this automation run for every state_changed
event for all entities? Is that a problem?
I don’t see an alternative, I’m just checking.
Yes, it will. This is an old post, and I haven’t reviewed the details, so I don’t know if there’s a better way to do what you want. You might want to open a new topic if you’d like further help.