hass-core/homeassistant
Eric Hagan ed3f7d1581 OwnTracks work. Beacon logic and testcases (#10183)
* OwnTracks work. Beacon logic and testcases

The existing test cases don't really make clear what is being
tested and the iBeacon / Region / Zone / Tracker thing is all
a bit confused.

I'm distinguishing a fixed-place beacon used to trigger entrance
into an HA zone (as a Region Beacon) from a beacon affixed to a
portable or mobile object (as a Mobile Beacon). The behaviors
and test cases for those usages should be different. A Region Beacon
will be named the same as a Home Assistant Zone and seeing an event
from that beacon should trigger a device tracker update related
to that zone. It would be appropriate, though unnecessary, to
configure the Region Beacon with the GPS coordinates of its static
physical location.

A Mobile Beacon is not named after any HA Zone and seeing the beacon
triggers an update in HA setting the location of the beacon to the
current device_tracker location. In this way, when my_phone sees
the beacon on my_keys, the location of my_keys is set to where
my_phone is. And when my_phone stops seeing my_keys, my_keys location
is the location of my_phone the last time it saw them.

A Mobile Beacon's GPS information should be ignored because it's
almost certain to be incorrect because the beacon moves. In fact,
beacons typcially come configured with lat/lon as 0.0/0.0 so using
the location of the beacon in an update has a nasty habit of
setting you and your keys on the bottom of the Atlantic Ocean.

Leave message handling is changed to treat mobile beacons
differently from region beacons and gps regions.

active beacons should be a set. you shouldn't end up
with multiple "active" entries for the same beacon. Let's
enforce that with the correct data structure.

Added test for real-world bug that is fixed.
A series of mobile beacon and region beacon
enter and leave events could cause a mobile
beacon to stick to the tracking device even
though it had tracked through a "leave" event.

Changed two tests to look at the size
of the 'mobile_beacons_active' structure rather
than at the object which will allow this test
to work with any sort of list, set, etc.

* Removing excess logging and unnecessary try catch.

From review on PR #10183 I've removed some info logging
that was unnecessary and I've made the suggested changes
to an if block and a try/catch.
2017-10-31 00:18:45 -07:00
..
components OwnTracks work. Beacon logic and testcases (#10183) 2017-10-31 00:18:45 -07:00
helpers Consolidate frontend (#9915) 2017-10-24 19:36:27 -07:00
scripts update boto3 to 1.4.7 and botocore to 1.7.34 (#10121) 2017-10-29 10:24:56 +01:00
util Do not auto-install credstash (#9844) 2017-10-12 23:57:45 -07:00
__init__.py
__main__.py Added log-file command line flag (#9422) 2017-09-13 21:22:42 -07:00
bootstrap.py Fix spelling error (#10009) 2017-10-21 21:56:19 +02:00
config.py Fix load of components without any config from packages (#9901) 2017-10-17 09:59:33 +02:00
const.py Add entity_picture_template options to Template Cover, Template Light, Template Sensor, and Template Switch (#9854) 2017-10-30 09:28:37 -07:00
core.py Fix recorder crash for long state string - enforce at core level (#9696) 2017-10-25 09:05:30 -07:00
exceptions.py Fix recorder crash for long state string - enforce at core level (#9696) 2017-10-25 09:05:30 -07:00
loader.py RFC: Use bind_hass for helpers (#9745) 2017-10-08 08:17:54 -07:00
monkey_patch.py Make monkey patch work in Python 3.6 (#7848) 2017-06-01 23:23:39 -07:00
package_constraints.txt Update requests requirement (#9876) 2017-10-19 19:24:49 -07:00
remote.py Fix pylint 1.7.2 no-else-return issues (#8361) 2017-07-05 23:30:01 -07:00
setup.py Fix check for running inside venv (#8481) 2017-07-15 07:25:02 -07:00