|
1 | 1 | """Stromer Button component for Home Assistant.""" |
2 | 2 | from __future__ import annotations |
3 | 3 |
|
4 | | -from typing import Any |
5 | | - |
6 | 4 | from homeassistant.components.button import ( |
7 | 5 | ButtonDeviceClass, |
8 | 6 | ButtonEntity, |
9 | 7 | ButtonEntityDescription, |
10 | 8 | ) |
11 | 9 | from homeassistant.config_entries import ConfigEntry |
12 | | -from homeassistant.core import HomeAssistant, callback |
| 10 | +from homeassistant.core import HomeAssistant |
13 | 11 | from homeassistant.helpers.entity_platform import AddEntitiesCallback |
14 | 12 |
|
15 | 13 | from .const import DOMAIN, LOGGER |
@@ -61,17 +59,9 @@ def __init__( |
61 | 59 | device_id = coordinator.data.bike_id |
62 | 60 |
|
63 | 61 | 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" |
71 | 63 |
|
72 | | - async def async_turn_on(self, **kwargs: Any) -> None: |
| 64 | + async def async_press(self) -> None: |
73 | 65 | """Handle the button press.""" |
74 | 66 | if self.entity_description.key == "reset_trip_data": |
75 | 67 | 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