Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions homeassistant/components/tesla/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
"temperature sensor": "mdi:thermometer",
"location tracker": "mdi:crosshairs-gps",
"charging rate sensor": "mdi:speedometer",
"sentry mode switch": "mdi:shield-car",
}
2 changes: 1 addition & 1 deletion homeassistant/components/tesla/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/tesla",
"requirements": [
"teslajsonpy==0.5.1"
"teslajsonpy==0.6.0"
],
"dependencies": [],
"codeowners": [
Expand Down
31 changes: 31 additions & 0 deletions homeassistant/components/tesla/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
entities.append(UpdateSwitch(device, controller, config_entry))
elif device.type == "maxrange switch":
entities.append(RangeSwitch(device, controller, config_entry))
elif device.type == "sentry mode switch":
Comment thread
bdraco marked this conversation as resolved.
entities.append(SentryModeSwitch(device, controller, config_entry))
async_add_entities(entities, True)


Expand Down Expand Up @@ -114,3 +116,32 @@ async def async_update(self):
_LOGGER.debug("Updating state for: %s %s", self._name, car_id)
await super().async_update()
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()
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ temperusb==1.5.3
# tensorflow==1.13.2

# homeassistant.components.tesla
teslajsonpy==0.5.1
teslajsonpy==0.6.0

# homeassistant.components.thermoworks_smoke
thermoworks_smoke==0.1.8
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ sunwatcher==0.2.1
tellduslive==0.10.10

# homeassistant.components.tesla
teslajsonpy==0.5.1
teslajsonpy==0.6.0

# homeassistant.components.toon
toonapilib==3.2.4
Expand Down