Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -5,7 +5,7 @@ from homeassistant.core import callback
|
|||
|
||||
from .const import DOMAIN
|
||||
|
||||
ENTITY_MAP_STORAGE_KEY = '{}-entity-map'.format(DOMAIN)
|
||||
ENTITY_MAP_STORAGE_KEY = "{}-entity-map".format(DOMAIN)
|
||||
ENTITY_MAP_STORAGE_VERSION = 1
|
||||
ENTITY_MAP_SAVE_DELAY = 10
|
||||
|
||||
|
@ -29,11 +29,7 @@ class EntityMapStorage:
|
|||
def __init__(self, hass):
|
||||
"""Create a new entity map store."""
|
||||
self.hass = hass
|
||||
self.store = Store(
|
||||
hass,
|
||||
ENTITY_MAP_STORAGE_VERSION,
|
||||
ENTITY_MAP_STORAGE_KEY
|
||||
)
|
||||
self.store = Store(hass, ENTITY_MAP_STORAGE_VERSION, ENTITY_MAP_STORAGE_KEY)
|
||||
self.storage_data = {}
|
||||
|
||||
async def async_initialize(self):
|
||||
|
@ -43,7 +39,7 @@ class EntityMapStorage:
|
|||
# There is no cached data about HomeKit devices yet
|
||||
return
|
||||
|
||||
self.storage_data = raw_storage.get('pairings', {})
|
||||
self.storage_data = raw_storage.get("pairings", {})
|
||||
|
||||
def get_map(self, homekit_id):
|
||||
"""Get a pairing cache item."""
|
||||
|
@ -51,10 +47,7 @@ class EntityMapStorage:
|
|||
|
||||
def async_create_or_update_map(self, homekit_id, config_num, accessories):
|
||||
"""Create a new pairing cache."""
|
||||
data = {
|
||||
'config_num': config_num,
|
||||
'accessories': accessories,
|
||||
}
|
||||
data = {"config_num": config_num, "accessories": accessories}
|
||||
self.storage_data[homekit_id] = data
|
||||
self._async_schedule_save()
|
||||
return data
|
||||
|
@ -75,6 +68,4 @@ class EntityMapStorage:
|
|||
@callback
|
||||
def _data_to_save(self):
|
||||
"""Return data of entity map to store in a file."""
|
||||
return {
|
||||
'pairings': self.storage_data,
|
||||
}
|
||||
return {"pairings": self.storage_data}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue