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:
parent
7d0f847f83
commit
93f84a5cd1
20 changed files with 196 additions and 151 deletions
|
@ -1,4 +1,6 @@
|
|||
"""Support for binary sensors through the SmartThings cloud API."""
|
||||
from typing import Optional, Sequence
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
|
||||
from . import SmartThingsEntity
|
||||
|
@ -41,12 +43,19 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
|
||||
sensors = []
|
||||
for device in broker.devices.values():
|
||||
for capability, attrib in CAPABILITY_TO_ATTRIB.items():
|
||||
if capability in device.capabilities:
|
||||
sensors.append(SmartThingsBinarySensor(device, attrib))
|
||||
for capability in broker.get_assigned(
|
||||
device.device_id, 'binary_sensor'):
|
||||
attrib = CAPABILITY_TO_ATTRIB[capability]
|
||||
sensors.append(SmartThingsBinarySensor(device, attrib))
|
||||
async_add_entities(sensors)
|
||||
|
||||
|
||||
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
|
||||
"""Return all capabilities supported if minimum required are present."""
|
||||
return [capability for capability in CAPABILITY_TO_ATTRIB
|
||||
if capability in capabilities]
|
||||
|
||||
|
||||
class SmartThingsBinarySensor(SmartThingsEntity, BinarySensorDevice):
|
||||
"""Define a SmartThings Binary Sensor."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue