This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Homewizard websocket
#1
In the new Homewizard v2 api there's a websocket to receive device updates, see:
WebSocket | HomeWizard Energy API Documentation

From the forum i used an example, but i received an error:
Code:
* table: ["type"]   * string: authorization_requested ["data"]   * table:    ["api_version"]     * string: 2.0.1 * string: receive failed: error:0A000126:SSL routines::unexpected eof while reading

My code
Code:
if not client then   ws = require('user.websocket')   json = require('json')     local ip = 'MYIP'   local token = 'MYTOKEN'   local url = 'wss://' .. ip .. '/api/ws'   client, err = ws.client('sync', 10)   res, err = client:connect(url)   if res then     -- send authorization     client:send(json.encode({       type = 'authorization',       payload = 'data=' .. token,     }))         -- subscribe op batteries         --client:send(json.encode({           --type = 'subscribe',           --data = 'batteries'         --}))   else     log('connection failed: ' .. tostring(err))     client:close()     client = nil   end else   data, _, _, opcode, err = client:receive()   if data then     data = json.pdecode(data)     if data then       log(data)     end   else     log('receive failed: ' .. tostring(err))     client:close()     client = nil   end end
Reply


Messages In This Thread
Homewizard websocket - by gjniewenhuijse - 16.10.2025, 09:20
RE: Homewizard websocket - by admin - 16.10.2025, 09:39
RE: Homewizard websocket - by gjniewenhuijse - 16.10.2025, 09:39
RE: Homewizard websocket - by admin - 16.10.2025, 10:11
RE: Homewizard websocket - by gjniewenhuijse - 17.10.2025, 12:54
RE: Homewizard websocket - by admin - 17.10.2025, 12:58

Forum Jump: