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.

Philips Hue api v2
#10
(03.02.2022, 09:50)admin Wrote: Does it work for you with curl? HTTPS is 443 but some extra code is needed for the raw socket to use encryption: https://forum.logicmachine.net/showthrea...903#pid903

yep, curl for windows code works:
curl --insecure -N -H "hue-application-key: sameapiuserasbefore" -H "Accept: text/event-stream" https://myipaddress/eventstream/clip/v2

and thx, the raw socket example works also.

working code for evenstream

Code:
if not sock then
  host = 'fillyourip'
  port = 443
  proto = 'tlsv12'
  path = '/eventstream/clip/v2'
  appkey = 'fillyouruser'

  require('ssl')
  sock = require('socket').tcp()
  sock:settimeout(10)
  res, err = sock:connect(host, port)
  if res then
    sock = ssl.wrap(sock, proto)
      res, err = sock:dohandshake()
    if res then
      sock:send(
        'GET ' .. path .. ' HTTP/1.1\r\n' ..
        'Host: ' .. host .. '\r\n' ..
        'Accept: text/event-stream\r\n' ..
        'hue-application-key: ' .. appkey .. '\r\n' ..
        '\r\n'
      )
        else
        log('handshake failed: ' .. tostring(err))
      end
  else
    log('connect failed: ' .. tostring(err))
    sock:close()
  end
end

line, err = sock:receive()

if line then
  --log('line: ' .. line)
  if line:find(': hi') then
    log('connection ok: ', line)
  elseif line:find('data:') then
    --status = line:split(':')[2]
    log('data', line)
  end
else
  log('receive failed: ' .. tostring(err))
  sock:close()
  sock = nil
end
Reply


Messages In This Thread
Philips Hue api v2 - by gjniewenhuijse - 02.02.2022, 13:17
RE: Philips Hue api v2 - by gjniewenhuijse - 02.02.2022, 14:53
RE: Philips Hue api v2 - by admin - 02.02.2022, 15:53
RE: Philips Hue api v2 - by gjniewenhuijse - 02.02.2022, 18:51
RE: Philips Hue api v2 - by admin - 03.02.2022, 07:21
RE: Philips Hue api v2 - by gjniewenhuijse - 03.02.2022, 09:11
RE: Philips Hue api v2 - by admin - 03.02.2022, 09:22
RE: Philips Hue api v2 - by gjniewenhuijse - 03.02.2022, 09:34
RE: Philips Hue api v2 - by admin - 03.02.2022, 09:50
RE: Philips Hue api v2 - by gjniewenhuijse - 03.02.2022, 10:12
RE: Philips Hue api v2 - by gjniewenhuijse - 03.02.2022, 14:58
RE: Philips Hue api v2 - by Joep - 10.01.2023, 09:16

Forum Jump: