HI Everyone,
I really need some help, I receive this hex string and have tried everything to process it on my plugin
02 00 00 10 DF E0 C6 C8 D2 C7 CB DC DE CF DA CB F1
02 is the header, 00 reserve, 00 normally zone but not for this command, 10 is the command for volume, DF is the volume for zone 1 and that carries like E0=Z2, C6=Z3 and etc.
How do i receive this? I have tried the following,
local data = string.format(‘%02X’, string.byte(lul_data))
-- Build full hex strings
if (data == HTD_cmd_start) then
bufferString = buffer .. " " .. data
luup.log("Received full buffer from controller via serial " .. bufferString)
elseif (data == HTD_cmd_start) then
buffer = data
else
buffer = buffer .. " " .. data
end
-- Generate array from buffer
if (bufferString ~= nil) then
Array = {}
local x = 1
for i in string.gmatch(bufferString, "%S+") do
Array[x] = i
x = x + 1
end
end
-- Parse hex strings
if (#Array == 3) then
if (Array[3] == "10") then
-- Convert to decimal, range 0..100, and return volume status
value = tonumber(Array[4], 16) * 2
zonedev = zone_ID[tonumber(Array[3]) + 1]
luup.variable_set("urn:micasaverde-com:serviceId:Volume1", "Volume", value, zonedev)
luup.variable_set("urn:micasaverde-com:serviceId:InputSelection1", "DiscreteinputTV", DiscreteinputTV, value)
luup.log("Volume for zone " .. tonumber(Array[1]) + 1 .. " is " .. (value or "Not Available"))
bufferString = ""
end
But it doesn’t work