Logic Machine Forum
HEOS by Denon - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: HEOS by Denon (/showthread.php?tid=190)



HEOS by Denon - FatMax - 12.01.2016

Has anyone written a script to control the HEOS system?

I have no idea how to write json, but wondering if the SONOS script can be modified for use with HEOS as per this documentation:

http://www.eurostar-ostrava.cz/files/01.2015_HEOS---CLI_PROTOCOL_V01.pdf


RE: HEOS by Denon - admin - 13.01.2016

Telnet is used data exchange, so you need to use LuaSocket for communication. Try this code, change IP variable and see if there's any data in logs. Errors will be logged as well.

Code:
require('json')
require('socket')

IP = '192.168.1.11'
PORT = 1255

sock = socket.tcp()
sock:settimeout(5)
sock:connect(IP, PORT)
sock:send("heos://system/check_account\r\n")

res, err = sock:receive()
if res then
  dec = json.pdecode(res)
  if dec then
    log(dec)
  else
    log(res)
  end
else
  log(err)
end

sock:close()



RE: HEOS by Denon - FatMax - 13.01.2016

Thanks for amazing help! I´ll test this and report back!

EDIT:

Getting error at line15, it´s expecting = near dec...?


RE: HEOS by Denon - admin - 13.01.2016

Chrome issue, remove all leading spaces from this script.
Code:
require('json')
require('socket')

IP = '192.168.1.11'
PORT = 1255

sock = socket.tcp()
sock:settimeout(5)
sock:connect(IP, PORT)
sock:send("heos://system/check_account\r\n")

res, err = sock:receive()
if res then dec = json.pdecode(res)
if dec then log(dec) else log(res) end
else log(err) end

sock:close()



RE: HEOS by Denon - FatMax - 13.01.2016

I´m getting this:

Code:
* table:
[heos]
 * table:
  [result]
   * string: success
  [command]
   * string: system/check_account
  [message]
   * string: signed_out

Which I am guessing is a good thing!

EDIT:

So I put this script in common functions, does that mean it gets triggered every time a resident script gets triggered?

See attachded screenshot.


RE: HEOS by Denon - admin - 14.01.2016

You should never place code that is executed by itself into common functions. Common functions is included in every script and should only contain functions.


RE: HEOS by Denon - FatMax - 14.01.2016

I see, thanks, understand better know!


RE: HEOS by Denon - FatMax - 14.01.2016

I´ve been experimenting a lot with the script above, trying to get the Player ID from the system. I cannot execute anything without that elementary piece of information.

So, someone who actually knows how this works; What´s the next step? I´m getting responses from the system with various commands, I´m just missing what they´re calling payload information...

Anyone up for the challenge?


RE: HEOS by Denon - admin - 15.01.2016

Most probably you have to send auth info first, don't forget about escaping parameters in all commands or they might not work.

Put this after sock.connect and change user/pass variables accordingly:
Code:
url = require('socket.url')
escape = url.escape

user = 'user@gmail.com'
pass = '12345'

cmd = 'heos://system/sign_in?un=' .. escape(user) .. '&pw=' .. escape(pass) .. '\r\n'
sock:send(cmd)



RE: HEOS by Denon - FatMax - 15.01.2016

It´s pretty strange, even though I get success in the log when sending the auth, by sending a check account shortly after it says I´m signed out.

I think I´ll have to try this with a computer on the network itself, after all, all I need is the damn player id to be able to control volume up and down and play/pause, which is the only thing I´ll be using it for initially.

Thank you for the tremendous support, I´ve never experienced anything like it really.


RE: HEOS by Denon - FatMax - 19.01.2016

I´ve had someone over in the house to locally telnet directly into the heos and that finally gave me the PID i was looking for. The payload seems to be missing from the responses run through the scripts here.

Changing volume and muting seems to be working just fine now, thanks for all your help!