Skip to content

Commit 964c752

Browse files
committed
Correct syntax
1 parent 20bc39e commit 964c752

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

custom_components/stromer/button.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
"""Stromer Button component for Home Assistant."""
22
from __future__ import annotations
33

4-
from typing import Any
5-
64
from homeassistant.components.button import (
75
ButtonDeviceClass,
86
ButtonEntity,
97
ButtonEntityDescription,
108
)
119
from homeassistant.config_entries import ConfigEntry
12-
from homeassistant.core import HomeAssistant, callback
10+
from homeassistant.core import HomeAssistant
1311
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1412

1513
from .const import DOMAIN, LOGGER
@@ -61,17 +59,9 @@ def __init__(
6159
device_id = coordinator.data.bike_id
6260

6361
self.entity_description = description
64-
self._attr_unique_id = f"{device_id}-{description.key}-sw"
65-
66-
@callback # type: ignore[misc]
67-
def _handle_coordinator_update(self) -> None:
68-
"""Handle updated data from the coordinator."""
69-
self._attr_is_on = self._coordinator.data.bikedata.get(self._ent)
70-
self.async_write_ha_state()
62+
self._attr_unique_id = f"{device_id}-{description.key}-bu"
7163

72-
async def async_turn_on(self, **kwargs: Any) -> None:
64+
async def async_press(self) -> None:
7365
"""Handle the button press."""
7466
if self.entity_description.key == "reset_trip_data":
7567
await self._coordinator.stromer.stromer_reset_trip_data()
76-
# Call update on the bike so `is_on` correctly reflects status
77-
await self._coordinator.async_request_refresh()

0 commit comments

Comments
 (0)