This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Rudimentary telnet control over Pioneer AVR Receiver
I thought I'd share this work in progress. I am an amateur both in Lua and in KNX... so take with a huge grain of salt. 

All it does is open a socket to a defined IP and Port and send a telnet command... then add an "Enter"... then wait for an answer. It closes right after that, as the Pioneer does not like more than one telnet connection at a time and I don't want to hog the port.

Copy this code into a user library. I called mine user.telnet

--Sends a single telnet command to a host and port
--it returns one line answer
function telnetsend(host, port, command)

 nextline = '\r\n'

 local socket = require("socket")
 local tcp = assert(socket.tcp())
 res, err = tcp:connect(host, port)
 res, err = tcp:send(command .. nextline)
 local answer = tcp:receive('*l')
 return answer

--Sets the volume to a numeric value
--takes into account, that Pioneer increments the volume in
--2 step intervals. Takes a host ip and port as input.
function setvolume(host, port, volumelevel)

 local currentvolume = getvolume(host, port)

 if volumelevel > currentvolume then
   for i = currentvolume, volumelevel -1, 2 do
   for i = volumelevel, currentvolume-1, 2 do
 currentvolume = getvolume(host, port)
 return currentvolume


--Returns the current volume
function getvolume(host, port)
 local currentvolume = tonumber(string.sub(telnetsend(host,port,VOLUME_QUERY), 5))
 return currentvolume

--Turns reciever on off
function soundonoff(host, port, onoff)
 if onoff == true then
   local status = telnetsend(host,port,POWER_QUERY)
   if status == POWER_ONSTATE then
     return true
     alert("Could not turn on sound")
   local status = telnetsend(host,port,POWER_QUERY)
   if status == POWER_OFFSTATE then
     return false
     alert("Could not turn off sound")

and put this code into a separate user.script. I called mine

All it does is define a huge amount of variables with the correct telnet commands for the Pioneer avr 529 I have. Change, reduce as needed. There are most probably errors in the codes, as these where copied and pasted from around the web.

   -- Main zone
   -- Volume
   -- Mute
   MUTE=    "MO"
   UNMUTE=    "MF"

   -- Source / Input channel
   SOURCE_UP=    "FU"
   SOURCE_SET=    "%02dFN"
   SOURCE_DVD=    "04FN"
   SOURCE_BD=    "25FN"
   SOURCE_HMG=    "26FN"
   -- Listening mode
    -- tone control
    -- bass control
    -- treble control
    -- Speaker configuration
    -- HDMI outputs configuration
    -- HDMI audio configuration
    -- PQLS setting
    -- Zone 2 control
    ZONE2_POWER_ON=        "APO"
    ZONE2_INPUT_CD=    "01ZS"
    ZONE2_VOLUME=    "%02ZV",    "ZV"
    ZONE2_MUTE=        "Z2MO"
    ZONE2_UNMUTE=    "Z2MF"
    -- zone 3 control
    ZONE3_POWER_ON=        "BPO"
    ZONE3_INPUT_CD=    "01ZT"
    ZONE3_VOLUME=    "%02YV"
    ZONE3_MUTE=        "Z3MO"
    ZONE3_UNMUTE=    "Z3MF"
    -- radio tuner
    TUNER_BAND=        "TB"
    TUNER_PRESET=    "%01dTP"
    TUNER_CLASS=    "TC"
    -- iPod control
    IPOD_PLAY=            "00IP"
    IPOD_PAUSE=        "01IP"
    IPOD_STOP=            "02IP"
    IPOD_PREVIOS=        "03IP"
    IPOD_NEXT=            "04IP"
    IPOD_REV=            "05IP"
    IPOD_FWD=            "06IP"
    IPOD_REPEAT=        "07IP"
    IPOD_SHUFFLE=        "08IP"
    IPOD_DISPLAY=        "09IP"
    IPOD_CONTROL=        "10IP"
    IPOD_CURSOR_UP=    "13IP"
    IPOD_ENTER=        "17IP"
    IPOD_RETURN=        "18IP"
    IPOD_TOP_MENU=        "19IP"
    IPOD_KEY_OFF=        "KOF"
   -- Home Media Gateway (HMG) control
   HMG_UP=    "26NW"
   -- display info text

Lastly call the above user libraries from a KNX object like the following:


--we write the returned set volume to the status object
grp.write('11/2/2', soundonoff('',8102,event.getvalue()))

The 11/2/2 Object is the status object, that gets written with the return value of soundonoff.

Forum Jump: