Skip to content

Commit

Permalink
close #106
Browse files Browse the repository at this point in the history
  • Loading branch information
cereal2nd committed Jun 29, 2024
1 parent aa877ae commit f8b2fca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
aiofile
backoff>=1.10.0
pyserial>=3.5.0
pyserial-asyncio-fast>=0.11
Expand Down
1 change: 1 addition & 0 deletions velbusaio/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ async def stop(self) -> None:

async def connect(self, test_connect: bool = False) -> None:
"""Connect to the bus and load all the data."""
await self._handler.read_protocol_data()
auth = None
# connect to the bus
if ":" in self._dsn:
Expand Down
13 changes: 7 additions & 6 deletions velbusaio/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import os
import pathlib

from aiofile import async_open

from typing import TYPE_CHECKING, Awaitable, Callable
import pkg_resources

Expand Down Expand Up @@ -49,15 +51,14 @@ def __init__(
self._modulescan_address = 0
self._scan_complete = False
self._scan_delay_msec = 0
with open(

async def read_protocol_data(self):
async with async_open(
pkg_resources.resource_filename(__name__, "protocol.json")
) as protocol_file:
self.pdata = json.load(protocol_file)
self.pdata = json.loads(await protocol_file.read())

async def scan(self) -> None:
reload_cache = not os.path.isfile(
pathlib.Path(f"{get_cache_dir()}/usecache.yes")
)
async def scan(self, reload_cache: bool = False) -> None:
self._log.info(f"Start module scan, reload cache {reload_cache}")
while self._modulescan_address < 254:
address = 0
Expand Down

0 comments on commit f8b2fca

Please sign in to comment.