Skip to content

Commit

Permalink
Merge pull request #124 from moorgrove/patch-7
Browse files Browse the repository at this point in the history
Add button stop climate
  • Loading branch information
mitch-dc authored Jan 16, 2023
2 parents dacacbd + 892daaa commit 0037f8d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions custom_components/volkswagen_we_connect_id/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
entities = []
for vehicle in vehicles: # weConnect.vehicles.items():
entities.append(VolkswagenIDStartClimateButton(vehicle, we_connect))
entities.append(VolkswagenIDStopClimateButton(vehicle, we_connect))
entities.append(VolkswagenIDToggleACChargeSpeed(vehicle, we_connect))

async_add_entities(entities)
Expand All @@ -30,6 +31,7 @@ def __init__(self, vehicle, we_connect) -> None:
"""Initialize VolkswagenID vehicle sensor."""
self._attr_name = f"{vehicle.nickname} Start Climate"
self._attr_unique_id = f"{vehicle.vin}-start_climate"
self._attr_icon = "mdi:fan-plus"
self._we_connect = we_connect
self._vehicle = vehicle

Expand All @@ -38,13 +40,30 @@ def press(self) -> None:
set_climatisation(self._vehicle.vin.value, self._we_connect, "start", 0)


class VolkswagenIDStopClimateButton(ButtonEntity):
"""Button for stopping climate."""

def __init__(self, vehicle, we_connect) -> None:
"""Initialize VolkswagenID vehicle sensor."""
self._attr_name = f"{vehicle.nickname} Stop Climate"
self._attr_unique_id = f"{vehicle.vin}-stop_climate"
self._attr_icon = "mdi:fan-off"
self._we_connect = we_connect
self._vehicle = vehicle

def press(self) -> None:
"""Handle the button press."""
set_climatisation(self._vehicle.vin.value, self._we_connect, "stop", 0)


class VolkswagenIDToggleACChargeSpeed(ButtonEntity):
"""Button for toggling the charge speed."""

def __init__(self, vehicle: Vehicle, we_connect: weconnect.WeConnect) -> None:
"""Initialize VolkswagenID vehicle sensor."""
self._attr_name = f"{vehicle.nickname} Toggle AC Charge Speed"
self._attr_unique_id = f"{vehicle.vin}-toggle_ac_charge_speed"
self._attr_icon = "mdi:ev-station"
self._we_connect = we_connect
self._vehicle = vehicle

Expand Down

0 comments on commit 0037f8d

Please sign in to comment.