home-assistant / architecture

Repo to discuss Home Assistant architecture
313 stars 100 forks source link

Allow zones for device tracker scanners #463

Closed akloeckner closed 1 year ago

akloeckner commented 3 years ago

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:

akloeckner commented 3 years ago

@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, ...

MartinHjelmare commented 3 years ago

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

akloeckner commented 3 years ago

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 commented 3 years ago

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

gnezdin commented 2 years ago

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 commented 2 years ago

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

davidwuest commented 1 year ago

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

frenck commented 1 year ago

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