Control of the Logitech Media Server using the LogicMachine

I use the Logitech Media Server to stream multi-room audio in our apartment. Lately I wanted to be able to also control the Spotify Plugin from the KNX buttons at home and automate some tasks.

This is a simple user library to allow you to send commands to a player attached to your LMS.

--Functions for Logitech Media Server integration
squeezboxserverip = '' -- IP of the Logitech Media Server

function unescape(space)
return string.gsub(space, ':', '%%3A') -- the telnet server returns : as %3A

function squeezeboxsendcommand(player,command,value)
local client = socket.connect(squeezboxserverip, 9090)
playercommand = player .. ' ' .. command .. ' '
client:send(playercommand .. value .. '\n')
local result=client:receive()
status = string.sub(result, string.len(unescape(playercommand))) --remove the MAC and command to get to the answer

function squeezeboxstatus(player)
local client = socket.connect(squeezboxserverip, 9090)
playercommand = player .. ' status'
client:send(playercommand .. '\n')
local result=client:receive()
status = split(result, ' ')
--status = string.sub(result, string.len(unescape(playercommand))) --remove the MAC and command to get to the answer

to play a Spotify Playlist you need to add this code to a KNX object.

require('user.squeezebox') --get the user library to access LMS

local player = 'b8:27:eb:ad:6b:c3' --set witch player to access

if (event.getvalue() == true) then
squeezeboxsendcommand(player, 'playlist', 'clear') -- reset any playlist
squeezeboxsendcommand(player, 'playlist add', 'spotify:user:1175125342:playlist:7yCDwOnYZTXFTYymXZxp0t') --get this command from the logs of the LMS when playing the Spotify playlist
squeezeboxsendcommand(player, 'playlist shuffle', 1) -- shuffle, if you want
squeezeboxsendcommand(player, 'play', '') -- now play the list
grp.write('11/6/1', 'Playing Spotify')
squeezeboxsendcommand(player, 'playlist', 'clear')
grp.write('11/4/0', false) --turn off player

Raspberry Pi GPIO Audio Amp control with relays using squeezlite

I have had a project in the making for some time. We use a Raspberry Pi with a Squeezeplug image to run Squeezelight on it to do basic audio out in our bathroom. As an amp I use the Dayton DTA-1. The amp has to be manually turned on and off each time we use it. This is subobtimal, as the whole idea behind the Logitech Media Server is to be able to use an app to use it.

While researching I came across the Squeezelite RPI GPIO project. It is a drop in replacement for the squeezelight binary provided by the Squeezeplug guys. To get it to work you need to change the code in a few places.

First log into your Raspberry Pi as root.

Get the latest git version of Squeezelite RPI GPIO:
git clone
cd phermann2-squeezelite-rpi-gpio/

Then edit the Makefile:
nano Makefile

Change the CFlags to this:
notice the -DGPIO, this gives you access to the desired functions.

compile with this command

now make a backup copy of your current squeezelight binary:
cp /opt/squeezelight/squeezelight /opt/squeezelight/squeezelight.original

edit the start script of squeezelight, as we need root rights
nano /etc/init.d/squeezelite
all I did is add a
after the first fi in the file… it overrides everything it detects automatically.

restart the squeezelite service to check if it worked.

You now need to connect pin 18 on the Raspberry PI to the input on your relais.

Relais for a Raspberry Pi Squeezbox Amp control

In my case I got a board for Arduino with 5 Volt relais and 3,3 volt pins. I took an old power cable and spliced it to attach it to the fist relais and added a socket for the power source of the amp.

LogicMachine script to turn on off Epson projector

Today I created a small script in a KNX object to turn my Epson projector on off via a serial link.

-- device on the LogicMachine connected to the Epson projector
-- ttyUSB0 is typical for a USB RS-232C
-- tested with adapter based on FT232 or CP210x chip.
device = '/dev/ttyUSB0'
-- opens a serial port using the sugested values of Epson manual
port =, { baudrate = 9600, parity = 'none', stopbits = 1  })

-- get value of KNX object
value = event.getvalue()

if (value == true) then
 -- send power on command with returns to make them stick
 char = "PWR ON\r\n"  
 -- send power off command
 char = "PWR OFF\r\n"  

Config file to connect VPNC to a FritzBox

In a previous post I briefly described how to get a vpnc binary onto a tplink router. What I missed was to post the configuration file you need on the FritzBox side to get the connection running. Here it is:
* Vpnc to fritzbox config file

vpncfg {
connections {
enabled = yes;
conn_type = conntype_user;
name = "";
always_renew = no;
reject_not_encrypted = no;
dont_filter_netbios = yes;
localip =;
local_virtualip =;
remoteip =;
remote_virtualip =;
remoteid {
key_id = "nameofconnection";
mode = phase1_mode_aggressive;
phase1ss = "all/all/all";
keytype = connkeytype_pre_shared;
key = "yourpasswordhere";
cert_do_server_auth = no;
use_nat_t = yes;
use_xauth = yes;
xauth {
valid = yes;
username = "nameofconnection";
passwd = "yourpasswordhere";
use_cfgmode = yes;
phase2localid {
ipnet {
ipaddr =;
mask =;
phase2remoteid {
ipaddr =;
phase2ss = "esp-all-all/ah-none/comp-all/no-pfs";
accesslist = "permit ip any",
"permit ip any";
ike_forward_rules = "udp",

// EOF