Skip to content
Snippets Groups Projects
Commit d3454c8d authored by KERDREUX Jerome's avatar KERDREUX Jerome
Browse files

Initial nodes found ;)

parent d21f22cd
No related branches found
No related tags found
No related merge requests found
# from xaal.lib import tools # from xaal.lib import tools
import asyncio
import pdb import pdb
import logging import logging
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from aiohttp.client import ClientSession from aiohttp.client import ClientSession
from xaal.lib import AsyncEngine, Device
from xaal.schemas import devices
PACKAGE_NAME = 'xaal.zwavejs' PACKAGE_NAME = 'xaal.zwavejs'
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -13,17 +17,31 @@ URL = "ws://10.77.3.143:3000" ...@@ -13,17 +17,31 @@ URL = "ws://10.77.3.143:3000"
class GW: class GW:
def __init__(self, engine): def __init__(self, engine: AsyncEngine):
self.engine = engine self.engine = engine
logger.debug("ZwaveJS gateway initialized") logger.debug("ZwaveJS gateway initialized")
engine.on_start(self.start) engine.on_start(self.start)
gw = devices.gateway()
gw.new_attribute("gw", self)
engine.add_device(gw)
async def start(self): async def start(self):
sess = ClientSession() sess = ClientSession()
self.client = ZwaveClient(URL, sess) self.client = ZwaveClient(URL, sess)
await self.client.connect() await self.client.connect()
await self.client.initialize() self.ready = asyncio.Event()
await self.client.receive_until_closed() self.engine.new_task(self.client.listen(self.ready))
# await self.client.listen(ready)
logger.warning("Done")
await self.run()
async def run(self):
await self.ready.wait()
# logger.warning(self.client.controller.nodes)
logger.warning("ZwaveJS ready")
nodes = self.client.driver.controller.nodes
for node in nodes:
logger.warning(node)
def setup(eng): def setup(eng):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment