01.11.2015, 18:32
(This post was last modified: 01.11.2015, 22:46 by Erwin van der Zwart.)
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)
tcpettimeout(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"
tcpend(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
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)
tcpettimeout(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"
tcpend(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