diff --git a/homeassistant/components/device_tracker/owntracks.py b/homeassistant/components/device_tracker/owntracks.py index 44ae0359ff6..e2a238a5656 100644 --- a/homeassistant/components/device_tracker/owntracks.py +++ b/homeassistant/components/device_tracker/owntracks.py @@ -190,7 +190,7 @@ def setup_scanner(hass, config, see): return # OwnTracks uses - at the start of a beacon zone # to switch on 'hold mode' - ignore this - location = slugify(data['desc'].lstrip("-")) + location = data['desc'].lstrip("-") if location.lower() == 'home': location = STATE_HOME @@ -198,7 +198,7 @@ def setup_scanner(hass, config, see): def enter_event(): """Execute enter event.""" - zone = hass.states.get("zone.{}".format(location)) + zone = hass.states.get("zone.{}".format(slugify(location))) with LOCK: if zone is None and data.get('t') == 'b': # Not a HA zone, and a beacon so assume mobile @@ -227,7 +227,8 @@ def setup_scanner(hass, config, see): if new_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) _LOGGER.info("Exit to %s", new_region) see(**kwargs) diff --git a/tests/components/device_tracker/test_owntracks.py b/tests/components/device_tracker/test_owntracks.py index 183bbbd994f..4bea0d3d0b3 100644 --- a/tests/components/device_tracker/test_owntracks.py +++ b/tests/components/device_tracker/test_owntracks.py @@ -377,7 +377,7 @@ class TestDeviceTrackerOwnTracks(BaseMQTT): message = REGION_ENTER_MESSAGE.copy() message['desc'] = "inner 2" self.send_message(EVENT_TOPIC, message) - self.assert_location_state('inner_2') + self.assert_location_state('inner 2') message = REGION_LEAVE_MESSAGE.copy() message['desc'] = "inner 2"