lock.sesame: Update pysesame, add state attributes (#7953)
* Update pysesame requirement to 0.1.0 to support caching * Set `available` property based on API enabled status * Add state attributes for device ID and battery level
This commit is contained in:
parent
aaaf9637eb
commit
c52b18d7c8
2 changed files with 19 additions and 5 deletions
|
@ -10,10 +10,13 @@ import voluptuous as vol
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.lock import LockDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_EMAIL, CONF_PASSWORD, STATE_LOCKED, STATE_UNLOCKED)
|
||||
ATTR_BATTERY_LEVEL, CONF_EMAIL, CONF_PASSWORD,
|
||||
STATE_LOCKED, STATE_UNLOCKED)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
REQUIREMENTS = ['pysesame==0.0.2']
|
||||
REQUIREMENTS = ['pysesame==0.1.0']
|
||||
|
||||
ATTR_DEVICE_ID = 'device_id'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_EMAIL): cv.string,
|
||||
|
@ -37,12 +40,10 @@ def setup_platform(hass, config: ConfigType,
|
|||
class SesameDevice(LockDevice):
|
||||
"""Representation of a Sesame device."""
|
||||
|
||||
device_id = None
|
||||
_sesame = None
|
||||
|
||||
def __init__(self, sesame: object) -> None:
|
||||
"""Initialize the Sesame device."""
|
||||
self.device_id = sesame.device_id
|
||||
self._sesame = sesame
|
||||
|
||||
@property
|
||||
|
@ -50,6 +51,11 @@ class SesameDevice(LockDevice):
|
|||
"""Return the name of the device."""
|
||||
return self._sesame.nickname
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return self._sesame.api_enabled
|
||||
|
||||
@property
|
||||
def is_locked(self) -> bool:
|
||||
"""Return True if the device is currently locked, else False."""
|
||||
|
@ -73,3 +79,11 @@ class SesameDevice(LockDevice):
|
|||
def update(self) -> None:
|
||||
"""Update the internal state of the device."""
|
||||
self._sesame.update_state()
|
||||
|
||||
@property
|
||||
def device_state_attributes(self) -> dict:
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
attributes[ATTR_DEVICE_ID] = self._sesame.device_id
|
||||
attributes[ATTR_BATTERY_LEVEL] = self._sesame.battery
|
||||
return attributes
|
||||
|
|
|
@ -632,7 +632,7 @@ pysensibo==1.0.1
|
|||
pyserial==3.1.1
|
||||
|
||||
# homeassistant.components.lock.sesame
|
||||
pysesame==0.0.2
|
||||
pysesame==0.1.0
|
||||
|
||||
# homeassistant.components.sensor.sma
|
||||
pysma==0.1.3
|
||||
|
|
Loading…
Add table
Reference in a new issue