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.

Squeezebox + KNX
#1
Hi, does someone control their squeezbox (logitech media server) using the Logic Machine? I have found that openHAB does do this... maybe there is a direct way of doing this?
Reply
#2
Hi,

There are 2 ways to control it, or by API or by TCP

For API you can use this sample to send HTTP your commands:

require('socket.http')

socket.http.TIMEOUT = 5
ip_logicmachine = '192.168.0.10'
ip_squeezebox = '192.168.0.110'
pause_command = grp.getvalue('1/1/1')

if pause_command == true then
  pause_command = 1
else
  pause_command = 0
end

r, c, h, s = socket.http.request('http://' .. ip_squeezebox .. ':9000/status.html?p0=pause&p1=' .. pause_command .. '&player=' .. ip_logicmachine .. '')

if not r then
  log('No reply')
  return
else
  log®
  --do other actions with reply if needed
end

On this page are the HTTP / API commands for squeezebox explained:

http://tutoriels.domotique-store.fr/cont...-squeezebox-server-_-player-http.html

For TCP you can use this tcp/ip sample to send tcp/ip commands:

-- TCP/Telnet 

--------------------------------------------------------------------------------    
local host, port = "192.168.2.60", 23
local socket = require("socket")
local tcp = assert(socket.tcp())
tcp:connect(host, port)
tcpConfusedettimeout(0.5)

-- Send command as HEX
--command = string.char(0xfe, 0xff, 0xff,) -- You need to put here your correct HEX command
-- Send command as STRING
command = ''PUT_HERE_YOUR_COMMAND"

tcpConfusedend(command .. '\r')

--Get replies from controller
local s, status, partial = tcp:receive()

--Check if reply has a value
if s then
  -- Decode data from HEX if needed
  --decodeddata = lmcore.hextostr(s, string.len(s))
  --log(decodeddata)
  --Do your action(s) with replies
  if s == 'put here your expected reply' then
    -- Do actions
  end 
end
if status then
-- log(status)
end
if partial then
  -- log(partial)
end
tcp:close()

On this page are the tcp/ip commands for squeezebox explained:

https://crestron-squeeze.googlecode.com/...pi_7.6.htm

Explore those 2 and you can control your device (:

BR,

Erwin van der Zwart
Reply
#3
Thanks Erwin!

here a short function to send commands to your squeezebox players. I have added them to a user library.

Code:
--Functions for Logitech Media Server integration
squeezboxserverip = '192.168.0.XX' -- IP of the Logitech Media Server

function squeezeboxsendcommand(player,command)
 socket=require('socket')
  local client = socket.connect(squeezboxserverip, 9090)
 client:send(player .. ' ' .. command .. '\n')
  local result=client:receive()
  log(result)
  client:close()
end

and this is an example for an object turning on or off the player

Code:
require('user.squeezebox')

onoff = event.getvalue() and 1 or 0

squeezeboxsendcommand('b8:27:eb:ad:6b:c2', 'power ' .. onoff)
Reply


Forum Jump: