mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add Tesla sentry mode switch (#32938)
* Add Tesla sentry mode switch * add available property, fix is_on * bump teslajsonpy to 0.6.0
This commit is contained in:
parent
f9a7c64106
commit
4332cbe112
@ -25,4 +25,5 @@ ICONS = {
|
|||||||
"temperature sensor": "mdi:thermometer",
|
"temperature sensor": "mdi:thermometer",
|
||||||
"location tracker": "mdi:crosshairs-gps",
|
"location tracker": "mdi:crosshairs-gps",
|
||||||
"charging rate sensor": "mdi:speedometer",
|
"charging rate sensor": "mdi:speedometer",
|
||||||
|
"sentry mode switch": "mdi:shield-car",
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/tesla",
|
"documentation": "https://www.home-assistant.io/integrations/tesla",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"teslajsonpy==0.5.1"
|
"teslajsonpy==0.6.0"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
@ -19,6 +19,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
entities.append(UpdateSwitch(device, controller, config_entry))
|
entities.append(UpdateSwitch(device, controller, config_entry))
|
||||||
elif device.type == "maxrange switch":
|
elif device.type == "maxrange switch":
|
||||||
entities.append(RangeSwitch(device, controller, config_entry))
|
entities.append(RangeSwitch(device, controller, config_entry))
|
||||||
|
elif device.type == "sentry mode switch":
|
||||||
|
entities.append(SentryModeSwitch(device, controller, config_entry))
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
@ -114,3 +116,32 @@ class UpdateSwitch(TeslaDevice, SwitchDevice):
|
|||||||
_LOGGER.debug("Updating state for: %s %s", self._name, car_id)
|
_LOGGER.debug("Updating state for: %s %s", self._name, car_id)
|
||||||
await super().async_update()
|
await super().async_update()
|
||||||
self._state = bool(self.controller.get_updates(car_id))
|
self._state = bool(self.controller.get_updates(car_id))
|
||||||
|
|
||||||
|
|
||||||
|
class SentryModeSwitch(TeslaDevice, SwitchDevice):
|
||||||
|
"""Representation of a Tesla sentry mode switch."""
|
||||||
|
|
||||||
|
async def async_turn_on(self, **kwargs):
|
||||||
|
"""Send the on command."""
|
||||||
|
_LOGGER.debug("Enable sentry mode: %s", self._name)
|
||||||
|
await self.tesla_device.enable_sentry_mode()
|
||||||
|
|
||||||
|
async def async_turn_off(self, **kwargs):
|
||||||
|
"""Send the off command."""
|
||||||
|
_LOGGER.debug("Disable sentry mode: %s", self._name)
|
||||||
|
await self.tesla_device.disable_sentry_mode()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
"""Get whether the switch is in on state."""
|
||||||
|
return self.tesla_device.is_on()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self):
|
||||||
|
"""Indicate if Home Assistant is able to read the state and control the underlying device."""
|
||||||
|
return self.tesla_device.available()
|
||||||
|
|
||||||
|
async def async_update(self):
|
||||||
|
"""Update the state of the switch."""
|
||||||
|
_LOGGER.debug("Updating state for: %s", self._name)
|
||||||
|
await super().async_update()
|
||||||
|
@ -2000,7 +2000,7 @@ temperusb==1.5.3
|
|||||||
tesla-powerwall==0.1.1
|
tesla-powerwall==0.1.1
|
||||||
|
|
||||||
# homeassistant.components.tesla
|
# homeassistant.components.tesla
|
||||||
teslajsonpy==0.5.1
|
teslajsonpy==0.6.0
|
||||||
|
|
||||||
# homeassistant.components.thermoworks_smoke
|
# homeassistant.components.thermoworks_smoke
|
||||||
thermoworks_smoke==0.1.8
|
thermoworks_smoke==0.1.8
|
||||||
|
@ -719,7 +719,7 @@ tellduslive==0.10.10
|
|||||||
tesla-powerwall==0.1.1
|
tesla-powerwall==0.1.1
|
||||||
|
|
||||||
# homeassistant.components.tesla
|
# homeassistant.components.tesla
|
||||||
teslajsonpy==0.5.1
|
teslajsonpy==0.6.0
|
||||||
|
|
||||||
# homeassistant.components.toon
|
# homeassistant.components.toon
|
||||||
toonapilib==3.2.4
|
toonapilib==3.2.4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user