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.

WLED
#2
Example for brightness control.

Attach an event script to 0..100% scale object. Change WLED_IP to your WLED device IP address.

Code:
http = require('socket.http')
json = require('json')
ltn12 = require('ltn12')

url = 'http://WLED_IP/json/state'

value = event.getvalue()

data = json.encode({
  on = value > 0,
  bri = math.round(value * 2.55),
})

res, code = http.request({
  url = url,
  method = 'POST',
  headers = {
    ['content-type']  = 'application/json',
    ['content-length'] = #data,
  },
  source = ltn12.source.string(data),
})

log(res, code)
Reply


Messages In This Thread
WLED - by danborge - 20.05.2024, 20:43
RE: WLED - by admin - 21.05.2024, 07:24
RE: WLED - by Andrea Becagli - 21.05.2024, 11:37
RE: WLED - by danborge - 21.05.2024, 18:05
RE: WLED - by Andrea Becagli - 22.05.2024, 15:31
RE: WLED - by danborge - 22.05.2024, 16:45
RE: WLED - by AlexLV - 27.05.2024, 21:49

Forum Jump: