Hey all,
I was looking into how to create polyogonal zones. Found some discussions about it and a couple of examples in node-red. I even found a proposal to integrate it into hass core. while waiting for a bit to see if there was any traction for it i decided to create a custom integration for it.
Enter my first integration, Polygonal zones. It is lacking in a large amount of features but it supplies a way to configure from the ui and the ability to easely store multiple zones.
The current version makes use of GeoJSON to store the zone information and shapely to check in which zone you are. there are a large amount of improvements that can still be made. The current version is a proof of concept i hope you guys can help me test.
Installing/Configuring the integration
installing the integration is as simple as copying the custom_components/polygonal_zones
folder into your config/custom_components
folder and following the configuration flow.
However before following the integration flow you need to create a geojson file accessible for a homeassistant via the web. the easiest place i found is to just place it into your config/www
folder. once you have done that you can simple configure the integration via the ui. the first field is for the url of the GeoJSON file and the second is the entities to track.
How it works
Once you have the integration configured it will create a sensor for each entity you selected. it will update this every time the location or accuracy of the tracked device changes.
What makes it different
Not much differentiates it form the different implementations there are but the biggest difference i can find is that it takes into account the accuracy of the gps signal. all other options i found just check the latitude and longitude. however that didnt work for me as i was using some realy inprecise gps trackers. besides that it isnt implemented in node red and is actualy functional
Limitations / TODO
There are still a large amount of things to improve. the biggest limitation currently is you cant track a single entity multiple times. besides that there are not tests for the code. also it might not work on armhf as i heard that shapely doesn’t support it(current is only tested on a intel nuc).
If you are interested in this please dont just use this but contribute to the discussion/proposal to get it integrated into core Allow zone to be a polygon · home-assistant/architecture · Discussion #1014 · GitHub. if you want to improve this my integration feel free to open a pr/issue.