Hello,
I am considering writing a driver that's going to listen to /zigbeeLogsocket
web socket (this is what Zeegbee Log is doing). Based on this information I can find out devices that have connectivity issues so I can troubleshoot them later.
The following code on python does it without any problem.
import asyncio
import websockets
async def hello():
async with websockets.connect("ws://192.168.1.71/zigbeeLogsocket") as websocket:
while True:
print(await websocket.recv())
asyncio.run(hello())
Here is the similar code for my driver that does pretty much the same, except if fails:
def refresh() {
log.debug 'Refreshing data'
webSocketConnect()
}
void webSocketConnect() {
final String wsUrl = "ws://192.168.1.71/zigbeeLogsocket"
log.debug "wsUrl: $wsUrl"
try {
interfaces.webSocket.connect(wsUrl)
log.debug "Connection has been established"
}
catch (e) {
log.debug "Initialize error: ${e.message} ${e}"
log.error "WebSocket connect failed: ${e}"
}
}
void webSocketStatus(final String status) {
log.debug "webSocketStatus: ${status}"
}
Log
22:57:34.779 debug webSocketStatus: failure: Failed to connect to /192.168.1.71:80
22:57:34.765 debug Connection has been established
22:57:34.763 debug wsUrl: ws://192.168.1.71/zigbeeLogsocket
22:57:34.746 debug Refreshing data
Please advise what the problem might be.
p.s. this is my second driver, I might be missing some obvious stuff.