mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Handle region enter/leave with spaces.
This commit is contained in:
parent
5f98a70c21
commit
dd1703469e
@ -11,7 +11,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
from homeassistant.const import STATE_HOME
|
from homeassistant.const import STATE_HOME
|
||||||
from homeassistant.util import convert
|
from homeassistant.util import convert, slugify
|
||||||
|
|
||||||
DEPENDENCIES = ['mqtt']
|
DEPENDENCIES = ['mqtt']
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ def setup_scanner(hass, config, see):
|
|||||||
return
|
return
|
||||||
# OwnTracks uses - at the start of a beacon zone
|
# OwnTracks uses - at the start of a beacon zone
|
||||||
# to switch on 'hold mode' - ignore this
|
# to switch on 'hold mode' - ignore this
|
||||||
location = data['desc'].lstrip("-")
|
location = slugify(data['desc'].lstrip("-"))
|
||||||
if location.lower() == 'home':
|
if location.lower() == 'home':
|
||||||
location = STATE_HOME
|
location = STATE_HOME
|
||||||
|
|
||||||
|
@ -230,6 +230,20 @@ class TestDeviceTrackerOwnTracks(unittest.TestCase):
|
|||||||
# Left clean zone state
|
# Left clean zone state
|
||||||
self.assertFalse(owntracks.REGIONS_ENTERED[USER])
|
self.assertFalse(owntracks.REGIONS_ENTERED[USER])
|
||||||
|
|
||||||
|
def test_event_with_spaces(self):
|
||||||
|
"""Test the entry event."""
|
||||||
|
message = REGION_ENTER_MESSAGE.copy()
|
||||||
|
message['desc'] = "inner 2"
|
||||||
|
self.send_message(EVENT_TOPIC, message)
|
||||||
|
self.assert_location_state('inner_2')
|
||||||
|
|
||||||
|
message = REGION_LEAVE_MESSAGE.copy()
|
||||||
|
message['desc'] = "inner 2"
|
||||||
|
self.send_message(EVENT_TOPIC, message)
|
||||||
|
|
||||||
|
# Left clean zone state
|
||||||
|
self.assertFalse(owntracks.REGIONS_ENTERED[USER])
|
||||||
|
|
||||||
def test_event_entry_exit_inaccurate(self):
|
def test_event_entry_exit_inaccurate(self):
|
||||||
"""Test the event for inaccurate exit."""
|
"""Test the event for inaccurate exit."""
|
||||||
self.send_message(EVENT_TOPIC, REGION_ENTER_MESSAGE)
|
self.send_message(EVENT_TOPIC, REGION_ENTER_MESSAGE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user