SmartThings Component Enhancements/Fixes (#21085)
* Improve component setup error logging/notification * Prevent capabilities from being represented my multiple platforms * Improved logging of received updates * Updates based on review feedback
This commit is contained in:
1 parent
7d0f847f83
commit
93f84a5cd1
20 files changed
+196
-151
No files matched your search
@@ -1,4 +1,6 @@
|
||||
"""Support for locks through the SmartThings cloud API."""
|
||||
from typing import Optional, Sequence
|
||||
|
||||
from homeassistant.components.lock import LockDevice
|
||||
|
||||
from . import SmartThingsEntity
|
||||
@@ -25,13 +27,16 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
|
||||
async_add_entities(
|
||||
[SmartThingsLock(device) for device in broker.devices.values()
|
||||
if is_lock(device)])
|
||||
if broker.any_assigned(device.device_id, 'lock')])
|
||||
|
||||
|
||||
def is_lock(device):
|
||||
"""Determine if the device supports the lock capability."""
|
||||
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
|
||||
"""Return all capabilities supported if minimum required are present."""
|
||||
from pysmartthings import Capability
|
||||
return Capability.lock in device.capabilities
|
||||
|
||||
if Capability.lock in capabilities:
|
||||
return [Capability.lock]
|
||||
return None
|
||||
|
||||
|
||||
class SmartThingsLock(SmartThingsEntity, LockDevice):
|
||||
|
||||
Reference in new issue
Block a user