Owntracks: Use bluetooth_le as source_type if beacon was used for location change. (#11615)
* Use bluetooth_le source_type, if location was changed by beacon * No reason to do nested ifs * Added tests for source_type on owntracks * Fixed The Hound * Added test and fixed bug surfaced by test
This commit is contained in:
1 parent
0859e38bd5
commit
536424b0c8
2 files changed
+40
-1
No files matched your search
@@ -316,6 +316,11 @@ class BaseMQTT(unittest.TestCase):
|
||||
state = self.hass.states.get(DEVICE_TRACKER_STATE)
|
||||
self.assertEqual(state.attributes.get('gps_accuracy'), accuracy)
|
||||
|
||||
def assert_location_source_type(self, source_type):
|
||||
"""Test the assertion of source_type."""
|
||||
state = self.hass.states.get(DEVICE_TRACKER_STATE)
|
||||
self.assertEqual(state.attributes.get('source_type'), source_type)
|
||||
|
||||
|
||||
class TestDeviceTrackerOwnTracks(BaseMQTT):
|
||||
"""Test the OwnTrack sensor."""
|
||||
@@ -666,6 +671,32 @@ class TestDeviceTrackerOwnTracks(BaseMQTT):
|
||||
# Location update processed
|
||||
self.assert_location_state('outer')
|
||||
|
||||
def test_event_source_type_entry_exit(self):
|
||||
"""Test the entry and exit events of source type."""
|
||||
# Entering the owntrack circular region named "inner"
|
||||
self.send_message(EVENT_TOPIC, REGION_GPS_ENTER_MESSAGE)
|
||||
|
||||
# source_type should be gps when enterings using gps.
|
||||
self.assert_location_source_type('gps')
|
||||
|
||||
# owntracks shouldn't send beacon events with acc = 0
|
||||
self.send_message(EVENT_TOPIC, build_message(
|
||||
{'acc': 1}, REGION_BEACON_ENTER_MESSAGE))
|
||||
|
||||
# We should be able to enter a beacon zone even inside a gps zone
|
||||
self.assert_location_source_type('bluetooth_le')
|
||||
|
||||
self.send_message(EVENT_TOPIC, REGION_GPS_LEAVE_MESSAGE)
|
||||
|
||||
# source_type should be gps when leaving using gps.
|
||||
self.assert_location_source_type('gps')
|
||||
|
||||
# owntracks shouldn't send beacon events with acc = 0
|
||||
self.send_message(EVENT_TOPIC, build_message(
|
||||
{'acc': 1}, REGION_BEACON_LEAVE_MESSAGE))
|
||||
|
||||
self.assert_location_source_type('bluetooth_le')
|
||||
|
||||
# Region Beacon based event entry / exit testing
|
||||
|
||||
def test_event_region_entry_exit(self):
|
||||
|
||||
Reference in new issue
Block a user