Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -10,21 +10,20 @@ OUTLET_IN_USE = "outlet_in_use"
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
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):
|
||||
"""Legacy set up platform."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up Homekit lock."""
|
||||
hkid = config_entry.data['AccessoryPairingID']
|
||||
hkid = config_entry.data["AccessoryPairingID"]
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
def async_add_service(aid, service):
|
||||
if service['stype'] not in ('switch', 'outlet'):
|
||||
if service["stype"] not in ("switch", "outlet"):
|
||||
return False
|
||||
info = {'aid': aid, 'iid': service['iid']}
|
||||
info = {"aid": aid, "iid": service["iid"]}
|
||||
async_add_entities([HomeKitSwitch(conn, info)], True)
|
||||
return True
|
||||
|
||||
|
@ -44,10 +43,8 @@ class HomeKitSwitch(HomeKitEntity, SwitchDevice):
|
|||
"""Define the homekit characteristics the entity cares about."""
|
||||
# pylint: disable=import-error
|
||||
from homekit.model.characteristics import CharacteristicsTypes
|
||||
return [
|
||||
CharacteristicsTypes.ON,
|
||||
CharacteristicsTypes.OUTLET_IN_USE,
|
||||
]
|
||||
|
||||
return [CharacteristicsTypes.ON, CharacteristicsTypes.OUTLET_IN_USE]
|
||||
|
||||
def _update_on(self, value):
|
||||
self._on = value
|
||||
|
@ -63,22 +60,16 @@ class HomeKitSwitch(HomeKitEntity, SwitchDevice):
|
|||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn the specified switch on."""
|
||||
self._on = True
|
||||
characteristics = [{'aid': self._aid,
|
||||
'iid': self._chars['on'],
|
||||
'value': True}]
|
||||
characteristics = [{"aid": self._aid, "iid": self._chars["on"], "value": True}]
|
||||
await self._accessory.put_characteristics(characteristics)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the specified switch off."""
|
||||
characteristics = [{'aid': self._aid,
|
||||
'iid': self._chars['on'],
|
||||
'value': False}]
|
||||
characteristics = [{"aid": self._aid, "iid": self._chars["on"], "value": False}]
|
||||
await self._accessory.put_characteristics(characteristics)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the optional state attributes."""
|
||||
if self._outlet_in_use is not None:
|
||||
return {
|
||||
OUTLET_IN_USE: self._outlet_in_use,
|
||||
}
|
||||
return {OUTLET_IN_USE: self._outlet_in_use}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue