Hue API V2

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Maxx
Posts: 58
Joined: Saturday 27 January 2018 20:59
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Hue API V2

Post by Maxx »

Hello All,

Currently I am using direct API call to hue using the v1 API version. I am trying to upgrade to API V2 and I am partly successfull. I use the following test program:

Code: Select all

	on = {
		timer = {
			'every minute' 
		},
		httpResponses = {
			'trigger' 
		}
	},
	logging = {
		level = domoticz.LOG_INFO,
		marker = 'template',
	},
	execute = function(domoticz, item)
 		if (item.isTimer) then
			domoticz.openURL({
				url = 'https://192.168.1.8/clip/v2/resource/device',
				headers = { ['hue-application-key'] = 'LqUg-Ho81HxhcjOqX4YnRbrQELiSXHjkh3' },
				method = 'GET',
				callback = 'trigger', .
				domoticz.log('HTTPS call has been done')
				
			})
		end

		if (item.isHTTPResponse) then

			if (item.ok) then
				if (item.isJSON) then
					local json = item.data
					domoticz.log(json)
				end
			else
				domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
				domoticz.log(item, domoticz.LOG_ERROR)
			end

		end

	end
}
Sometimes I get usable data back but most of the time I get a SSL error:

2024-11-25 15:22:01.917 Error: dzVents: template: HTTP/1.1 response: 35 ==>> SSL connect error

I know that V2 uses https calls only and according the Hue development site you should use the given certificate, this is probably what is going wrong at the moment.

Now the question: Does anybody know how to use a certificate in the openURL call? Is that even possible or is there another way? There are CURL examples where the certificate is sent with the CURL call.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest