Hi Everyone,
I have been having issues trying to get volume working on a plugin it works in a scene and it will not work in the plugin. I believe is has something to do with the delay or end.
local socket = require(“socket”) --I call for this in the plugin
host = “192.168.2.88” – All other commands work
c = assert(socket.connect(host, 10006)) - Call for the port in the plugin
local c:settimeout(5)sres, serr = c:send(string.char(0x02,0x00,0x01,0x04,0x57,0x5E))-- testing
print(“Send:”, sres, serr)
local data, rerr = c:receive(300)
luup.log (data)
print (“Receive:”, data, rerr)
local sres, serr = c:send(string.char(0x02,0x01,0x01,0x15,0xF6,0x0F))–
print(“Send:”, sres, serr)
local data, rerr = c:receive(300)
luup.log (data)
print (“Receive:”, data, rerr)
local sres, serr = c:send(string.char(0x02,0x00,0x01,0x04,0x57,0x5E))-- testing
print(“Send:”, sres, serr)
local data, rerr = c:receive(300)
luup.log (data)
print (“Receive:”, data, rerr)
local sres, serr = c:send(string.char(0x02,0x01,0x01,0x15,0xF6,0x0F))–
print(“Send:”, sres, serr)
local data, rerr = c:receive(300)
luup.log (data)
print (“Receive:”, data, rerr)
c:close()
The above works with the scene and changes volume…To change volume I need to turn the zone on first, then volume then zone on and volume again. That sets the volume right as required.
local hexVol = math.ceil(tonumber(string.format('%02X',lul_settings.DesiredVolume), 16) / 2) -- IF DESIRED VOLUME IS 10 WHAT WOULD THE HEXVOL WORK OUT TO?
local chksums99 = 0x02 + 0x00 + KeyString + 0x04 + 0x57
local chksums66 = 0x02 + 0x01 + KeyString + 0x15 + vol88
-- Send command
cmdString = { 0x02, 0x00, KeyString, 0x04, 0x57, chksums99 }
sendCommand(makeCommand(cmdString))
cmdString = { 0x02, 0x01, 0X01, 0x15, 0xC9, 0XE2 }
sendCommand(makeCommand(cmdString))
cmdString = { 0x02, 0x00, KeyString, 0x04, 0x57, chksums99 }
sendCommand(makeCommand(cmdString))
cmdString = { 0x02, 0x01, 0X01, 0x15, 0xC9, 0XE2 }
sendCommand(makeCommand(cmdString))
This unit works where you must send an on command first then the hex volume code. It must be repeated twice to work in the scene so i completed it twice in the plugin.
Thanks