16.10.2025, 09:20
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:
My code
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