I think we should be able to set zones that are square shaped, rectangular shaped… Or even be able to set streets as zones, so they can be used for automations.
100% agree. Defined zones (point and click to create a boarder) would be fantastic. Especially for much larger zones to fit awkward shaped areas without encroaching on others, or needing to create multiple for the same area. Such as lakes, beaches, or city limits.
I guess this is related to a limitation on the battery-saving features of mobile phones. I guess phones can easily notify apps if the location is somewhere around a point; but doing the same with arbitrary polygons can be more difficult. Still, I don’t know, and I could be completely wrong here.
I also might be wrong, but surely the phone just sends it’s GPS coordinates and HA works out if it is in that zone or not?
Maybe someone who knows more about the inner workings of the mobile app can shed some light on it.
Absolutely! We should be able to make different shaped zones.
I use a simple appdaemon app to use polygon zones, would be great to have this integrated
I think there was a feature request for this also. I also would like to see polygon zones. My use case is tracking which yard the automower is in. I currently accomplish this through the integration, but it should be done in Home Assistant.
Point and click defined polygon shaped zones would be a game changer.
I would also be insanely happy with a “general zone” which maintains the functionality we currently have, and a “precise zone” which implements this new functionality.
I was thinking it would be good to choose which entities are tracked to the polygonal zones level. I don’t need to know if my phone is in the front yard, just that it’s home. I really only want specific entities, in my case the mower to be compared against the polygonal zones.
Mobile phones only support geofencing with circular zones, and geofencing is what ensures your phone wakes up and sends back a location update. Supporting polygonal zones for mobile phones would basically require the phone to send location updates much more frequently draining battery, rather than send them periodically, and when the system geofence feature triggers.
That said, for any devices that do report longitude and latitude frequently, then conceptually home assistant could be upgraded to handle polygonal zones. The issue then becomes though that one of the most common uses for zones (tracking phones, tablets, and similar devices) won’t work very well with such zones.
This will not work well with the rest of services that use zones like the Android app. Most geofencing apps take the zone radius. You can’t do that in another shape properly if you want accurate zone tracking.
it was annoying me too, so I made it myself.
- I added new zone integration called polygon_zone with additional property
- used it with
- hacked zone component methods
in_zone, so if it has
I am checking if latitude and longitude are within polygon:
from shapely.geometry import Point, Polygon (...) point = Point(latitude, longitude) if 'points' in zone.attributes: polygon = Polygon(zone.attributes['points']) if polygon.contains(point): return zone else: # use original function
from homeassistant import components (...) components.zone.async_active_zone = polygon_async_active_zone components.zone.in_zone = polygon_in_zone (...)
as frontend I used leaflet and
And it works much much better than zones with radius. No more issues with triggering zones enter/leave because road is nearby parking, or overlapping zones etc.
Overriding original methods allows automation triggers to work correctly, and original zones are still supported.
WTH moment: why zone trigger do not have time field “for 5 minutes” or something like that?
Try and add it to GitHub and see if they can adopt it in native HA