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,5 +1,6 @@
|
||||
"""Support for sensors through the SmartThings cloud API."""
|
||||
from collections import namedtuple
|
||||
from typing import Optional, Sequence
|
||||
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE,
|
||||
@@ -164,16 +165,22 @@ 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, maps in CAPABILITY_TO_SENSORS.items():
|
||||
if capability in device.capabilities:
|
||||
sensors.extend([
|
||||
SmartThingsSensor(
|
||||
device, m.attribute, m.name, m.default_unit,
|
||||
m.device_class)
|
||||
for m in maps])
|
||||
for capability in broker.get_assigned(device.device_id, 'sensor'):
|
||||
maps = CAPABILITY_TO_SENSORS[capability]
|
||||
sensors.extend([
|
||||
SmartThingsSensor(
|
||||
device, m.attribute, m.name, m.default_unit,
|
||||
m.device_class)
|
||||
for m in maps])
|
||||
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_SENSORS
|
||||
if capability in capabilities]
|
||||
|
||||
|
||||
class SmartThingsSensor(SmartThingsEntity):
|
||||
"""Define a SmartThings Binary Sensor."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user