Help Help Help, ProgramMER EXPERT REQUIRED

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

There’s at least two syntax errors here:

c = assert(socket.connect(host, 10006)) - Call for the port in the plugin

should be

c = assert(socket.connect(host, 10006)) -- Call for the port in the plugin

Whereas for this:

local c:settimeout(5)sres, serr = c:send(string.char(0x02,0x00,0x01,0x04,0x57,0x5E))-- testing

…I have no idea what’s intended.

Hi Akbooer,

Thank you for the prompt reply and support. For some reason the scene works with the syntax errors the code for the plugin will not work. I need to send the hex code to turn the unit on and then the volume. I have tried everything from hard code the hex code to veritable based on the hex code. I think i need to send the hex for on then pause, then send the code to set volume.

Any ideas would be greatly appreciated.