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.

Hue Brightness feedback
#18
-- 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:

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?
Reply


Messages In This Thread
Hue Brightness feedback - by Arjen Straver - 05.07.2017, 19:30
RE: Hue Brightness feedback - by Hippolyte - 19.07.2017, 15:14
RE: Hue Brightness feedback - by Hippolyte - 27.07.2017, 07:03
RE: Hue Brightness feedback - by Albertor - 21.11.2017, 18:22
RE: Hue Brightness feedback - by Albertor - 22.11.2017, 19:51
RE: Hue Brightness feedback - by DarthPaul - 13.08.2018, 12:19
RE: Hue Brightness feedback - by DarthPaul - 14.08.2018, 04:42
RE: Hue Brightness feedback - by admin - 13.08.2018, 12:40
RE: Hue Brightness feedback - by ralwet - 19.10.2018, 20:28
RE: Hue Brightness feedback - by FatMax - 30.11.2018, 16:36
RE: Hue Brightness feedback - by admin - 30.11.2018, 16:48
RE: Hue Brightness feedback - by FatMax - 01.12.2018, 02:58
RE: Hue Brightness feedback - by admin - 03.12.2018, 07:49
RE: Hue Brightness feedback - by FatMax - 03.12.2018, 07:59
RE: Hue Brightness feedback - by timchan054 - 02.01.2019, 01:13
RE: Hue Brightness feedback - by Daniel - 02.01.2019, 13:05
RE: Hue Brightness feedback - by lenze90 - 24.02.2019, 10:07
RE: Hue Brightness feedback - by Daniel - 25.02.2019, 09:13
RE: Hue Brightness feedback - by Zandkever - 21.08.2019, 09:02
RE: Hue Brightness feedback - by admin - 21.08.2019, 09:22
RE: Hue Brightness feedback - by Zandkever - 21.08.2019, 10:20
RE: Hue Brightness feedback - by Tee_Trinker - 08.05.2020, 22:31
RE: Hue Brightness feedback - by Tee_Trinker - 13.05.2020, 19:47
RE: Hue Brightness feedback - by Firechief - 08.06.2020, 16:16
RE: Hue Brightness feedback - by Firechief - 09.06.2020, 08:24
RE: Hue Brightness feedback - by Ravi Kiran S - 25.03.2021, 10:51
RE: Hue Brightness feedback - by MLa - 30.07.2020, 20:03
RE: Hue Brightness feedback - by MLa - 31.07.2020, 18:05
RE: Hue Brightness feedback - by Sral1987 - 02.08.2020, 17:25
RE: Hue Brightness feedback - by Sral1987 - 09.08.2020, 08:27
RE: Hue Brightness feedback - by Sral1987 - 05.09.2020, 15:48
RE: Hue Brightness feedback - by Sral1987 - 05.09.2020, 16:03
RE: Hue Brightness feedback - by Sral1987 - 01.05.2023, 08:44
RE: Hue Brightness feedback - by Firechief - 08.11.2020, 12:35
RE: Hue Brightness feedback - by admin - 09.11.2020, 08:23
RE: Hue Brightness feedback - by Firechief - 09.11.2020, 15:17
RE: Hue Brightness feedback - by admin - 09.11.2020, 15:45
RE: Hue Brightness feedback - by Firechief - 09.11.2020, 16:24
RE: Hue Brightness feedback - by admin - 09.11.2020, 17:13
RE: Hue Brightness feedback - by Firechief - 09.11.2020, 17:31
RE: Hue Brightness feedback - by admin - 09.11.2020, 17:45
RE: Hue Brightness feedback - by Firechief - 09.11.2020, 18:15
RE: Hue Brightness feedback - by Sral1987 - 27.11.2020, 17:36
RE: Hue Brightness feedback - by admin - 30.11.2020, 07:26
RE: Hue Brightness feedback - by Sral1987 - 30.11.2020, 15:59
RE: Hue Brightness feedback - by Sral1987 - 01.12.2020, 15:21
RE: Hue Brightness feedback - by Karaffe - 21.01.2022, 07:50
RE: Hue Brightness feedback - by Firechief - 25.03.2023, 14:56
RE: Hue Brightness feedback - by admin - 27.03.2023, 05:28
RE: Hue Brightness feedback - by Firechief - 28.03.2023, 07:47
RE: Hue Brightness feedback - by admin - 28.03.2023, 07:58
RE: Hue Brightness feedback - by Firechief - 28.03.2023, 09:31
RE: Hue Brightness feedback - by admin - 28.03.2023, 09:31
RE: Hue Brightness feedback - by Firechief - 28.03.2023, 09:35
RE: Hue Brightness feedback - by admin - 28.03.2023, 09:39
RE: Hue Brightness feedback - by Firechief - 28.03.2023, 09:41
RE: Hue Brightness feedback - by NKereshki - 20.04.2023, 11:32
RE: Hue Brightness feedback - by NKereshki - 20.04.2023, 13:38
RE: Hue Brightness feedback - by NKereshki - 24.04.2023, 06:33

Forum Jump: