Hue: support for CLIP v2 and updates through streaming http

Is anybody working on adding support for the new CLIP v2 api for Hue?

The biggest advantage would be that the add-on no longer needs to poll the base station to detect switches, buttons, temperature, light changes etc… instead you open an http stream and then are subscribed to received the updates that are pushed to you.

Python example of how to get resources and then subscribe to updates:

import requests
import json

# Get the available resources (lights, switches, temps, groups, scenes, dynamic scenes, ....
resource_url = 'https://10.x.x.x:443/clip/v2/resource'
resource_headers = {"hue-application-key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
r = requests.get(resource_url, headers=resource_headers, verify=False)
if r.status_code == 200:
    res_json = json.loads(r.text)
    print(res_json)
    

# Open an http stream an keep listening for pushed updates
stream_url = 'https://10.x.x.x:443/eventstream/clip/v2'
stream_headers = {"Accept": "text/event-stream", "hue-application-key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
r = requests.get(stream_url, headers=stream_headers, verify=False, timeout=20000, stream=True)
for line in r.iter_lines():
    print(line)

2 Likes

Oh so sorry but i am not sure about that… Thanks ! ! !