2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Volvo On Call locks."""
|
2017-02-19 01:09:25 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from homeassistant.components.lock import LockDevice
|
2019-03-21 05:56:46 +00:00
|
|
|
|
|
|
|
from . import DATA_KEY, VolvoEntity
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2019-02-13 20:21:14 +00:00
|
|
|
async def async_setup_platform(
|
|
|
|
hass, config, async_add_entities, discovery_info=None):
|
2017-05-02 16:18:47 +00:00
|
|
|
"""Set up the Volvo On Call lock."""
|
2017-02-19 01:09:25 +00:00
|
|
|
if discovery_info is None:
|
|
|
|
return
|
2017-05-02 16:18:47 +00:00
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
async_add_entities([VolvoLock(hass.data[DATA_KEY], *discovery_info)])
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VolvoLock(VolvoEntity, LockDevice):
|
|
|
|
"""Represents a car lock."""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_locked(self):
|
|
|
|
"""Return true if lock is locked."""
|
2018-11-30 18:07:42 +00:00
|
|
|
return self.instrument.is_locked
|
2017-02-19 01:09:25 +00:00
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
async def async_lock(self, **kwargs):
|
2017-02-19 01:09:25 +00:00
|
|
|
"""Lock the car."""
|
2018-11-30 18:07:42 +00:00
|
|
|
await self.instrument.lock()
|
2017-02-19 01:09:25 +00:00
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
async def async_unlock(self, **kwargs):
|
2017-02-19 01:09:25 +00:00
|
|
|
"""Unlock the car."""
|
2018-11-30 18:07:42 +00:00
|
|
|
await self.instrument.unlock()
|