Logitech Media Server
Moderators: leecollings, remb0
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
No, there's no rebooting done in my code. The sections you highlighted are related to checking if a player is disconnected before wasting time talking to it, and to saving it's current 'state' so that after playing an alert we can return to normal.
What exactly are you trying to achieve? Maybe I can suggest an overall solution rather than helping to get a sub-optimal solution to work.
Remember that the Domoticz UI in a web browser communicates with the Domoticz server via your network (http). If you open Domoticz in a web browser and select 'developer tools' or its equivalent, you can see what is sent from your browser back to the Domoticz engine when you click on something. Using MS Edge as the browser for example, you can get to developer tools by pressing CTRL-U or F12. Go to the 'network' tab in the pane that now splits your screen. If you now click on a Domoticz UI button you will see here what underlying URL is associated with the command that is actually sent onwards to Domoticz by that click.
If you do this with a Squeezebox player icon, you will see that the following is actually sent to the Domoticz engine when you power a player on, for example:
http://192.168.1.10:8080/json.htm?type= ... &passcode=
So you can see that, to Domoticz, an SB player is just a switch that can be turned on or off. Using this 'take a look under the hood' from the browser method, you can often figure out how to do things in Domoticz that are not normally documented.
What exactly are you trying to achieve? Maybe I can suggest an overall solution rather than helping to get a sub-optimal solution to work.
Remember that the Domoticz UI in a web browser communicates with the Domoticz server via your network (http). If you open Domoticz in a web browser and select 'developer tools' or its equivalent, you can see what is sent from your browser back to the Domoticz engine when you click on something. Using MS Edge as the browser for example, you can get to developer tools by pressing CTRL-U or F12. Go to the 'network' tab in the pane that now splits your screen. If you now click on a Domoticz UI button you will see here what underlying URL is associated with the command that is actually sent onwards to Domoticz by that click.
If you do this with a Squeezebox player icon, you will see that the following is actually sent to the Domoticz engine when you power a player on, for example:
http://192.168.1.10:8080/json.htm?type= ... &passcode=
So you can see that, to Domoticz, an SB player is just a switch that can be turned on or off. Using this 'take a look under the hood' from the browser method, you can often figure out how to do things in Domoticz that are not normally documented.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: Logitech Media Server
Hmm, so it looks like you are looking for a way to really switch the power off and back on again ("reboot") to solve a disconnecting issue? In that case, there is not any approach to call the RPC or http api as the device is "disconnected" and thus offline. So you need something else, most probably a remote controllable wall plug (Z-Wave, KaKu [433Mhz], Xiaomi, Sonoff [WiFi] etc, whatever hardware you might have for controlling them) that you will then just turn off and back on again in hopes of getting the device online again.
Last edited by Nautilus on Tuesday 02 January 2018 23:11, edited 1 time in total.
- havnegata
- Posts: 114
- Joined: Wednesday 10 September 2014 11:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.10162
- Location: Norway
- Contact:
Re: Logitech Media Server
Thanks @Philchillbill and @Nautilus! Rebooting the Squeezebox is what I need to do. Will try your solution when I get home
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
What type of SB do you have? On some you can SSH in to the SB which means you could put a script on it that watches (via HTTP) for a signal from Domoticz and auto-reboots if it gets it. My wiki entry on reading out the ambient light sensor in an SB-Radio or Touch demonstrates the principle. If it's one of theose players I can code up a bash script for you to install on the player.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
- havnegata
- Posts: 114
- Joined: Wednesday 10 September 2014 11:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.10162
- Location: Norway
- Contact:
Re: Logitech Media Server
Wow, that would be great! I have a SB-radio
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: Logitech Media Server
Great idea! Although, shouldn't it be that the script would ping e.g. the LMS server and if it does not respond it reboots (or maybe the script can read the player status from the player directly)? Because when it is disconnected I doubt it'll receive any signal from Domoticz.philchillbill wrote: ↑Wednesday 03 January 2018 18:56 ...you could put a script on it that watches (via HTTP) for a signal from Domoticz and auto-reboots if it gets it...
In any case, I'm definitely interested in this as well. For me the problem might be that I don't want to do the reboot outside a specific time window which might make it a bit complicated.
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
Just because Domoticz sees it as disconnected doesn't mean it isn't alive and still able to talk to the network (and therefore able to see a switch-state in Domoticz). You can still use e.g. the web-interface for LMS or iPeng to control the 'Disconnected' player after all so it's not dead, it's just Domoticz is confused. When it's 'disconnected' there's a switch in Domoticz that's not 'On' or 'Off' but 'Disconnected' and I can check for this. The time-window is not an issue - I'll make sure to include it. Now I'm off to code this up ...
Last edited by philchillbill on Friday 05 January 2018 13:12, edited 1 time in total.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Logitech Media Server
OK, I have a working script that installs and runs on the SB itself and looks outward at Domoticz periodically to see if Domoticz thinks it’s disconnected (even though it's not in reality and is still reachable through any control mechanism outside Domoticz). Copy the below script to a file called sbreboot.sh and used the instructions in the wiki entry on how to read out the ambient light sensor in the SB Radio to install this scriot and get it to auto-run upon booting of the Squeezebox. Don't forget to configure your own IP/port. IDX, friendly-name plus time-window values.
Let me know how it goes for you - I checked it here and it works fine so any issues you may have are likely going to be configuration-related.
By the way, that script above may not be needed. I've noticed that if a player is 'genuinely' disconnected by being powered off (as opposed to sleep/standby) then sending an OFF command via JSON http://192.168.178.12:8080/json.htm?typ ... tchcmd=Off results in an error:
{
"message" : "Error sending switch command, check device/hardware !",
"status" : "ERROR",
"title" : "SwitchLight"
}
*but* if the player is falsely showing as disconnected and is in reality alive and well, sending that OFF command results in Domoticz seeing the player again (for how long is anybody's guess, but maybe long enough to commence playing something).
{
"status" : "OK",
"title" : "SwitchLight"
}
Code: Select all
#!/bin/sh
# Script to check if a Squeezebox Radio is shown as 'Disconnected' in Domoticz and reboot itself if so.
# The script is installed and run on the squeezebox player itself via ssh. Note curl is not available so wget is used !
# Author: philchillbill, 2018.
DOMO="192.168.178.12:8080" # IP and port of your Domoticz instance
SBNAME="Livingroom" # Name of the squeezebox (to appear in the Domoticz log)
SBIDX=142 # IDX of the squeezebox
# say Hello World to the Domoticz Log after waiting a bit for network to be up
sleep 20
wget -O /dev/null -q "http://"$DOMO"/json.htm?type=command¶m=addlogmessage&message=SB%20"$SBNAME"%20launched%20automatic%20reboot%20upon%20disconnection."
while /bin/true; do
# only perform reset if inside a defined time window (from 7AM to 11PM, for example)
h=`date +%H`
if [ $h -ge 7 ] && [ $h -lt 23 ]
then
wget -O- -q "http://$DOMO/json.htm?type=devices&rid=$SBIDX" | grep "Status" | grep "Disconnected" >/dev/null
if [ $? -eq 0 ] ; then
wget -O /dev/null -q "http://"$DOMO"/json.htm?type=command¶m=addlogmessage&message=SB%20"$SBNAME"%20was%20auto-rebooted."
reboot
fi
fi
# sleep a defined number of seconds before re-checking the status
sleep 60
done
By the way, that script above may not be needed. I've noticed that if a player is 'genuinely' disconnected by being powered off (as opposed to sleep/standby) then sending an OFF command via JSON http://192.168.178.12:8080/json.htm?typ ... tchcmd=Off results in an error:
{
"message" : "Error sending switch command, check device/hardware !",
"status" : "ERROR",
"title" : "SwitchLight"
}
*but* if the player is falsely showing as disconnected and is in reality alive and well, sending that OFF command results in Domoticz seeing the player again (for how long is anybody's guess, but maybe long enough to commence playing something).
{
"status" : "OK",
"title" : "SwitchLight"
}
Last edited by philchillbill on Friday 05 January 2018 13:10, edited 1 time in total.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: Logitech Media Server
Thanks a lot, will definitely look into this. In my case the issue however is a bit different and it really seems the player loses connection to network, I cannot see it in iPeng or any other interface for that matter when this happens. But I can easily modify your example and e.g. change the Domoticz switch status check to generic ping (if that is available in SB radio OS) check or some other command to check whether network is available.
If the fault would be a "confused" Domoticz, shouldn't there be some way to fix the script there so that there would not be "false" disconnects anymore?
If the fault would be a "confused" Domoticz, shouldn't there be some way to fix the script there so that there would not be "false" disconnects anymore?
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
I have random false disconnects here with software-based players like Softsqueeze but never with real Logitech hardware. I doubt that part of Domoticz is receiving any active development anymore to fix issues. Maybe I should learn C++ and dive in. LMS itself is written in perl, which is my favourite language ever
Last edited by philchillbill on Thursday 18 January 2018 16:26, edited 1 time in total.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
Today I updated the wiki entry on LMS with a modified version of the perl script that plays audio-alerts on Squeezeboxes. This version uses a single compound-query to LMS to deduce the current status of the SB player instead of needing 5 separate queries. You also no longer need to supply the idx of the SB's to the script as it determines if a player is disconnected without asking Domoticz. I noticed that if a player stays offline for a long time then Domoticz ignores it after it comes back, so asking Domoticz what players are available to LMS was not reliable. The new script handles it better/faster.
https://www.domoticz.com/wiki/Logitech_ ... ox_Players
https://www.domoticz.com/wiki/Logitech_ ... ox_Players
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
-
- Posts: 4
- Joined: Friday 19 January 2018 22:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logitech Media Server
Hi all,
The last few days I have been playing with the LMS/Domoticz integration. Most of it works perfectly, even the communication with my Philips Streamium audio player.
There is one thing however, that doesn't work: playing a playlist using a Lua script. I use this line to play the playlist:
commandArray['Philips MCi730']='Play Playlist Trance'
A similar command for Volume, On, stop, Play, etc, works perfect. But with the playlist command, the Domoticz log says:
2018-01-27 11:19:24.601 Error: Logitech Media Server: Playlist 'Trance' not found.
I configured the Playlists to be stored in /media (via Basic settings)
And when I check, the playlist is really there:
pi@raspberrypi:/media$ ls -l Tra*
-rw-r--r-- 1 squeezeboxserver nogroup 271 Jan 27 11:32 Trance.m3u
I also tried other options like:
commandArray['Philips MCi730']='Play Playlist Trance.m3u'
commandArray['Philips MCi730']='Play Playlist /media/Trance'
commandArray['Philips MCi730']='Play Playlist /media/Trance.m3u'
But nothing seems to work.
Playing a playlist via the LMS gui works fine.
What am I doing wrong?
Kind regards,
Pieter
The last few days I have been playing with the LMS/Domoticz integration. Most of it works perfectly, even the communication with my Philips Streamium audio player.
There is one thing however, that doesn't work: playing a playlist using a Lua script. I use this line to play the playlist:
commandArray['Philips MCi730']='Play Playlist Trance'
A similar command for Volume, On, stop, Play, etc, works perfect. But with the playlist command, the Domoticz log says:
2018-01-27 11:19:24.601 Error: Logitech Media Server: Playlist 'Trance' not found.
I configured the Playlists to be stored in /media (via Basic settings)
And when I check, the playlist is really there:
pi@raspberrypi:/media$ ls -l Tra*
-rw-r--r-- 1 squeezeboxserver nogroup 271 Jan 27 11:32 Trance.m3u
I also tried other options like:
commandArray['Philips MCi730']='Play Playlist Trance.m3u'
commandArray['Philips MCi730']='Play Playlist /media/Trance'
commandArray['Philips MCi730']='Play Playlist /media/Trance.m3u'
But nothing seems to work.
Playing a playlist via the LMS gui works fine.
What am I doing wrong?
Kind regards,
Pieter
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
Is that /media directory also pointed to in the GUI setup of LMS where you defined your music and playlists directories? If it's a different directory to the one LMS 'knows about' it won't work.
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
-
- Posts: 4
- Joined: Friday 19 January 2018 22:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logitech Media Server
Yes, it is. But never mind, I now use this command in a LUA script and that works fine:philchillbill wrote: ↑Monday 29 January 2018 21:44 Is that /media directory also pointed to in the GUI setup of LMS where you defined your music and playlists directories? If it's a different directory to the one LMS 'knows about' it won't work.
commandArray['OpenURL']='http://192.168.178.136:9000/status.html ... 68.178.158'
-
- Posts: 20
- Joined: Sunday 22 October 2017 19:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logitech Media Server
Hi
Could anybody help in giving me detailed example of HHTP command that could play online radio stream?
I am too dumb for LMS CLI (read French link but something is not clear for me = not working...)
I tried :
http://IP:PORT/status?p0=playlist&p1=play&p2=iplayer://live?hls=http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_one.m3u8&radiovis=fm/ce1/c201/09880&player=MAC
with my own streams too.. fail
Now trying to add:
http://opml.radiotime.com/Tune.ashx?id= ... 39d3ff16c9
Could anybody help with this radio as example (Hotmix Radio 90')?
Thanks et merci.
Could anybody help in giving me detailed example of HHTP command that could play online radio stream?
I am too dumb for LMS CLI (read French link but something is not clear for me = not working...)
I tried :
http://IP:PORT/status?p0=playlist&p1=play&p2=iplayer://live?hls=http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_one.m3u8&radiovis=fm/ce1/c201/09880&player=MAC
with my own streams too.. fail
Now trying to add:
http://opml.radiotime.com/Tune.ashx?id= ... 39d3ff16c9
Could anybody help with this radio as example (Hotmix Radio 90')?
Thanks et merci.
-
- Posts: 229
- Joined: Friday 03 April 2015 20:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Germany (near dutch border)
- Contact:
Re: Logitech Media Server
Here you go:
http://192.168.111.112:9000/index.html? ... %3A6f%3Ad3'
I have 6 players..if you only have one than the following will do:
http://192.168.111.112:9000/index.html? ... rtnerId=16
Success, Hans
http://192.168.111.112:9000/index.html? ... %3A6f%3Ad3'
I have 6 players..if you only have one than the following will do:
http://192.168.111.112:9000/index.html? ... rtnerId=16
Success, Hans
-
- Posts: 20
- Joined: Sunday 22 October 2017 19:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Logitech Media Server
Hans! Great! Thank you , man!
If I need to chage to other Radio Stream , what part of string should I change:
http://IP:9000/index.html?p0=playlist&p ... rtnerId=16
in " " ?
UPDATE: GOT it! Can now change link to any my favorite radio.
Thank you again! Now I have full voice control of radio on squeeze.
If I need to chage to other Radio Stream , what part of string should I change:
http://IP:9000/index.html?p0=playlist&p ... rtnerId=16
in " " ?
UPDATE: GOT it! Can now change link to any my favorite radio.
Thank you again! Now I have full voice control of radio on squeeze.
- capman
- Posts: 153
- Joined: Friday 12 July 2013 20:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: Logitech Media Server
Oke, after some research and searching the net , I have no solution found for my next goal .philchillbill wrote: ↑Thursday 18 January 2018 16:26 Today I updated the wiki entry on LMS with a modified version of the perl script that plays audio-alerts on Squeezeboxes. This version uses a single compound-query to LMS to deduce the current status of the SB player instead of needing 5 separate queries. You also no longer need to supply the idx of the SB's to the script as it determines if a player is disconnected without asking Domoticz. I noticed that if a player stays offline for a long time then Domoticz ignores it after it comes back, so asking Domoticz what players are available to LMS was not reliable. The new script handles it better/faster.
https://www.domoticz.com/wiki/Logitech_ ... ox_Players
I have a logitech mediaserver installed on a pi and some pi players around the house for music.
I have a perl script in domoticz that when someone press the doorbell , the music pauzed , some mp3 file is playing and then
the music resumed playing. That is done for one player in the kitchen only. Domoticz is installed on my NAS , so installing your script is not a solution.
Something to do with 'make' and 'cpan'. Why should I want this ? Because the alert is only playing on one player now. The kitchen . And I wanted it also playing on some other players (bathroom , bedroom , garden , ...) on the same time. Then I thought , maybe when I install your script directly on my pi where my LMS is installed. Follow the wiki , but when a type ./doorbell.pl through ssh , I hear nothing . Also no error message . File is 'chmod -x'. And installed with use 'cpan install JSON::RPC::Client'.
Now i'm out of thoughts how to accomplise this . So maybe , just maybe , when you have the time or interrest to look over the perl script how to do this ?
(Sorry for my bad english writing )
Thanks.
"my" working script for one player.
Code: Select all
#!/usr/bin/perl
# ********************************************************************
# Simple announcement script for SlimServer using the CLI v0.6
#
# Copyright (c) 2003 Felix Mueller (felix.mueller(at)gwendesign.com)
#
# This file might be distributed under the same terms as the
# SlimServer (www.slimdevices.com)
#
# Description:
# Plays a sound and shows a message interupting the current song
# - Store current parameters
# - The sound is appended to the current playlist and played
# - After the duration of the sound the sound is removed
# - Resume playing the current song
# - Restore current parameters
#
# Plattform tested:
# - Linux
#
# Known restrictions:
# - trancoded files (i.e. ogg) will restart at the beginning after
# the announcement
# - a shuffled playlist will be reshuffled
# - does not work with iTunes (maybe works only with real SLIMP3)
#
# History:
# 0.6 - Added parameters for user/password (thanks to Mario Wagner)
# 0.5 - Adapted and tested with SlimServer 5.1.1
# 0.4 - Added command line parameter: --name --server --ip --line1 --line2 --sound
# - Added player selection by name
# 0.3 - Added power and volume persistency
# ********************************************************************
use strict;
use Getopt::Long;
use IO::Socket;
# Parameter defaults overridden by command line
my $szServerIP = "192.168.178.91";
my $iServerCLIPort = 9090;
my $szPlayerName = "Keuken";
my $szLine1 = "Line1 text";
my $szLine2 = "Line2 text";
my $szSound = "/home/pi/music/Cool.mp3"; # path on the machine where announcement.pl runs
my $user = "";
my $passw = "";
# Internal parameters
my $debug = 0; # 0 = off, 1 = on
GetOptions( "server:s" => \$szServerIP,
"port:i" => \$iServerCLIPort,
"name:s" => \$szPlayerName,
"line1:s" => \$szLine1,
"line2:s" => \$szLine2,
"user:s" => \$user,
"passw:s" => \$passw,
"sound:s" => \$szSound);
# Check for a player name
showUsage() if( $szPlayerName eq "");
# Prepare variables
$szPlayerName = encodeChars( $szPlayerName);
$szLine1 = encodeChars( $szLine1);
$szLine2 = encodeChars( $szLine2);
$szSound = encodeChars( $szSound);
# Try to open a connection to the SLIMP3 CLI
my $socket = IO::Socket::INET->new( PeerAddr => $szServerIP,
PeerPort => $iServerCLIPort,
Proto => "tcp",
Type => SOCK_STREAM);
# Check if socket was opened successful
if( !defined( $socket))
{
print "Cannot connect to $szServerIP:$iServerCLIPort\n";
exit;
}
# Login
if ($user ne "")
{
my $login = sendAndReceive("login $user $passw");
print $login;
$debug && print "user: $user, passw: $passw\n";
}
# Get the # of players
my $iNumPlayer = sendAndReceive( "player count ?");
$debug && print "iNumPlayer: $iNumPlayer\n";
# Get the player ip and port from the name
my $szPlayerIPAndPort = "";
for( my $i = 0; $i < $iNumPlayer; $i++)
{
if( $szPlayerName eq sendAndReceive( "player name $i ?"))
{
$szPlayerIPAndPort = sendAndReceive( "player address $i ?");
last;
}
}
$debug && print "szPlayerName: $szPlayerName\n";
# Check if successful
if( $szPlayerIPAndPort eq "")
{
print "Player with name: $szPlayerName could not be found!\n";
close( $socket);
exit;
}
$debug && print "szPlayerIPAndPort: $szPlayerIPAndPort\n";
# Get power status (on, off)
my $iPower = sendAndReceive( "power ?");
$debug && print "iPower: $iPower\n";
# Get shuffle status (on, off)
my $iShuffle = sendAndReceive( "playlist shuffle ?");
$debug && print "iShuffle: $iShuffle\n";
# Turn shuffle off
sendAndReceive( "playlist shuffle 0");
# Get mode (play, stop, pause)
my $iMode = sendAndReceive( "mode ?");
$debug && print "iMode: $iMode\n";
# Get current song
my $iIndex = sendAndReceive( "playlist index ?");
$debug && print "iIndex: $iIndex\n";
# Get path and filename to current song
my $iPath = sendAndReceive( "playlist path $iIndex ?");
$debug && print "iPath: $iPath\n";
# Check the song file type (mp3, ogg, wav)
my $iMP3 = 0;
$iMP3 = 1 if( $iPath =~ m/mp3$/);
$debug && print "iMP3: $iMP3\n";
# Get the current position (in s)
my $iTime = sendAndReceive( "time ?");
$debug && print "iTime: $iTime\n";
# Stop the current song
sendAndReceive( "stop");
# Add the announcement sound file at the end of the playlist
sendAndReceive( "playlist append $szSound");
$debug && print "szSound: $szSound\n";
# Get the number of tracks in the playlist
my $iTracks = sendAndReceive( "playlist tracks ?");
$iTracks -= 1;
$debug && print "iTracks: $iTracks\n";
# Is now -1 if playlist was empty
$iTracks = 0 if( $iTracks < 0);
# Get the volume
my $iVolume = sendAndReceive( "mixer volume ?");
$debug && print "iVolume: $iVolume\n";
# Set a volume for the announcement
sendAndReceive( "mixer volume 60");
# Play the announcement sound
sendAndReceive( "playlist index $iTracks");
# Get the duration of the announcement sound
my $iDuration = sendAndReceive( "playlist duration $iTracks ?");
$debug && print "iDuration: $iDuration\n";
sleep( 1);
# Show the announcement message
sendAndReceive( "display $szLine1 $szLine2 $iDuration");
# Wait until announcement sound has finished
sleep( $iDuration);
# Stop it
sendAndReceive( "stop");
# Mute output
sendAndReceive( "mixer volume 0");
# Remove the announcement sound from the playlist
sendAndReceive( "playlist delete $iTracks");
# Reselect the old song
sendAndReceive( "playlist index $iIndex");
# Set the player in the old mode
if( $iMode eq "stop")
{
sendAndReceive( "stop");
}
elsif( $iMode eq "pause")
{
if( $iMP3 == 1)
{
sendAndReceive( "time $iTime");
sleep( 1);
}
sendAndReceive( "mode pause");
}
elsif( $iMode eq "play")
{
if( $iMP3 == 1)
{
sendAndReceive( "time $iTime");
}
}
# Reinstate the volume
sendAndReceive( "mixer volume $iVolume");
# Reinstate the shuffle mode
sendAndReceive( "playlist shuffle $iShuffle");
# Reinstate the power mode
sendAndReceive( "power $iPower");
close( $socket);
# ---------------------------------------------
sub sendAndReceive
{
my $cmd = shift;
return if( $cmd eq "");
# $cmd = $szPlayerIP . encodeChars( ":") . $iPlayerPort . " " . $cmd;
if( $szPlayerIPAndPort ne "")
{
$cmd = $szPlayerIPAndPort . " " . $cmd;
}
print $socket "$cmd\n";
my $answer = <$socket>;
$answer =~ s/$cmd //i;
$answer =~ s/\n//;
return $answer;
}
# ---------------------------------------------
sub encodeChars
{
my $myChars = $_[0];
my $MetaChars = quotemeta(' ;,/?\|=+)(*&^%$#@!~`:');
$myChars =~ s/([$MetaChars\"\'\x80-\xFF])/"%" . uc( sprintf( "%2.2x", ord($1)))/eg;
return $myChars;
}
# ---------------------------------------------
sub showUsage
{
print "usage: slimp3announcement.pl <parameters>\n";
print "\n";
print "Mandatory parameter:\n";
print "--name=<player name>\ti.e.: \"my slimp3\"\n";
print "\n";
print "Optional parameters:\n";
print "--server=<ip>\t\tdefault: 127.0.0.1\n";
print "--port=<nr>\t\tdefault: 9090\n";
print "--line1=<text>\t\tdefault: \"Line1 text\"\n";
print "--line2=<text>\t\tdefault: \"Line2 text\"\n";
print "--user=<text>\t\tdefault: \"\"\n";
print "--passw=<text>\t\tdefault: \"\"\n";
print "--sound=<soundfile>\tdefault: /music/_Diverses/gotmail19.mp3\n";
exit;
}
Re: Logitech Media Server
New in ihe latest bèta (9014):
Option to delete unused device from the nodelist in the hardware-setup of LMS.
Option to delete unused device from the nodelist in the hardware-setup of LMS.
- philchillbill
- Posts: 396
- Joined: Monday 12 September 2016 13:47
- Target OS: Linux
- Domoticz version: beta
- Location: Eindhoven. NL
- Contact:
Re: Logitech Media Server
The script does not have to be on the server where Domoticz is installed, nor even where your LMS is installed. The RPC calls work across your local network from any machine to any machine(s), so it will work on any machine where you have perl and the 4 CPAN modules in the use-header. HOw are you currently detecting a doorbell push? Is it an RFXcom device or something?
Sorry, but the perl script you listed in not the one I wrote but is a much older one. Why don't you start from my script?
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
Who is online
Users browsing this forum: No registered users and 1 guest