mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Bump teslajsonpy and add update switch (#27957)
* bump teslajsonpy to 0.0.26 breaking change * add update switch to tesla * bump requirements_all.txt for teslajsonpy * address requested style changes * fix bug where update switch not loaded
This commit is contained in:
parent
d1fcc5762b
commit
1e832dc9ec
@ -2,11 +2,7 @@
|
|||||||
"domain": "tesla",
|
"domain": "tesla",
|
||||||
"name": "Tesla",
|
"name": "Tesla",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/tesla",
|
"documentation": "https://www.home-assistant.io/integrations/tesla",
|
||||||
"requirements": [
|
"requirements": ["teslajsonpy==0.0.26"],
|
||||||
"teslajsonpy==0.0.25"
|
|
||||||
],
|
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": ["@zabuldon"]
|
||||||
"@zabuldon"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,12 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Tesla switch platform."""
|
"""Set up the Tesla switch platform."""
|
||||||
controller = hass.data[TESLA_DOMAIN]["devices"]["controller"]
|
controller = hass.data[TESLA_DOMAIN]["controller"]
|
||||||
devices = []
|
devices = []
|
||||||
for device in hass.data[TESLA_DOMAIN]["devices"]["switch"]:
|
for device in hass.data[TESLA_DOMAIN]["devices"]["switch"]:
|
||||||
if device.bin_type == 0x8:
|
if device.bin_type == 0x8:
|
||||||
devices.append(ChargerSwitch(device, controller))
|
devices.append(ChargerSwitch(device, controller))
|
||||||
|
devices.append(UpdateSwitch(device, controller))
|
||||||
elif device.bin_type == 0x9:
|
elif device.bin_type == 0x9:
|
||||||
devices.append(RangeSwitch(device, controller))
|
devices.append(RangeSwitch(device, controller))
|
||||||
add_entities(devices, True)
|
add_entities(devices, True)
|
||||||
@ -72,10 +73,42 @@ class RangeSwitch(TeslaDevice, SwitchDevice):
|
|||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Get whether the switch is in on state."""
|
"""Get whether the switch is in on state."""
|
||||||
return self._state == STATE_ON
|
return self._state
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the state of the switch."""
|
"""Update the state of the switch."""
|
||||||
_LOGGER.debug("Updating state for: %s", self._name)
|
_LOGGER.debug("Updating state for: %s", self._name)
|
||||||
self.tesla_device.update()
|
self.tesla_device.update()
|
||||||
self._state = STATE_ON if self.tesla_device.is_maxrange() else STATE_OFF
|
self._state = bool(self.tesla_device.is_maxrange())
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateSwitch(TeslaDevice, SwitchDevice):
|
||||||
|
"""Representation of a Tesla update switch."""
|
||||||
|
|
||||||
|
def __init__(self, tesla_device, controller):
|
||||||
|
"""Initialise of the switch."""
|
||||||
|
self._state = None
|
||||||
|
super().__init__(tesla_device, controller)
|
||||||
|
self._name = self._name.replace("charger", "update")
|
||||||
|
self.tesla_id = self.tesla_id.replace("charger", "update")
|
||||||
|
|
||||||
|
def turn_on(self, **kwargs):
|
||||||
|
"""Send the on command."""
|
||||||
|
_LOGGER.debug("Enable updates: %s %s", self._name, self.tesla_device.id())
|
||||||
|
self.controller.set_updates(self.tesla_device.id(), True)
|
||||||
|
|
||||||
|
def turn_off(self, **kwargs):
|
||||||
|
"""Send the off command."""
|
||||||
|
_LOGGER.debug("Disable updates: %s %s", self._name, self.tesla_device.id())
|
||||||
|
self.controller.set_updates(self.tesla_device.id(), False)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
"""Get whether the switch is in on state."""
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Update the state of the switch."""
|
||||||
|
car_id = self.tesla_device.id()
|
||||||
|
_LOGGER.debug("Updating state for: %s %s", self._name, car_id)
|
||||||
|
self._state = bool(self.controller.get_updates(car_id))
|
||||||
|
@ -1876,7 +1876,7 @@ temperusb==1.5.3
|
|||||||
# tensorflow==1.13.2
|
# tensorflow==1.13.2
|
||||||
|
|
||||||
# homeassistant.components.tesla
|
# homeassistant.components.tesla
|
||||||
teslajsonpy==0.0.25
|
teslajsonpy==0.0.26
|
||||||
|
|
||||||
# homeassistant.components.thermoworks_smoke
|
# homeassistant.components.thermoworks_smoke
|
||||||
thermoworks_smoke==0.1.8
|
thermoworks_smoke==0.1.8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user