Skip to content

Commit

Permalink
Added async - await
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed May 27, 2022
1 parent 3e8c41e commit 36d191d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion fastybird_devices_module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
Devices module
"""

__version__ = "0.58.0"
__version__ = "0.59.0"
28 changes: 14 additions & 14 deletions fastybird_devices_module/connectors/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def reset_devices_channels_properties(self, channel: ChannelEntity) -> None:
# -----------------------------------------------------------------------------

@abstractmethod
def start(self) -> None:
async def start(self) -> None:
"""Start connector service"""

# -----------------------------------------------------------------------------
Expand All @@ -252,13 +252,13 @@ def has_unfinished_tasks(self) -> bool:
# -----------------------------------------------------------------------------

@abstractmethod
def write_property(self, property_item: Union[DevicePropertyEntity, ChannelPropertyEntity], data: Dict) -> None:
async def write_property(self, property_item: Union[DevicePropertyEntity, ChannelPropertyEntity], data: Dict) -> None:
"""Write device or channel property value to device"""

# -----------------------------------------------------------------------------

@abstractmethod
def write_control(
async def write_control(
self,
control_item: Union[ConnectorControlEntity, DeviceControlEntity, ChannelControlEntity],
data: Optional[Dict],
Expand Down Expand Up @@ -350,7 +350,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-locals

# -----------------------------------------------------------------------------

def start(self) -> None:
async def start(self) -> None:
"""Start connector service"""
self.__stopped = False

Expand All @@ -362,7 +362,7 @@ def start(self) -> None:
asyncio.ensure_future(self.__queue_process())

# Send start command to loaded connector
self.__connector.start()
await self.__connector.start()

except Exception as ex: # pylint: disable=broad-except
self.__logger.exception(ex)
Expand Down Expand Up @@ -483,10 +483,10 @@ async def __queue_process(self) -> None:
if queue_item is not None:
try:
if isinstance(queue_item, ConsumePropertyActionMessageQueueItem):
self.__write_property_command(item=queue_item)
await self.__write_property_command(item=queue_item)

if isinstance(queue_item, ConsumeControlActionMessageQueueItem):
self.__write_control_command(item=queue_item)
await self.__write_control_command(item=queue_item)

if isinstance(queue_item, ConsumeEntityMessageQueueItem):
self.__handle_entity_event(item=queue_item)
Expand All @@ -511,7 +511,7 @@ async def __queue_process(self) -> None:

# -----------------------------------------------------------------------------

def __write_property_command( # pylint: disable=too-many-return-statements
async def __write_property_command( # pylint: disable=too-many-return-statements
self,
item: ConsumePropertyActionMessageQueueItem,
) -> None:
Expand Down Expand Up @@ -540,7 +540,7 @@ def __write_property_command( # pylint: disable=too-many-return-statements

return

self.__connector.write_property(device_property, item.data)
await self.__connector.write_property(device_property, item.data)

if item.routing_key == RoutingKey.CHANNEL_PROPERTY_ACTION:
try:
Expand All @@ -564,11 +564,11 @@ def __write_property_command( # pylint: disable=too-many-return-statements

return

self.__connector.write_property(channel_property, item.data)
await self.__connector.write_property(channel_property, item.data)

# -----------------------------------------------------------------------------

def __write_control_command( # pylint: disable=too-many-return-statements
async def __write_control_command( # pylint: disable=too-many-return-statements
self,
item: ConsumeControlActionMessageQueueItem,
) -> None:
Expand All @@ -590,7 +590,7 @@ def __write_control_command( # pylint: disable=too-many-return-statements

return

self.__connector.write_control(
await self.__connector.write_control(
control_item=device_control,
data=item.data,
action=ControlAction(item.data.get("name")),
Expand All @@ -610,7 +610,7 @@ def __write_control_command( # pylint: disable=too-many-return-statements

return

self.__connector.write_control(
await self.__connector.write_control(
control_item=channel_control,
data=item.data,
action=ControlAction(item.data.get("name")),
Expand All @@ -630,7 +630,7 @@ def __write_control_command( # pylint: disable=too-many-return-statements

return

self.__connector.write_control(
await self.__connector.write_control(
control_item=connector_control,
data=item.data,
action=ControlAction(item.data.get("name")),
Expand Down
2 changes: 1 addition & 1 deletion fastybird_devices_module/managers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def create(self, data: Dict) -> DeviceAttributeEntity:
data={**data, **{"attribute_id": data.get("id", None)}},
entity_type=DeviceAttributeEntity,
required_fields=self.__REQUIRED_FIELDS,
writable_fields=[],
writable_fields=self.__WRITABLE_FIELDS,
)

# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastybird/devices-module",
"version": "0.58.0",
"version": "0.59.0",
"description": "Devices module data model plugin",
"keywords": [
"devices",
Expand Down

0 comments on commit 36d191d

Please sign in to comment.