10.10.2022, 13:48
(11.03.2020, 06:59)admin Wrote: Try this resident script (sleep time = 0), change USER and PASS to your auth data. It will log all incoming data (log(line)). This is to check if there are any errors during communication. If everything is working then comment/delete this line.Hello together, i think the code you provided does not fit for python, so i changed it a bit to make it work.. But i still receive error-code 504 back for this. Could you provide a solution which fits for python?
Code:123456789101112131415161718192021222324252627282930313233343536373839if not sock then host = '192.168.100.211' port = 80 path = '/bha-api/monitor.cgi?ring=doorbell,motionsensor&http-user=USER&http-password=PASS' sock = require('socket').tcp() sock:settimeout(10) res, err = sock:connect(host, port) if res then sock:send( 'GET ' .. path .. ' HTTP/1.1\r\n' .. 'Host: ' .. host .. '\r\n\r\n' ) else alert('connect failed: ' .. tostring(err)) sock:close() sock = nil os.sleep(5) end end line, err = sock:receive() if line then log(line) if line:find('doorbell:') then status = line:split(':')[2] log('doorbell', line) elseif line:find('motionsensor:') then status = line:split(':')[2] log('motionsensor', status) end else alert('receive failed: ' .. tostring(err)) sock:close() sock = nil end