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
This commit is contained in:
parent
2d6eb5c05d
commit
093bd863ba
4 changed files with 9 additions and 13 deletions
|
@ -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."""
|
||||
|
|
|
@ -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"]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue