Can't get lua to run from PLEG action

In PLEG: My starup Lua Code is

function VOLUME_DOWN()
cmd = 'sendir,1:3,1,38000,1,1,172,172,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,21,22,64,22,21,22,21,22,21,22,21,22,21,22,21,22,64,22,21,22,64,22,64,22,64,22,64,22,1820'
sendir(cmd)
end

function VOLUME_UP()
cmd = 'sendir,1:3,1,38000,1,1,172,172,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,64,22,64,22,1820'
sendir(cmd)
end

function CHANNEL_DOWN()
cmd = 'sendir,1:3,1,38000,1,1,172,172,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,64,22,64,22,64,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,64,22,21,22,21,22,21,22,64,22,64,22,64,22,64,22,21,22,64,22,64,22,64,22,1820'
sendir(cmd)
end

function sendir(commandtosend)
commandtosend = commandtosend .. ',\r'
local socket = require("socket")
c = assert(socket.connect("10.0.0.203", 4998))
c:settimeout(5)
local sres, serr = c:send(commandtosend)
local data, rerr = c:receive(5)
c:close()
end

In my Logic Actions item, I add the following Lua code:

CHANNEL_DOWN()

I save it and run my scene and it doesn’t fire off.

If I take this code and put it in the “test” area of Vera, it works.

What am I doing wrong?

See my post in this section about that very topic. My understanding is that the Action logic expressions can’t access Lua functions or variables. You can from other parts of PLEG, but the {(expression)} syntax only works for PLEG defined objects.