From 5900d8a2c1ece557dac8a91225c701ca84e0a9b1 Mon Sep 17 00:00:00 2001 From: Erik Eriksson Date: Tue, 4 Oct 2016 09:58:25 +0200 Subject: [PATCH] only query vehicle attributes once (#3668) use registration number as dev id --- .../components/device_tracker/volvooncall.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/device_tracker/volvooncall.py b/homeassistant/components/device_tracker/volvooncall.py index 6876d63c223..703fe32e538 100644 --- a/homeassistant/components/device_tracker/volvooncall.py +++ b/homeassistant/components/device_tracker/volvooncall.py @@ -67,6 +67,12 @@ def setup_scanner(hass, config, see): user = query("customeraccounts") rel = query(user["accountVehicleRelations"][0]) vehicle_url = rel["vehicle"] + '/' + attributes = query("attributes", vehicle_url) + + dev_id = "volvo_" + attributes["registrationNumber"] + host_name = "%s %s/%s" % (attributes["registrationNumber"], + attributes["vehicleType"], + attributes["modelYear"]) except requests.exceptions.RequestException: _LOGGER.error("Could not log in to service. " "Please check configuration.") @@ -78,12 +84,6 @@ def setup_scanner(hass, config, see): status = query("status", vehicle_url) position = query("position", vehicle_url) - attributes = query("attributes", vehicle_url) - - dev_id = "volvo_" + attributes["vin"] - host_name = "%s %s/%s" % (attributes["registrationNumber"], - attributes["vehicleType"], - attributes["modelYear"]) see(dev_id=dev_id, host_name=host_name,