2

I'm trying to create some stuff on my Philips-Hue installation, using Symfony. I'm able to control my lights, get motion sensor,... But all is working with GET requests. This is a very bad idea ;)

API provided by Philips comes with Events endpoint, as described here : Core-concepts of meethue

So, I tried to use the "Consuming Server Events" capability of Symfony in my application.

I do not understand how to use it? I tried to find more information, but this is always regarding sending information. I want to consume informations. I tried to create some route, but the connect function does not end (I assume this is the normal way). So how to use the "$source" created by the call?

During my searches, I noticed that, if I enter one bad key, I get an error (Full HTML response), but this does not throw any Exception on the connect function. For me, as written line 112 of source code, it should be.

For example, when using curl call:

curl --insecure -N -H 'hue-application-key: ThisIsAVeryBadKey' -H 'Accept: text/event-stream' https://ip-bridge/eventstream/clip/v2

I get:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>hue personal wireless lighting</title>
    <link rel="stylesheet" type="text/css" href="/index.css">
</head>
<body>
    <div class="philips-header">
      <img src="/philips-blue.png" class="philips-logo" alt="Philips" />
    </div>
    <div class="header">
      <img class="header-logo" src="/hue-logo.png" alt="hue personal wireless lighting" />

      <img src="/hue-color-line.png" class="colorline" />

    </div>
    <div class="error">Oops, there appears to be no lighting here</div>
</body>
</html>

If I use a good key, I have the following:

:hi

id: 1639957108:0
data: [{"creationtime":"2021-12-19T23:38:28Z","data":[{"id":"YYYY","id_v1":"/sensors/30","owner":{"rid":"XXXXX","rtype":"device"},"temperature":{"temperature":19.059999465942383,"temperature_valid":true},"type":"temperature"}],"id":"ZZZZZ","type":"update"}]

Regards,

0 Answers0