allow ios device tracker see calls to go through (#13020)

This commit is contained in:
Paulus Schoutsen 2018-03-09 19:39:50 -08:00
parent ca973b68e0
commit 34c694c20e
2 changed files with 23 additions and 1 deletions

View File

@ -111,6 +111,9 @@ SERVICE_SEE_PAYLOAD_SCHEMA = vol.Schema(vol.All(
ATTR_ATTRIBUTES: dict,
ATTR_SOURCE_TYPE: vol.In(SOURCE_TYPES),
ATTR_CONSIDER_HOME: cv.time_period,
# Temp workaround for iOS app introduced in 0.65
vol.Optional('battery_status'): str,
vol.Optional('hostname'): str,
}))
@ -219,7 +222,11 @@ def async_setup(hass: HomeAssistantType, config: ConfigType):
@asyncio.coroutine
def async_see_service(call):
"""Service to see a device."""
yield from tracker.async_see(**call.data)
# Temp workaround for iOS, introduced in 0.65
data = dict(call.data)
data.pop('hostname', None)
data.pop('battery_status', None)
yield from tracker.async_see(**data)
hass.services.async_register(
DOMAIN, SERVICE_SEE, async_see_service, SERVICE_SEE_PAYLOAD_SCHEMA)

View File

@ -730,3 +730,18 @@ async def test_old_style_track_new_is_skipped(mock_device_tracker_conf, hass):
await hass.async_block_till_done()
assert len(mock_device_tracker_conf) == 1
assert mock_device_tracker_conf[0].track is False
def test_see_schema_allowing_ios_calls():
"""Test SEE service schema allows extra keys.
Temp work around because the iOS app sends incorrect data.
"""
device_tracker.SERVICE_SEE_PAYLOAD_SCHEMA({
'dev_id': 'Test',
"battery": 35,
"battery_status": 'Unplugged',
"gps": [10.0, 10.0],
"gps_accuracy": 300,
"hostname": 'beer',
})