Skip to content

Commit

Permalink
Solve the button wake issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Feb 4, 2024
1 parent ed27909 commit 77e868c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/teslemetry/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
class TeslemetryButtonEntityDescription(ButtonEntityDescription):
"""Describes a Teslemetry Button entity."""

func: Callable
func: Callable | None


DESCRIPTIONS: tuple[TeslemetryButtonEntityDescription, ...] = (
TeslemetryButtonEntityDescription(
key="wake", func=lambda api: api.wake_up()
key="wake"
), # Every button also runs wakeup
TeslemetryButtonEntityDescription(
key="flash_lights", func=lambda api: api.flash_lights()
Expand Down Expand Up @@ -73,4 +73,5 @@ def __init__(
async def async_press(self) -> None:
"""Press the button."""
await self.wake_up_if_asleep()
await self.entity_description.func(self.api)
if self.entity_description.func:
await self.entity_description.func(self.api)

0 comments on commit 77e868c

Please sign in to comment.