Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -20,20 +20,19 @@ CAPABILITY_TO_ATTRIB = {
|
|||
Capability.water_sensor: Attribute.water,
|
||||
}
|
||||
ATTRIB_TO_CLASS = {
|
||||
Attribute.acceleration: 'moving',
|
||||
Attribute.contact: 'opening',
|
||||
Attribute.filter_status: 'problem',
|
||||
Attribute.motion: 'motion',
|
||||
Attribute.presence: 'presence',
|
||||
Attribute.sound: 'sound',
|
||||
Attribute.tamper: 'problem',
|
||||
Attribute.valve: 'opening',
|
||||
Attribute.water: 'moisture',
|
||||
Attribute.acceleration: "moving",
|
||||
Attribute.contact: "opening",
|
||||
Attribute.filter_status: "problem",
|
||||
Attribute.motion: "motion",
|
||||
Attribute.presence: "presence",
|
||||
Attribute.sound: "sound",
|
||||
Attribute.tamper: "problem",
|
||||
Attribute.valve: "opening",
|
||||
Attribute.water: "moisture",
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Platform uses config entry setup."""
|
||||
pass
|
||||
|
||||
|
@ -43,8 +42,7 @@ 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 in broker.get_assigned(
|
||||
device.device_id, 'binary_sensor'):
|
||||
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)
|
||||
|
@ -52,8 +50,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
|
||||
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]
|
||||
return [
|
||||
capability for capability in CAPABILITY_TO_ATTRIB if capability in capabilities
|
||||
]
|
||||
|
||||
|
||||
class SmartThingsBinarySensor(SmartThingsEntity, BinarySensorDevice):
|
||||
|
@ -67,12 +66,12 @@ class SmartThingsBinarySensor(SmartThingsEntity, BinarySensorDevice):
|
|||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the binary sensor."""
|
||||
return '{} {}'.format(self._device.label, self._attribute)
|
||||
return "{} {}".format(self._device.label, self._attribute)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return a unique ID."""
|
||||
return '{}.{}'.format(self._device.device_id, self._attribute)
|
||||
return "{}.{}".format(self._device.device_id, self._attribute)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue