Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions homeassistant/components/binary_sensor/mercedesme.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from homeassistant.components.binary_sensor import (BinarySensorDevice)
from homeassistant.components.mercedesme import (
DATA_MME, MercedesMeEntity, BINARY_SENSORS)
DATA_MME, FEATURE_NOT_AVAILABLE, MercedesMeEntity, BINARY_SENSORS)

DEPENDENCIES = ['mercedesme']

Expand All @@ -27,8 +27,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
devices = []
for car in data.cars:
for key, value in sorted(BINARY_SENSORS.items()):
devices.append(MercedesMEBinarySensor(
data, key, value[0], car["vin"], None))
if car['availabilities'].get(key, 'INVALID') == 'VALID':
devices.append(MercedesMEBinarySensor(
data, key, value[0], car["vin"], None))
else:
_LOGGER.warning(FEATURE_NOT_AVAILABLE, key, car["license"])

add_devices(devices, True)

Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/device_tracker/mercedesme.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ def __init__(self, hass, config, see, data):
def update_info(self, now=None):
"""Update the device info."""
for device in self.data.cars:
_LOGGER.debug("Updating %s", device["vin"])
if not device['services'].get('VEHICLE_FINDER', False):
continue

location = self.data.get_location(device["vin"])
if location is None:
return False
continue

dev_id = device["vin"]
name = device["license"]

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/mercedesme.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
DATA_MME = 'mercedesme'
DOMAIN = 'mercedesme'

FEATURE_NOT_AVAILABLE = "The feature %s is not available for your car %s"

NOTIFICATION_ID = 'mercedesme_integration_notification'
NOTIFICATION_TITLE = 'Mercedes me integration setup'

Expand Down
10 changes: 7 additions & 3 deletions homeassistant/components/sensor/mercedesme.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import datetime

from homeassistant.components.mercedesme import (
DATA_MME, MercedesMeEntity, SENSORS)
DATA_MME, FEATURE_NOT_AVAILABLE, MercedesMeEntity, SENSORS)


DEPENDENCIES = ['mercedesme']
Expand All @@ -29,8 +29,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
devices = []
for car in data.cars:
for key, value in sorted(SENSORS.items()):
devices.append(
MercedesMESensor(data, key, value[0], car["vin"], value[1]))
if car['availabilities'].get(key, 'INVALID') == 'VALID':
devices.append(
MercedesMESensor(
data, key, value[0], car["vin"], value[1]))
else:
_LOGGER.warning(FEATURE_NOT_AVAILABLE, key, car["license"])

add_devices(devices, True)

Expand Down