mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Fix OwnTracks state names (#5454)
* Fix OwnTracks state names (#5453) * Update owntracks.py * Update tests
This commit is contained in:
parent
6e94f0d7cd
commit
b5f285a789
@ -190,7 +190,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 = slugify(data['desc'].lstrip("-"))
|
location = data['desc'].lstrip("-")
|
||||||
if location.lower() == 'home':
|
if location.lower() == 'home':
|
||||||
location = STATE_HOME
|
location = STATE_HOME
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ def setup_scanner(hass, config, see):
|
|||||||
|
|
||||||
def enter_event():
|
def enter_event():
|
||||||
"""Execute enter event."""
|
"""Execute enter event."""
|
||||||
zone = hass.states.get("zone.{}".format(location))
|
zone = hass.states.get("zone.{}".format(slugify(location)))
|
||||||
with LOCK:
|
with LOCK:
|
||||||
if zone is None and data.get('t') == 'b':
|
if zone is None and data.get('t') == 'b':
|
||||||
# Not a HA zone, and a beacon so assume mobile
|
# Not a HA zone, and a beacon so assume mobile
|
||||||
@ -227,7 +227,8 @@ def setup_scanner(hass, config, see):
|
|||||||
|
|
||||||
if new_region:
|
if new_region:
|
||||||
# Exit to previous region
|
# Exit to previous region
|
||||||
zone = hass.states.get("zone.{}".format(new_region))
|
zone = hass.states.get(
|
||||||
|
"zone.{}".format(slugify(new_region)))
|
||||||
_set_gps_from_zone(kwargs, new_region, zone)
|
_set_gps_from_zone(kwargs, new_region, zone)
|
||||||
_LOGGER.info("Exit to %s", new_region)
|
_LOGGER.info("Exit to %s", new_region)
|
||||||
see(**kwargs)
|
see(**kwargs)
|
||||||
|
@ -377,7 +377,7 @@ class TestDeviceTrackerOwnTracks(BaseMQTT):
|
|||||||
message = REGION_ENTER_MESSAGE.copy()
|
message = REGION_ENTER_MESSAGE.copy()
|
||||||
message['desc'] = "inner 2"
|
message['desc'] = "inner 2"
|
||||||
self.send_message(EVENT_TOPIC, message)
|
self.send_message(EVENT_TOPIC, message)
|
||||||
self.assert_location_state('inner_2')
|
self.assert_location_state('inner 2')
|
||||||
|
|
||||||
message = REGION_LEAVE_MESSAGE.copy()
|
message = REGION_LEAVE_MESSAGE.copy()
|
||||||
message['desc'] = "inner 2"
|
message['desc'] = "inner 2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user