Горячая линия Embedded System Rus:8-800-775-06-34 (звонок по России бесплатный)

LM5_N
LM-Wall_N
DALI_N
Vita_N

Управление лампами Philips Hue из KNX

Задача

Как управлять лампами Philips Hue из KNX?

Событийный скрипт

Добавьте событийный скрипт на групповой адрес KNX с которого мы будем управлять лампами Philips Hue.
Для примера пусть будет 12/0/4

require('socket.http')
body_on = '{"on":true,"sat":255,"bri":255,"hue":6144}'
body_off = '{"on":false}'
response = {}
 
start = grp.getvalue('12/4/0')
 
-- Включить Philips hue лампы 4 и 5
if start==true then
 
	socket.http.request({
	url = "http://192.168.178.21/api/richardmeiland/lights/4/state",
	method = 'PUT',
	sink = ltn12.sink.table(response),
	headers = {
	['content-length'] = #body_on,
	['content-type'] = 'application/json',
	},
	source = ltn12.source.string(body_on),
	})
	log(response)
 
	socket.http.request({
	url = "http://192.168.178.21/api/richardmeiland/lights/5/state",
	method = 'PUT',
	sink = ltn12.sink.table(response),
	headers = {
	['content-length'] = #body_on,
	['content-type'] = 'application/json',
	},
	source = ltn12.source.string(body_on),
	})
	log(response)
end
 
-- Выключить лампы  4 и 5
 
if start==false then
 
	socket.http.request({
	url = "http://192.168.178.21/api/richardmeiland/lights/4/state",
	method = 'PUT',
	sink = ltn12.sink.table(response),
	headers = {
	['content-length'] = #body_off,
	['content-type'] = 'application/json',
	},
	source = ltn12.source.string(body_off),
	})
 
	log(response)
 
	socket.http.request({
	url = "http://192.168.178.21/api/richardmeiland/lights/5/state",
	method = 'PUT',
	sink = ltn12.sink.table(response),
	headers = {
	['content-length'] = #body_off,
	['content-type'] = 'application/json',
	},
	source = ltn12.source.string(body_off),
	})
 
	log(response)
end