From 093bd863baccd828d1b46dc944c16e6e0c2e211c Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Sun, 26 Jul 2020 11:00:07 -0700 Subject: [PATCH] Add update available binary sensor to Tesla (#37991) * Add update available binary sensor to Tesla * Bump teslajsonpy to 0.10.1 * Add check for DEVICE_CLASS * Change to relative import --- homeassistant/components/tesla/binary_sensor.py | 16 ++++++---------- homeassistant/components/tesla/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/tesla/binary_sensor.py b/homeassistant/components/tesla/binary_sensor.py index c1f6fe18b99..c6b63d92bd2 100644 --- a/homeassistant/components/tesla/binary_sensor.py +++ b/homeassistant/components/tesla/binary_sensor.py @@ -1,7 +1,7 @@ """Support for Tesla binary sensor.""" import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import DEVICE_CLASSES, BinarySensorEntity from . import DOMAIN as TESLA_DOMAIN, TeslaDevice @@ -15,7 +15,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities): TeslaBinarySensor( device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["controller"], - "connectivity", config_entry, ) for device in hass.data[TESLA_DOMAIN][config_entry.entry_id]["devices"][ @@ -29,22 +28,19 @@ async def async_setup_entry(hass, config_entry, async_add_entities): class TeslaBinarySensor(TeslaDevice, BinarySensorEntity): """Implement an Tesla binary sensor for parking and charger.""" - def __init__(self, tesla_device, controller, sensor_type, config_entry): + def __init__(self, tesla_device, controller, config_entry): """Initialise of a Tesla binary sensor.""" super().__init__(tesla_device, controller, config_entry) - self._state = False - self._sensor_type = sensor_type + self._state = None + self._sensor_type = None + if tesla_device.sensor_type in DEVICE_CLASSES: + self._sensor_type = tesla_device.sensor_type @property def device_class(self): """Return the class of this binary sensor.""" return self._sensor_type - @property - def name(self): - """Return the name of the binary sensor.""" - return self._name - @property def is_on(self): """Return the state of the binary sensor.""" diff --git a/homeassistant/components/tesla/manifest.json b/homeassistant/components/tesla/manifest.json index 1db32bbd61f..fab844eb8eb 100644 --- a/homeassistant/components/tesla/manifest.json +++ b/homeassistant/components/tesla/manifest.json @@ -3,6 +3,6 @@ "name": "Tesla", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/tesla", - "requirements": ["teslajsonpy==0.9.3"], + "requirements": ["teslajsonpy==0.10.1"], "codeowners": ["@zabuldon", "@alandtse"] } diff --git a/requirements_all.txt b/requirements_all.txt index dcf12d9b274..64ff88aff11 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2101,7 +2101,7 @@ temperusb==1.5.3 tesla-powerwall==0.2.11 # homeassistant.components.tesla -teslajsonpy==0.9.3 +teslajsonpy==0.10.1 # homeassistant.components.thermoworks_smoke thermoworks_smoke==0.1.8 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7d8bb75841e..880e1178640 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -927,7 +927,7 @@ tellduslive==0.10.11 tesla-powerwall==0.2.11 # homeassistant.components.tesla -teslajsonpy==0.9.3 +teslajsonpy==0.10.1 # homeassistant.components.toon toonapi==0.1.0