Status of first row color added to MQTT
This commit is contained in:
parent
5b96bcc7bb
commit
f79195e9a5
@ -41,6 +41,7 @@ Optinal:
|
|||||||
### Status
|
### Status
|
||||||
* **basetopic**/brightness **Current brightness in percent**
|
* **basetopic**/brightness **Current brightness in percent**
|
||||||
* **basetopic**/background **Current background color**
|
* **basetopic**/background **Current background color**
|
||||||
|
* **basetopic**/row1 **Current background color**
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
* **basetopic**/cmd/single
|
* **basetopic**/cmd/single
|
||||||
@ -51,6 +52,8 @@ Optinal:
|
|||||||
* 0-255,0-255,0-255 **Background color is set to decimal representation of red, green an blue**
|
* 0-255,0-255,0-255 **Background color is set to decimal representation of red, green an blue**
|
||||||
* **basetopic**/cmd/telnet
|
* **basetopic**/cmd/telnet
|
||||||
* ignored **Stop MQTT server and start telnetserver at port 23**
|
* ignored **Stop MQTT server and start telnetserver at port 23**
|
||||||
|
* **basetopic**/cmd/row1
|
||||||
|
* 0-255,0-255,0-255 **Background color is set to decimal representation of red, green an blue**
|
||||||
|
|
||||||
## OpenHAB2
|
## OpenHAB2
|
||||||
Tested MQTT with binding-mqtt 2.5.x
|
Tested MQTT with binding-mqtt 2.5.x
|
||||||
|
8
mqtt.lua
8
mqtt.lua
@ -37,7 +37,10 @@ function handleSingleCommand(client, topic, data)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function parseBgColor(data)
|
-- Parse MQTT data and extract color
|
||||||
|
-- @param data MQTT information
|
||||||
|
-- @param row string of the row e.g. "row1" used to publish current state
|
||||||
|
function parseBgColor(data, row)
|
||||||
local red=nil
|
local red=nil
|
||||||
local green=nil
|
local green=nil
|
||||||
local blue=nil
|
local blue=nil
|
||||||
@ -49,6 +52,7 @@ function parseBgColor(data)
|
|||||||
red, green, blue = string.match(data, "(%d+),(%d+),(%d+)")
|
red, green, blue = string.match(data, "(%d+),(%d+),(%d+)")
|
||||||
end
|
end
|
||||||
if ((red ~= nil) and (green ~= nil) and (blue ~= nil) ) then
|
if ((red ~= nil) and (green ~= nil) and (blue ~= nil) ) then
|
||||||
|
m:publish(mqttPrefix .. "/"..row, tostring(red) .. "," .. tostring(green) .. "," .. tostring(blue), 0, 0)
|
||||||
return string.char(green * briPercent / 100, red * briPercent / 100, blue * briPercent / 100)
|
return string.char(green * briPercent / 100, red * briPercent / 100, blue * briPercent / 100)
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
@ -77,7 +81,7 @@ function registerMqtt()
|
|||||||
mydofile("telnet")
|
mydofile("telnet")
|
||||||
startTelnetServer()
|
startTelnetServer()
|
||||||
elseif (string.match(topic, "row1$")) then
|
elseif (string.match(topic, "row1$")) then
|
||||||
row1bgColor = parseBgColor(data)
|
row1bgColor = parseBgColor(data, "row1")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user