1 """Support for Subaru door locks."""
6 import voluptuous
as vol
15 from .
import DOMAIN, get_device_info
20 SERVICE_UNLOCK_SPECIFIC_DOOR,
23 VEHICLE_HAS_REMOTE_SERVICE,
27 from .remote_service
import async_call_remote_service
29 _LOGGER = logging.getLogger(__name__)
34 config_entry: ConfigEntry,
35 async_add_entities: AddEntitiesCallback,
37 """Set up the Subaru locks by config_entry."""
38 entry = hass.data[DOMAIN][config_entry.entry_id]
39 controller = entry[ENTRY_CONTROLLER]
40 vehicle_info = entry[ENTRY_VEHICLES]
43 for vehicle
in vehicle_info.values()
44 if vehicle[VEHICLE_HAS_REMOTE_SERVICE]
47 platform = entity_platform.async_get_current_platform()
49 platform.async_register_entity_service(
50 SERVICE_UNLOCK_SPECIFIC_DOOR,
51 {vol.Required(ATTR_DOOR): vol.In(UNLOCK_VALID_DOORS)},
52 "async_unlock_specific_door",
57 """Representation of a Subaru door lock.
59 Note that the Subaru API currently does not support returning the status of the locks. Lock status is always unknown.
62 _attr_has_entity_name =
True
63 _attr_translation_key =
"door_locks"
66 """Initialize the locks for the vehicle."""
69 vin = vehicle_info[VEHICLE_VIN]
70 self.
car_namecar_name = vehicle_info[VEHICLE_NAME]
75 """Send the lock command."""
76 _LOGGER.debug(
"Locking doors for: %s", self.
car_namecar_name)
84 """Send the unlock command."""
85 _LOGGER.debug(
"Unlocking doors for: %s", self.
car_namecar_name)
90 UNLOCK_VALID_DOORS[UNLOCK_DOOR_ALL],
94 """Send the unlock command for a specified door."""
95 _LOGGER.debug(
"Unlocking %s door for: %s", door, self.
car_namecar_name)
100 UNLOCK_VALID_DOORS[door],
def __init__(self, vehicle_info, controller)
None async_unlock(self, **Any kwargs)
def async_unlock_specific_door(self, door)
None async_lock(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
def async_call_remote_service(controller, cmd, vehicle_info, arg=None)
def get_device_info(vehicle_info)