06.07.2017, 19:51 (This post was last modified: 06.07.2017, 19:53 by Erwin van der Zwart.)
Hi Arjen,
As discussed you where using a old version of the HUE feedback. Here is the latest version with fix when using more lamps (the result table existed out of multiple tables).
19.07.2017, 16:02 (This post was last modified: 19.07.2017, 16:02 by Erwin van der Zwart.)
Hi,
Use:
Code:
require('user.hue')
value = event.getvalue()
lamp_id = 1
value=math.floor(value*2.55)
if value == 0 then
body_msg = '{"on":false}'
sendToLight(lamp_id,body_msg)
else
body_msg = '{"on":true,"bri":'..value..'}'
sendToLight(lamp_id,body_msg)
end
require('user.hue')
value = event.getvalue()
lamp_id = 1
value=math.floor(value*2.55)
if value == 0 then
body_msg = '{"on":false}'
sendToLight(lamp_id,body_msg)
else
body_msg = '{"on":true,"bri":'..value..'}'
sendToLight(lamp_id,body_msg)
end
There are some questions about HUE because there are some older libs and samples so here is the latest version to avoid all kind of questions:
BR,
Erwin
Good afternoon,
I have an application with enough Hue's. Everything works fine, but I have a problem with feedbacks ... I'm using v2. Attached image of the error.
Here is the error: Resident scritp21: bad argument # 1 to 'decode' (string expected, got table)
stack traceback:
[C]: in function 'decode'
Can you try the latest version, it has some minor improvemments including the fix for this issue when feedback exceeds 1000 chars.
BR,
Erwin
Hello
I am using the latest version. And it works perfect. The only issue I can't figure out, is that it is filling up my LOG.
I have qouted all script part with -- log(something) but the script fill up my log with
*string: hue = 40712
*string: colormode = xy
*string: bri = 136
etc..
seems to come from all lamps defined in script..
I can not find any referende in script, why this is logged.. Does something in require log to the log file?
Like require('json')
socket.http or ltn12?
Or is it some other LUA code that also write into log-file? like sink, respone or similar?
I really cant find it (i quoted absolutely all log()) and still the meassages fill up?
Try restarting the script, there is a “do while” in the feedback script so changing anything without restarting it won’t be loaded until a restart of the script.
(13.08.2018, 21:34)Erwin van der Zwart Wrote: Try restarting the script, there is a “do while” in the feedback script so changing anything without restarting it won’t be loaded until a restart of the script.
Thanks! That solved the issue..
It almost made me go crazy!
I assumed it restarted, when i edited script and saved it.. but that do while-forever loop, probably got stuck?
Your the Best!
14.08.2018, 06:45 (This post was last modified: 14.08.2018, 07:05 by Erwin van der Zwart.)
Hi,
No it doesn’t get stuck, it’s just the logical behavior of a script when you use a ‘do while’, as long as the conditions are valid it will keep doing what it’s been told, if you change the script in the background it doesn’t load that until the next time it should restart, or forced by a manual restart.
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.