Skip to content

Commit

Permalink
fix: rename update switch to polling switch
Browse files Browse the repository at this point in the history
The `update switch` was confusing since we use `update available` to describe whether a software update is available. We now clarify that this switch controls polling of a vehicle.

BREAKING CHANGE: `update_switch` has been renamed to `polling_switch`. While the UI name will change immediately if you have not modified it, the entity_id should not change unless you remove and reinstall the component.

closes #22

Co-authored-by: Andy Allsopp <arallsopp@gmail.com>
  • Loading branch information
alandtse and arallsopp authored Sep 11, 2021
1 parent 37bce6a commit b09825c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/tesla_custom/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"parking brake sensor": "mdi:car-brake-parking",
"charger sensor": "mdi:ev-station",
"charger switch": "mdi:battery-charging",
"update switch": "mdi:update",
"update switch": "mdi:car-connected",
"maxrange switch": "mdi:gauge-full",
"temperature sensor": "mdi:thermometer",
"location tracker": "mdi:crosshairs-gps",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tesla_custom/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"init": {
"data": {
"enable_wake_on_start": "Force cars awake on startup",
"scan_interval": "Seconds between scans"
"scan_interval": "Seconds between polling"
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions custom_components/tesla_custom/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for Tesla charger switches."""
from custom_components.tesla_custom.const import ICONS
import logging

from homeassistant.components.switch import SwitchEntity
Expand Down Expand Up @@ -75,7 +76,7 @@ def is_on(self):


class UpdateSwitch(TeslaDevice, SwitchEntity):
"""Representation of a Tesla update switch."""
"""Representation of a Tesla update switch. Described in UI as polling."""

def __init__(self, tesla_device, coordinator):
"""Initialise the switch."""
Expand All @@ -85,7 +86,12 @@ def __init__(self, tesla_device, coordinator):
@property
def name(self):
"""Return the name of the device."""
return super().name.replace("charger", "update")
return super().name.replace("charger", "polling")

@property
def icon(self):
"""Return the icon of the sensor."""
return ICONS.get("update switch")

@property
def unique_id(self) -> str:
Expand All @@ -94,13 +100,13 @@ def unique_id(self) -> str:

async def async_turn_on(self, **kwargs):
"""Send the on command."""
_LOGGER.debug("Enable updates: %s %s", self.name, self.tesla_device.id())
_LOGGER.debug("Enable polling: %s %s", self.name, self.tesla_device.id())
self.controller.set_updates(self.tesla_device.id(), True)
self.async_write_ha_state()

async def async_turn_off(self, **kwargs):
"""Send the off command."""
_LOGGER.debug("Disable updates: %s %s", self.name, self.tesla_device.id())
_LOGGER.debug("Disable polling: %s %s", self.name, self.tesla_device.id())
self.controller.set_updates(self.tesla_device.id(), False)
self.async_write_ha_state()

Expand Down
2 changes: 1 addition & 1 deletion custom_components/tesla_custom/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"init": {
"data": {
"enable_wake_on_start": "Force cars awake on startup",
"scan_interval": "Seconds between scans"
"scan_interval": "Seconds between polling"
}
}
}
Expand Down

0 comments on commit b09825c

Please sign in to comment.