Allow zone to be a polygon #1014
Replies: 9 comments 7 replies
-
+1, This feature would be particularly nice for me. When I walk around our lake loop where I live, my phone just barely catches the zone I call 'Home' and causes automations to fire off. The lake loop isn't a perfect circle, so I'd need to define two zones to cover the area I walk to prevent the trigger, or I'd need to make my zone for my home smaller, which is less than ideal since doing so would make automations that fire off when I actually do arrive home happen later than usual. I also park my car in different places occasionally, sometimes inside the 'Home' zone and sometimes right outside of it (despite it being here. I could make more circles, but even that isn't as granular as I'd like. |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
+1, my properly is oddly shaped and I'd even like to specify a zone within another (a "lot" versus an owned property such as an RV's allotted space in a much larger area). |
Beta Was this translation helpful? Give feedback.
-
Big kudos to @Misiu for his work. Where do we stand? What needs to be done to move this forward? In my opinion, this is one of the most needed changes. Circular zones simply won't serve their purpose and can only be treated as general areas, like near a station. When you have two parking lots next to each other and you want to implement two different automations depending on the parking lot - it's impossible. Not to mention that it's currently impossible to drive near the house and parking lot going from preschool to work, when the road is nearby, without triggering the automation. IMO even if for some reason the FE (geoman) is problematic to implement in HA in this case, the backend should implement it, giving possibilities to users, and then the FE can be delivered as a custom component from HACS or whatever. |
Beta Was this translation helpful? Give feedback.
-
Would love to see this implemented. The current system of only allowing circles is inherently flawed. not a single zone i am tracking is a circle and using multiple circles for a single zone is not a real solution. like mentioned before i want to track multiple zones that are close to each other which becomes close to impossible with circles. the primary locations where i am in need of this is my local race track. i would like to be able to differentiate between the track or the road that is near it, the karting track, or the buildings around it. or my collage campus where i want to track specific buildings or even wings of buildings and parking lots. The way this proposes would be an amazing way to Like @Baael says if the FE is the issue then i would still love it it was implemented. The current problem for the frontend is how would it the data be represented. Because if why implement something that doesn't have uses. If the problem is in what format to store the data i would like to suggest the GeoJson format. its easy to read and debug and supports whatever you want. due to the simplicity of the storage of the data and the large support both the current implementation of circles and the proposed situation of polygons can be rendered. GeoJSON even supports excalves. If geospatial data would be stored and rendered like this it would bring support for a large amount of different opportunities in the map. For testing in which zone we are the ray-casting algorithm suggested in issue #954 (comment) you can support en-/exclaves by simply testing all zones/polygons. rudimentary tests on a rpi zero w shows that millions of zones can be queried a second. So to reiterate. this would be absolutely amazing if this can be implemented. this would open a large amount of opportunities that the current zones don't offer. As this proposal only extends on the current spec for zones it should not break a single integration or feature. the only points that i could see that would prevent this would be lack of support for the frontend or the want for a better defined common way to store geospatial data. |
Beta Was this translation helpful? Give feedback.
-
I would really like to see polygonal zones implemented. I have several zones in HA and with the circle I can't define their area correctly |
Beta Was this translation helpful? Give feedback.
-
I'd love to see polygonal zones implemented, as well. I have a large rectangular property (4+ acres) and the "home" zone doesn't cover enough of it without "encroaching" on my neighbors' properties. Loving the GeoJSON as a part of implementing. |
Beta Was this translation helpful? Give feedback.
-
This is a great idea and something I would really appreciate in Home Assistant if it can be gotten over the line - I really hope it gets some attention soon! Currently, I have a few zones that are close together, and the limitation of circular zones prevents me from defining them accurately. I also have zones that are essentially "strips" which circles are not suitable for at all. Being able to define zones as polygons would give much more flexibility and allow for more precise zone design. Geojson would allow easy definition of complex zones where needed. Thanks for your work on this! |
Beta Was this translation helpful? Give feedback.
-
In the meantime, here's a simple custom template that lets you create your own Geofence template sensors: Usage example: DarkFox/ha-config/packages/automation/car/car_parking.yaml#L8-L100 |
Beta Was this translation helpful? Give feedback.
-
Context
Today, we can create Zones that are based on center point location and radius, this makes it hard to create Zones for places that are near to each other, like buildings, or parts of your backyard, because sometimes the circles may overlap each other:
Decision
We introduce two new properties to the Zone entity model:
zone_type
which can becircle
orpolygon
, withcircle
as the default to be backward compatiblepoints
which takes a list of points that define a polygonConsequences
Give the end users the ability to specify non-circular zones.
The change will allow picking zone type when creating new zone, or when editing zone.
Motivation:
With this change, we will be able to create such zones:
Additional informations
After getting approval, the next step would be to finish the implementation and move to frontend.
Ideally when adding or editing zones on the frontend the end user should have two options (circle, polygon). When choosing a circle he will get the functionality he has now. When choosing a polygon he should be able to create points that will form polygon for the zone (like in this demo: https://www.geoman.io/demo)
Of course, the zone type can be changed so users can move from circle zones to polygon zones. The editor should also allow editing zones (adding/moving/deleting points).
The original solution proposed using https://www.npmjs.com/package/@geoman-io/leaflet-geoman-free, but maybe something similar can be used.
I've created a PR (home-assistant/core#105729) that uses a simple ray-casting algorithm as suggested here: #954 (comment)
This discussion is similar to #954, so a common way of storing and processing coordinates would be useful for both solutions.
Beta Was this translation helpful? Give feedback.
All reactions