Skip to content

Commit

Permalink
Fix up cover
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Jan 31, 2024
1 parent b015dd4 commit 333102a
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions custom_components/teslemetry/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

from typing import Any

from Teslemetry_api import (
close_charge_port,
close_windows,
open_close_rear_trunk,
open_front_trunk,
open_unlock_charge_port,
vent_windows,
)
from tesla_fleet_api.const import WindowCommands, Trunks

from homeassistant.components.cover import (
CoverDeviceClass,
Expand Down Expand Up @@ -66,7 +59,7 @@ def is_closed(self) -> bool | None:

async def async_open_cover(self, **kwargs: Any) -> None:
"""Open windows."""
await self.run(vent_windows)
await self.api.window_control(command=WindowCommands.VENT)
self.set(
("vehicle_state_fd_window", TeslemetryCoverStates.OPEN),
("vehicle_state_fp_window", TeslemetryCoverStates.OPEN),
Expand All @@ -76,7 +69,7 @@ async def async_open_cover(self, **kwargs: Any) -> None:

async def async_close_cover(self, **kwargs: Any) -> None:
"""Close windows."""
await self.run(close_windows)
await self.api.window_control(command=WindowCommands.CLOSE)
self.set(
("vehicle_state_fd_window", TeslemetryCoverStates.CLOSED),
("vehicle_state_fp_window", TeslemetryCoverStates.CLOSED),
Expand All @@ -102,12 +95,12 @@ def is_closed(self) -> bool | None:

async def async_open_cover(self, **kwargs: Any) -> None:
"""Open windows."""
await self.run(open_unlock_charge_port)
await self.api.charge_port_door_open()
self.set((self.key, True))

async def async_close_cover(self, **kwargs: Any) -> None:
"""Close windows."""
await self.run(close_charge_port)
await self.api.charge_port_door_close()
self.set((self.key, False))


Expand All @@ -128,7 +121,7 @@ def is_closed(self) -> bool | None:

async def async_open_cover(self, **kwargs: Any) -> None:
"""Open front trunk."""
await self.run(open_front_trunk)
await self.api.actuate_trunk(Trunks.FRONT)
self.set((self.key, TeslemetryCoverStates.OPEN))


Expand All @@ -150,11 +143,11 @@ def is_closed(self) -> bool | None:
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open rear trunk."""
if self._value == TeslemetryCoverStates.CLOSED:
await self.run(open_close_rear_trunk)
self.api.actuate_trunk(Trunks.REAR)
self.set((self.key, TeslemetryCoverStates.OPEN))

async def async_close_cover(self, **kwargs: Any) -> None:
"""Close rear trunk."""
if self._value == TeslemetryCoverStates.OPEN:
await self.run(open_close_rear_trunk)
self.api.actuate_trunk(Trunks.REAR)
self.set((self.key, TeslemetryCoverStates.CLOSED))

0 comments on commit 333102a

Please sign in to comment.