How are sensors related to the "master" device?

Hi all. I have just started using the Companion app and it works very well. I have several iPhones using the app and each appears in the “integration” part of the system (as expected). All of the iPhones show several sensors - battery, steps, location etc. Very cool.

Now - when I catch an event when a device_tracker is being updated I also want to get some info from the geocoded_location-sensor that belongs to the same iPhone. The question is how I find the link between the two…

Example:
The mobile app “Jeas iPhone” has several sensors, for example:

  1. device_tracker.jeas_iphone_3 shows lat/long and other info.
  2. sensor.geocoded_location_2 shows address, country etc.

If I (in appdaemon) know the entity_id=device_tracker.jeas_iphone_3, how do I find out it is related to sensor.geocoded_location_2? I can’t see any attributes in any of the entities that points on a “master” entity or similar. The MobileApp integration must have stored this info somewhere but I can’t figure out where. I would like to send a customized notification to the mobile app offering to open the garage door when the device is close to home and moving fast enough. Not a question of life and death but since it can be done it has to be done.

I would like to keep the code as generic as possible and not have to hard code these relations.

There is probably something fundamental and simple I have missed - do you know what??

I don’t think this is possible or at least it will probably be very hard to do.
Why do you need to hardcode the relations? You could create a dict for each person in a separate pyrhon file containing all sensors, device tracker, whatever belongs to this person and then import this dict in your notification app. That’s what I do. Another option would be consistent naming of entities, e.g. all entities that belong to Jack’s phone start with phone_jack, device_tracker.phone_jack, sensor.phone_jack_battery_level etc.

Thank you @Burningstone, I almost suspected that. I wonder why it is like that, devices with the same origin not being easy to identify… but that is a question for another day and forum.
Yes, I am using a dict where I list some entities that belong to each family member but I was hoping to be able to get rid of that and just maintain the “person” items.

1 Like