Skip to content

Commit

Permalink
feat: add emission test button (#454)
Browse files Browse the repository at this point in the history
closes #438
  • Loading branch information
InTheDaylight14 authored Dec 28, 2022
1 parent 5781cea commit 8d40beb
Show file tree
Hide file tree
Showing 6 changed files with 1,581 additions and 485 deletions.
27 changes: 27 additions & 0 deletions custom_components/tesla_custom/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
entities.append(TeslaCarForceDataUpdate(hass, car, coordinator))
entities.append(TeslaCarTriggerHomelink(hass, car, coordinator))
entities.append(TeslaCarRemoteStart(hass, car, coordinator))
entities.append(TeslaCarEmissionsTest(hass, car, coordinator))

async_add_entities(entities, True)

Expand Down Expand Up @@ -162,3 +163,29 @@ def __init__(
async def async_press(self):
"""Send the command."""
await self._car.remote_start()


class TeslaCarEmissionsTest(TeslaCarEntity, ButtonEntity):
"""Representation of a Tesla car emissions test button."""

def __init__(
self,
hass: HomeAssistant,
car: TeslaCar,
coordinator: TeslaDataUpdateCoordinator,
) -> None:
"""Initialize emissions test button."""
super().__init__(hass, car, coordinator)
self.type = "emissions test"
self._attr_icon = "mdi:weather-windy"
self._attr_entity_category = EntityCategory.DIAGNOSTIC
self._enabled_by_default = self._car.pedestrian_speaker

async def async_press(self) -> None:
"""Handle the button press."""
await self._car.remote_boombox()

@property
def available(self) -> bool:
"""Return True."""
return True
2 changes: 1 addition & 1 deletion custom_components/tesla_custom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"documentation": "https://github.com/alandtse/tesla/wiki",
"issue_tracker": "https://github.com/alandtse/tesla/issues",
"requirements": [
"teslajsonpy==3.5.1"
"teslajsonpy==3.6.0"
],
"codeowners": [
"@alandtse"
Expand Down
Loading

0 comments on commit 8d40beb

Please sign in to comment.