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
#4
(02.02.2022, 15:53)admin Wrote: You can adapt this code for your use case: https://forum.logicmachine.net/showthrea...1#pid15941
Add headers to initial request lines and change APPKEY to the actual application key:
Code:
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'
)

i think i do something wrong because the output of the lines is the same as the bridge html source what i see in the browser

Code:
if not sock then
  host = 'my bridge ip'
  port = 80
  path = '/eventstream/clip/v2'
  appkey = 'mysecretappkey'

  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' ..
      'Accept: text/event-stream\r\n' ..
      'hue-application-key: ' .. appkey .. '\r\n' ..
      '\r\n'
    )
  else
    log('connect failed: ' .. tostring(err))
    sock:close()
  end
end

line, err = sock:receive()

if line then
  log('line: ' .. line)
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
RE: Philips Hue api v2 - by Fcs - 04.11.2024, 14:17
RE: Philips Hue api v2 - by gjniewenhuijse - 05.11.2024, 07:18

Forum Jump: