-- THE POST BELOW HAS BEEN EDITED. THE CODE NOW WORKS AS EXPECTED AND EDITED AS SUCH --
I've been using this library for a while at home and have had no problems with it on my own SL.
I made this function that I added to the hue feedback function library:
The purpose was to be able to dim with standard KNX. This works well in my home with this script (attached to dim GA):
I tried loading this onto our demo "apartment" SL in our office and I'm having a problem getting the desired result. The error log outputs this when trying to run it:
I´m expecting a JSON table, so that I can get to the Bri variable.
At home I have a v1 HUE hub and HW2 SL. At the office we have a v2 HUE hub and HW3 Wiser. Is the problem simply the ltn12 vs. ssl.http? I've tried to change that, but to no avail.
Any tips?
I've been using this library for a while at home and have had no problems with it on my own SL.
I made this function that I added to the hue feedback function library:
Code:
function getBri(Light_num)
local response = {}
socket.http.request({
url = "http://"..ip_add.."/api/"..user.."/lights/"..tostring(Light_num),
method = 'GET',
sink = ltn12.sink.table(response),
headers = {
['content-type'] = 'application/json',
},
source = ltn12.source.string(),
})
return response
end
The purpose was to be able to dim with standard KNX. This works well in my home with this script (attached to dim GA):
Code:
require('json')
-- Lamp id
lamp_id = 1
-----------------------------------------
start = event.getvalue()
val = getBri(lamp_id)
result = table.concat(val)
json_data = json.pdecode(result)
bri = tonumber(json_data.state.bri)
-- DIM Philips HUE Up
if start == 09 then
value = bri + 30
body_msg = '{"on":true,"bri":'..value..'}'
sendToLight(lamp_id,body_msg)
-- DIM Philips HUE Down
elseif start == 01 then
value = bri - 30
body_msg = '{"on":true,"bri":'..value..'}'
sendToLight(lamp_id,body_msg)
end
-----------------------------------------
I tried loading this onto our demo "apartment" SL in our office and I'm having a problem getting the desired result. The error log outputs this when trying to run it:
Code:
* table:
[1]
* string: <html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>
I´m expecting a JSON table, so that I can get to the Bri variable.
At home I have a v1 HUE hub and HW2 SL. At the office we have a v2 HUE hub and HW3 Wiser. Is the problem simply the ltn12 vs. ssl.http? I've tried to change that, but to no avail.
Any tips?