1 """Cover platform for Teslemetry integration."""
3 from __future__
import annotations
7 from tesla_fleet_api.const
import Scope, SunRoofCommand, Trunk, WindowCommand
17 from .
import TeslemetryConfigEntry
18 from .entity
import TeslemetryVehicleEntity
19 from .helpers
import handle_vehicle_command
20 from .models
import TeslemetryVehicleData
30 entry: TeslemetryConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up the Teslemetry cover platform from a config entry."""
36 klass(vehicle, entry.runtime_data.scopes)
38 TeslemetryWindowEntity,
39 TeslemetryChargePortEntity,
40 TeslemetryFrontTrunkEntity,
41 TeslemetryRearTrunkEntity,
42 TeslemetrySunroofEntity,
44 for vehicle
in entry.runtime_data.vehicles
49 """Cover entity for the windows."""
51 _attr_device_class = CoverDeviceClass.WINDOW
53 def __init__(self, data: TeslemetryVehicleData, scopes: list[Scope]) ->
None:
54 """Initialize the cover."""
56 self.
scopedscoped = Scope.VEHICLE_CMDS
in scopes
58 CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
64 """Update the entity attributes."""
65 fd = self.
getget(
"vehicle_state_fd_window")
66 fp = self.
getget(
"vehicle_state_fp_window")
67 rd = self.
getget(
"vehicle_state_rd_window")
68 rp = self.
getget(
"vehicle_state_rp_window")
71 if OPEN
in (fd, fp, rd, rp):
74 elif CLOSED == fd == fp == rd == rp:
102 """Cover entity for the charge port."""
104 _attr_device_class = CoverDeviceClass.DOOR
106 def __init__(self, vehicle: TeslemetryVehicleData, scopes: list[Scope]) ->
None:
107 """Initialize the cover."""
108 super().
__init__(vehicle,
"charge_state_charge_port_door_open")
111 for scope
in (Scope.VEHICLE_CMDS, Scope.VEHICLE_CHARGING_CMDS)
114 CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
120 """Update the entity attributes."""
124 """Open charge port."""
132 """Close charge port."""
141 """Cover entity for the front trunk."""
143 _attr_device_class = CoverDeviceClass.DOOR
145 def __init__(self, vehicle: TeslemetryVehicleData, scopes: list[Scope]) ->
None:
146 """Initialize the cover."""
147 super().
__init__(vehicle,
"vehicle_state_ft")
149 self.
scopedscoped = Scope.VEHICLE_CMDS
in scopes
155 """Update the entity attributes."""
159 """Open front trunk."""
168 """Cover entity for the rear trunk."""
170 _attr_device_class = CoverDeviceClass.DOOR
172 def __init__(self, vehicle: TeslemetryVehicleData, scopes: list[Scope]) ->
None:
173 """Initialize the cover."""
174 super().
__init__(vehicle,
"vehicle_state_rt")
176 self.
scopedscoped = Scope.VEHICLE_CMDS
in scopes
178 CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
184 """Update the entity attributes."""
188 """Open rear trunk."""
197 """Close rear trunk."""
207 """Cover entity for the sunroof."""
209 _attr_device_class = CoverDeviceClass.WINDOW
210 _attr_supported_features = (
211 CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
213 _attr_entity_registry_enabled_default =
False
215 def __init__(self, vehicle: TeslemetryVehicleData, scopes: list[Scope]) ->
None:
216 """Initialize the sensor."""
217 super().
__init__(vehicle,
"vehicle_state_sun_roof_state")
219 self.
scopedscoped = Scope.VEHICLE_CMDS
in scopes
224 """Update the entity attributes."""
226 if value
in (
None,
"unknown"):
232 "vehicle_state_sun_roof_percent_open"
bool|None is_closed(self)
None async_open_cover(self, **Any kwargs)
None _async_update_attrs(self)
None __init__(self, TeslemetryVehicleData vehicle, list[Scope] scopes)
None async_close_cover(self, **Any kwargs)
None _async_update_attrs(self)
None async_open_cover(self, **Any kwargs)
None __init__(self, TeslemetryVehicleData vehicle, list[Scope] scopes)
None _async_update_attrs(self)
None async_close_cover(self, **Any kwargs)
None async_open_cover(self, **Any kwargs)
None __init__(self, TeslemetryVehicleData vehicle, list[Scope] scopes)
_attr_current_cover_position
None async_stop_cover(self, **Any kwargs)
tuple _attr_supported_features
None _async_update_attrs(self)
None __init__(self, TeslemetryVehicleData vehicle, list[Scope] scopes)
None async_open_cover(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
None __init__(self, TeslemetryVehicleData data, list[Scope] scopes)
None _async_update_attrs(self)
None async_open_cover(self, **Any kwargs)
def raise_for_scope(self, Scope scope)
Any|None get(self, str key, Any|None default=None)
None wake_up_if_asleep(self)
None async_write_ha_state(self)
bool handle_vehicle_command(Awaitable command)
None async_setup_entry(HomeAssistant hass, TeslemetryConfigEntry entry, AddEntitiesCallback async_add_entities)