architecture icon indicating copy to clipboard operation
architecture copied to clipboard

Allow zones for device tracker scanners

Open akloeckner opened this issue 4 years ago • 6 comments
trafficstars

Context

Currently, device scanners can only “see“ tracked devices for the home zone. But as the world gets more connected, so do HA users. E.g., I have a network of VPN-connected routers. So, not every router is in the home zone.

Proposal

I suggest to allow device trackers to work in that kind of setup by allowing the user to associate a zone to a device scanner, which will be used instead of home for seen devices.

We should extend the device tracker perform schema with a zone option, defaulting to the home zone.

I was referred here from https://github.com/home-assistant/core/pull/43390, because that would need changing the ScannerEntity

https://github.com/home-assistant/core/blob/2741362b23a35e3806384882b61374af1e591957/homeassistant/components/device_tracker/config_entry.py#L130

by adding some features from the TrackerEntity, namely at least state and location_name. Ideally, the latter would be taken from the configuration by default, so implementations don't need to be updated to get this feature.

Consequences

This would factually unify the two tracker variants (because, allowing GPS additionally would be straight forward). But i don't see really, why there are two different base classes anyways (except for the default state implementation). Maybe things downstream might become more complicated, such as grouping device trackers. But this already needs to handle different zones because of GPS trackers. Maybe, integrations would need to update to reflect this. But we could make it seemless by providing a default implementation as lined out above.

In summary, i think there's no downside. But many upsides, the main two of which are:

  • we could use zones with scanners
  • we could get rid of two (then) marginally different base classes.

akloeckner avatar Nov 20 '20 16:11 akloeckner

@MartinHjelmare, you refered me here. I'd appreciate your advice. Is there any activity to be expected on that issue? How should we proceed in this matter (if at all)? We could e.g. wait here, invite devs to discuss, craft a bigger PR, ...

akloeckner avatar Feb 09 '21 10:02 akloeckner

There needs to be some interest from other members to start a discussion about this.

MartinHjelmare avatar Feb 09 '21 11:02 MartinHjelmare

Ok. So, I take this as a "wait and see", which I will do, but I won't actively follow up on this idea unless someone else picks it up... I'll be here to discuss in that case!

akloeckner avatar Feb 09 '21 11:02 akloeckner

Before letting go of it, I went through some other issues here to link them up.

  • One go at my suggestion could also be to run a small "remote HA server" as discussed here: https://github.com/home-assistant/architecture/issues/246
  • Here is some discussion on the way zones are combined for a person, which is a prerequisite for my suggestion: https://github.com/home-assistant/architecture/issues/163
  • Taking into account the place where the information is stored (user has a zone, or zone has many unsers) might be related: https://github.com/home-assistant/architecture/issues/311

akloeckner avatar Feb 09 '21 12:02 akloeckner

Just found this thread after investigating lack of zone for ScannerEntity. I'd support adding zone for the same reason as described by @akloeckner - I have two homes with routers constantly connected via VPN into one network. And currently I'm not able to use device_trackers for both locations without reinventing the square wheel... Only because ScannerEntity doesn't have zone.

gnezdin avatar Jul 22 '22 15:07 gnezdin

BTW the problem itself is not so rare, for instance there are 2.6K views in this thread: [Device Tracker] Associate a device tracker to different zone

gnezdin avatar Jul 22 '22 15:07 gnezdin

That would be a great feature. Long overdue for HA to be able to manage more than one location.

davidwuest avatar Apr 11 '23 17:04 davidwuest

This architecture issue is old, stale, and possibly obsolete. Things changed a lot over the years. Additionally, we have been moving to discussions for these architectural discussions.

For that reason, I'm going to close this issue.

../Frenck

frenck avatar May 11 '23 14:05 frenck