Master Device - What do I need to build?

Hi devs,

I want to build a “thing” that lets me summarise different devices into a master device.
At the moment I have multiple trackers for some of my gadgets. Like my mobile has the iOS app and the nmap detection. Then I have an AP in my network that changes the mac address when a device is connected thru there. So I have 2 nmap devices for the same mobile. Same for the laptops.
On top of that I currently use template sensors to change home/not_home into online/offline on/off for some of my things. Like my PC is always home, but not always on. So if my gadget is a mobile I want to do certain things, if it is a server some others, and I want to automatically hide the original trackers.

something like

- name: my_mobile
  type: mobile
  device_trackers:
    - device_tracker.nmap_mobile_1
    - device_tracker.nmap_mobile_2
    - device_tracker.ios_mobile_1

- name: my_server
  type: server
  device_trackers:
    - device_tracker.nmap_server1

this should result in a new device(?) that is called my_mobile and aggregates the other 2 devices.
and a new my_server that translates home/not_home into online/offline.
In an advanced version I want to be able to define priorities on how to aggregate the devices.
(Battery from dev1, location from dev2 …)

So here my question, what do I need to build?
Just a new device_tracker?
A new component?
A new platform?
Somehow I can’t get my answer from the documentation.
Is there a similar thing out there that I could copy from?

Once I get this sorted, it might feed nicely into this idea: Person Component (Users)

thanks!

Can you not do all of this with groups already?

1 Like

I don’t think so, but if I can, that would be great.
Maybe I can group the individual trackers into one device (group) , need to try that. But then I want to chage the state from home/not_home to online/offline. And I want to set priorities between tackers for different things.
Battery might come from one, location from another and I want to hide the individual devices.
Yes, probably it is possible in standard configuration, but requires a lot of different statements and repetition.
Maybe I can just simplify this by writing some code. I am just not sure where to start?

Changing the state to online/offline is easy (I’m told) using a template sensor, then group the sensors.

Groups do not have to contain identical devices, so I suspect you can use groups for most of what you’re trying to do.

Please could you define: “I want to set priorities between tackers for different things”?

Yes, I am using the template sensor now to do online/offline.
It is easy, but I have to do it over and over again.
Don’t get me wrong, it is possible, but I am looking for an easier way.

  customize:
    device_tracker.roku:
      hidden: true
    sensor.roku:
      icon: mdi:camcorder-box
      friendly_name: Roku
sensor:
  - platform: template
    sensors: 
      roku:
        value_template: '{% if is_state("device_tracker.roku", "home") %}Online{% else %}Offline{% endif %}'

but it is getting long and cumbersome:

Even if I could wrap that into a little script it would make my config so much easier to maintain…

Regarding Priorities, I am thinking that the nmap tracker is better at knowing when something is home. If it detects a mac address, it is certainly home. But when the mobile is off or asleep it does not work so well anymore. Then a different tracker might be better. That kind of priorities.

I’m thinking using customize_glob solves the first issue,no need for a script, just making sure that the pattern fits for what the device names are, and whether you want them visible or not.

For priorities, when you group several trackers together the group shows home if one device is home. So if you have a group called datamonkey with your GPS tracker, and your nmap tracker and whatever else, so long as one is home that one is already the priority. So like if the phone goes to sleep, the nmap will show away, but the last ping on the GPS is still home, so your group will be home.

I’m not saying your idea is wrong btw, I’m just suggesting ways to achieve what you want with the current infrastructure :thumbsup:

Nice, I didn’t know about this! Will give it a try, this will certainly make my stuff a lot neater!

Now, lets say I am just stubborn and I want to try and write a script and learn some python on the way… what would I build?

Good question, don’t know, somebody else will have to help with that :smile:

1 Like

Hi,
the customize_glob worked well, I actually ended up using customize_domain to hide all device_trackers.
And I moved the icon definition to the template_sensor.
Still, I have one template_sensor per device to do the online/offline.
But at least all the customization is now in one spot per device.

1 Like

If you wait long enough somebody else will fix it.

Thanks

1 Like