only check heater status if present (#4459)

This commit is contained in:
Erik Eriksson 2016-11-18 23:12:51 +01:00 committed by Paulus Schoutsen
parent e6c4113c5b
commit 265232af98

View File

@ -55,10 +55,6 @@ def setup_scanner(hass, config, see):
"""True if any door/window is opened.""" """True if any door/window is opened."""
return any([door[key] for key in door if "Open" in key]) return any([door[key] for key in door if "Open" in key])
see(dev_id=dev_id,
host_name=host_name,
gps=(position["latitude"],
position["longitude"]),
attributes = dict( attributes = dict(
unlocked=not vehicle["carLocked"], unlocked=not vehicle["carLocked"],
tank_volume=vehicle["fuelTankVolume"], tank_volume=vehicle["fuelTankVolume"],
@ -70,10 +66,19 @@ def setup_scanner(hass, config, see):
bulb_failures=len(vehicle["bulbFailures"]) > 0, bulb_failures=len(vehicle["bulbFailures"]) > 0,
doors_open=any_opened(vehicle["doors"]), doors_open=any_opened(vehicle["doors"]),
windows_open=any_opened(vehicle["windows"]), windows_open=any_opened(vehicle["windows"]),
heater_on=vehicle["heater"]["status"] != "off",
fuel=vehicle["fuelAmount"], fuel=vehicle["fuelAmount"],
odometer=round(vehicle["odometer"] / 1000), # km odometer=round(vehicle["odometer"] / 1000), # km
range=vehicle["distanceToEmpty"])) range=vehicle["distanceToEmpty"])
if "heater" in vehicle and \
"status" in vehicle["heater"]:
attributes.update(heater_on=vehicle["heater"]["status"] != "off")
see(dev_id=dev_id,
host_name=host_name,
gps=(position["latitude"],
position["longitude"]),
attributes=attributes)
def update(now): def update(now):
"""Update status from the online service.""" """Update status from the online service."""