Tesla bug fixes. (#9774)
* Tesla bug fixes. * Added myself to CODEOWNERS for tesla.
This commit is contained in:
parent
43d77729c5
commit
9abd0fb92f
8 changed files with 60 additions and 10 deletions
|
@ -57,5 +57,7 @@ homeassistant/components/switch/tplink.py @rytilahti
|
||||||
|
|
||||||
homeassistant/components/*/broadlink.py @danielhiversen
|
homeassistant/components/*/broadlink.py @danielhiversen
|
||||||
homeassistant/components/*/rfxtrx.py @danielhiversen
|
homeassistant/components/*/rfxtrx.py @danielhiversen
|
||||||
|
homeassistant/components/tesla.py @zabuldon
|
||||||
|
homeassistant/components/*/tesla.py @zabuldon
|
||||||
homeassistant/components/*/xiaomi_aqara.py @danielhiversen
|
homeassistant/components/*/xiaomi_aqara.py @danielhiversen
|
||||||
homeassistant/components/*/xiaomi_miio.py @rytilahti
|
homeassistant/components/*/xiaomi_miio.py @rytilahti
|
||||||
|
|
|
@ -30,7 +30,6 @@ class TeslaBinarySensor(TeslaDevice, BinarySensorDevice):
|
||||||
def __init__(self, tesla_device, controller, sensor_type):
|
def __init__(self, tesla_device, controller, sensor_type):
|
||||||
"""Initialisation of binary sensor."""
|
"""Initialisation of binary sensor."""
|
||||||
super().__init__(tesla_device, controller)
|
super().__init__(tesla_device, controller)
|
||||||
self._name = self.tesla_device.name
|
|
||||||
self._state = False
|
self._state = False
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
||||||
self._sensor_type = sensor_type
|
self._sensor_type = sensor_type
|
||||||
|
|
|
@ -35,7 +35,6 @@ class TeslaThermostat(TeslaDevice, ClimateDevice):
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
||||||
self._target_temperature = None
|
self._target_temperature = None
|
||||||
self._temperature = None
|
self._temperature = None
|
||||||
self._name = self.tesla_device.name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_operation(self):
|
def current_operation(self):
|
||||||
|
|
|
@ -29,20 +29,17 @@ class TeslaLock(TeslaDevice, LockDevice):
|
||||||
"""Initialisation of the lock."""
|
"""Initialisation of the lock."""
|
||||||
self._state = None
|
self._state = None
|
||||||
super().__init__(tesla_device, controller)
|
super().__init__(tesla_device, controller)
|
||||||
self._name = self.tesla_device.name
|
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
||||||
|
|
||||||
def lock(self, **kwargs):
|
def lock(self, **kwargs):
|
||||||
"""Send the lock command."""
|
"""Send the lock command."""
|
||||||
_LOGGER.debug("Locking doors for: %s", self._name)
|
_LOGGER.debug("Locking doors for: %s", self._name)
|
||||||
self.tesla_device.lock()
|
self.tesla_device.lock()
|
||||||
self._state = STATE_LOCKED
|
|
||||||
|
|
||||||
def unlock(self, **kwargs):
|
def unlock(self, **kwargs):
|
||||||
"""Send the unlock command."""
|
"""Send the unlock command."""
|
||||||
_LOGGER.debug("Unlocking doors for: %s", self._name)
|
_LOGGER.debug("Unlocking doors for: %s", self._name)
|
||||||
self.tesla_device.unlock()
|
self.tesla_device.unlock()
|
||||||
self._state = STATE_UNLOCKED
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_locked(self):
|
def is_locked(self):
|
||||||
|
|
|
@ -49,7 +49,6 @@ class TeslaSensor(TeslaDevice, Entity):
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(
|
self.entity_id = ENTITY_ID_FORMAT.format(
|
||||||
'{}_{}'.format(self.tesla_id, self.type))
|
'{}_{}'.format(self.tesla_id, self.type))
|
||||||
else:
|
else:
|
||||||
self._name = self.tesla_device.name
|
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
53
homeassistant/components/switch/tesla.py
Normal file
53
homeassistant/components/switch/tesla.py
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
"""
|
||||||
|
Support for Tesla charger switch.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.tesla/
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchDevice
|
||||||
|
from homeassistant.components.tesla import DOMAIN as TESLA_DOMAIN, TeslaDevice
|
||||||
|
from homeassistant.const import STATE_ON, STATE_OFF
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
DEPENDENCIES = ['tesla']
|
||||||
|
|
||||||
|
|
||||||
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
"""Set up the Tesla switch platform."""
|
||||||
|
devices = [ChargerSwitch(device, hass.data[TESLA_DOMAIN]['controller'])
|
||||||
|
for device in hass.data[TESLA_DOMAIN]['devices']['switch']]
|
||||||
|
add_devices(devices, True)
|
||||||
|
|
||||||
|
|
||||||
|
class ChargerSwitch(TeslaDevice, SwitchDevice):
|
||||||
|
"""Representation of a Tesla charger switch."""
|
||||||
|
|
||||||
|
def __init__(self, tesla_device, controller):
|
||||||
|
"""Initialisation of the switch."""
|
||||||
|
self._state = None
|
||||||
|
super().__init__(tesla_device, controller)
|
||||||
|
self.entity_id = ENTITY_ID_FORMAT.format(self.tesla_id)
|
||||||
|
|
||||||
|
def turn_on(self, **kwargs):
|
||||||
|
"""Send the on command."""
|
||||||
|
_LOGGER.debug("Enable charging: %s", self._name)
|
||||||
|
self.tesla_device.start_charge()
|
||||||
|
|
||||||
|
def turn_off(self, **kwargs):
|
||||||
|
"""Send the off command."""
|
||||||
|
_LOGGER.debug("Disable charging for: %s", self._name)
|
||||||
|
self.tesla_device.stop_charge()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
"""Get whether the switch is in on state."""
|
||||||
|
return self._state == STATE_ON
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Updating state of the switch."""
|
||||||
|
_LOGGER.debug("Updating state for: %s", self._name)
|
||||||
|
self.tesla_device.update()
|
||||||
|
self._state = STATE_ON if self.tesla_device.is_charging() \
|
||||||
|
else STATE_OFF
|
|
@ -17,7 +17,7 @@ from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
REQUIREMENTS = ['teslajsonpy==0.0.11']
|
REQUIREMENTS = ['teslajsonpy==0.0.17']
|
||||||
|
|
||||||
DOMAIN = 'tesla'
|
DOMAIN = 'tesla'
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ NOTIFICATION_ID = 'tesla_integration_notification'
|
||||||
NOTIFICATION_TITLE = 'Tesla integration setup'
|
NOTIFICATION_TITLE = 'Tesla integration setup'
|
||||||
|
|
||||||
TESLA_COMPONENTS = [
|
TESLA_COMPONENTS = [
|
||||||
'sensor', 'lock', 'climate', 'binary_sensor', 'device_tracker'
|
'sensor', 'lock', 'climate', 'binary_sensor', 'device_tracker', 'switch'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ def setup(hass, base_config):
|
||||||
if hass.data.get(DOMAIN) is None:
|
if hass.data.get(DOMAIN) is None:
|
||||||
try:
|
try:
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
'controller': teslaApi(email, password, update_interval),
|
'controller': teslaApi(
|
||||||
|
email, password, update_interval),
|
||||||
'devices': defaultdict(list)
|
'devices': defaultdict(list)
|
||||||
}
|
}
|
||||||
_LOGGER.debug("Connected to the Tesla API.")
|
_LOGGER.debug("Connected to the Tesla API.")
|
||||||
|
|
|
@ -993,7 +993,7 @@ tellduslive==0.3.4
|
||||||
temperusb==1.5.3
|
temperusb==1.5.3
|
||||||
|
|
||||||
# homeassistant.components.tesla
|
# homeassistant.components.tesla
|
||||||
teslajsonpy==0.0.11
|
teslajsonpy==0.0.17
|
||||||
|
|
||||||
# homeassistant.components.thingspeak
|
# homeassistant.components.thingspeak
|
||||||
thingspeak==0.4.1
|
thingspeak==0.4.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue