1 """Lock platform for Tessie integration."""
3 from __future__
import annotations
7 from tessie_api
import lock, open_unlock_charge_port, unlock
14 from .
import TessieConfigEntry
15 from .const
import DOMAIN, TessieChargeCableLockStates
16 from .entity
import TessieEntity
17 from .models
import TessieVehicleData
24 entry: TessieConfigEntry,
25 async_add_entities: AddEntitiesCallback,
27 """Set up the Tessie sensor platform from a config entry."""
28 data = entry.runtime_data
32 for klass
in (TessieLockEntity, TessieCableLockEntity)
33 for vehicle
in data.vehicles
38 """Lock entity for Tessie."""
42 vehicle: TessieVehicleData,
44 """Initialize the sensor."""
45 super().
__init__(vehicle,
"vehicle_state_locked")
49 """Return the state of the Lock."""
54 await self.
runrun(lock)
55 self.
setset((self.
keykey,
True))
59 await self.
runrun(unlock)
60 self.
setset((self.
keykey,
False))
64 """Cable Lock entity for Tessie."""
68 vehicle: TessieVehicleData,
70 """Initialize the sensor."""
71 super().
__init__(vehicle,
"charge_state_charge_port_latch")
75 """Return the state of the Lock."""
79 """Charge cable Lock cannot be manually locked."""
81 translation_domain=DOMAIN,
82 translation_key=
"no_cable",
86 """Unlock charge cable lock."""
87 await self.
runrun(open_unlock_charge_port)
88 self.
setset((self.
keykey, TessieChargeCableLockStates.DISENGAGED))
None set(self, *Any args)
None run(self, Callable[..., Awaitable[dict[str, Any]]] func, **Any kargs)
None __init__(self, TessieVehicleData vehicle)
None async_lock(self, **Any kwargs)
bool|None is_locked(self)
None async_unlock(self, **Any kwargs)
None __init__(self, TessieVehicleData vehicle)
None async_lock(self, **Any kwargs)
bool|None is_locked(self)
None async_unlock(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, TessieConfigEntry entry, AddEntitiesCallback async_add_entities)