PDA

View Full Version : Your home-made LMS API projects



tablemate
2016-09-21, 14:27
Hi,

While my many years ago promised Opera plugin to control LMS went nowhere, I still have lots of fun with SqueezeBox' LMS API.
The openness is probably the reason why I want to stick with SB as long as possible.

Some of my more noticeable home-brew projects have been:

1) A Opera browser (12 Presto and 19-upwards) plugin that shows artwork and title or artist of the currently playing song in a Speed Dial entry. A click opens LMS on the selected player. I have been using this plugin myself for years, but I have not released it on Opera's add-in store, as it will require tons of finishing touches. Password protected servers and mysqueezebox.com are not supported. Of course I am willing to upload it somewhere if someone's interested. As it has not been released on Opera's Add-on store, it requires enabling Opera's Developer mode, that would be a security risk. Also note that as long as Opera is running, it is polling LMS every X seconds (configurable from 5 to 60 seconds), I do not expect WebSocket support is on the LMS roadmap ;) It can be configured to stop polling after X unsuccessful tries however. Again it was mostly made for my personal enjoyment, but if there's interest I'd be willing to work on it.

2) I bought a new Logitech keyboard (at least they still make those ;) ) with neat media keys. Still I hardly play music on my desktop PC, I wanted to control LMS with these keys. Unfortunately Logitech's SetPoint utility's UI does not let me re-assign the Media Keys. With a bit of research I found out that you can edit a XML file manually to add functions to almost any key, including the Media Keys.

I'm a developer, so I created a native Win32 program that simply connects to LMS' TelNet interface (the compiler I used did not have built-in support for JSON, so I chose the TelNet interface) and sends parameter-driven commands to LMS. Now I can rewind, play/pause, forward, mute/unmute and volume up/down with a press of a button. I have been using this for a week now, on a Windows 10 desktop PC, and it seems to work remarkably well. I hope Logitech will not introduce major new versions of SetPoint for a long time ;)

Are there other people that have been playing with the various SqueezeBox-related APIs and created some noticeable home-brew projects that you wouldn't want to miss? :)

mherger
2016-09-21, 14:43
I recently discovered BitBar for OSX/macOS (http://getbitbar.com). This allows you to build menu bar items using your preferred scripting or programming language. I've cobbled together a quick Perl script which gives similar options as the tray icon on Windows:

21136

If I find time I might add some basic player control to it, together with title display in the menu bar, artwork... ok, I probably won't have time for all of this anytime soon, but if somebody was interested, the script is up on github.

If you're just interested in using the script as it is, head over to the BitBar website, install the application (https://getbitbar.com/plugins/Music/check-lms.10s.pl)

rkrug
2016-09-22, 00:55
mherger <mherger.7mf1fb (AT) no-mx (DOT) forums.slimdevices.com> writes:

> I recently discovered BitBar for OSX/macOS (http://getbitbar.com). This
> allows you to build menu bar items using your preferred scripting or
> programming language. I've cobbled together a quick Perl script which
> gives similar options as the tray icon on Windows:
>
> 21136
>
> If I find time I might add some basic player control to it, together
> with title display in the menu bar, artwork... ok, I probably won't have
> time for all of this anytime soon, but if somebody was interested, the
> script is up on github.
>
> If you're just interested in using the script as it is, head over to the
> BitBar website, install the application
> (https://getbitbar.com/plugins/Music/check-lms.10s.pl)
>
>
> +-------------------------------------------------------------------+
> |Filename: Bildschirmfoto 2016-09-19 um 13.57.22.png |
> |Download: http://forums.slimdevices.com/attachment.php?attachmentid=21136|
> +-------------------------------------------------------------------+

That looks really nice - but it would be even nicer, if I could use it
with an LMS server which is running on a different machine. Any chance
of adding this?

Rainer

>
>
> Michael
>
> http://www.herger.net/slim-plugins - MusicArtistInfo, MusicInfoSCR
> ------------------------------------------------------------------------
> mherger's Profile: http://forums.slimdevices.com/member.php?userid=50
> View this thread: http://forums.slimdevices.com/showthread.php?t=106168
>
>

mherger
2016-09-22, 01:07
> That looks really nice - but it would be even nicer, if I could use it
> with an LMS server which is running on a different machine. Any chance
> of adding this?

Ha! It's certainly something I've been thinking about - because I'm not
running my LMS on the Mac. I only implemented this as a POC and to get
an understanding of BitBar. It's a tool I might be using for other
purposes, too.

The problem with the "remote" server case is that it's a much more
complicated case. In the LMS on Mac case we have well defined paths, a
known environment. But with a remote server? How would we find it? How
would we restart a service on a remote Windows or Linux machine? A
BitBar plugin for a remote LMS would not be able to cover the feature
set I've demoed in the existing plugin. But it could of course feature
stuff like "now playing" information, basic player control etc. But
still, server discovery would be a problem, as those plugins are being
run in intervals, they're not kept in memory to eg. listen for LMS
instance discovery messages.

What kind of features would you like to see?

--

Michael

rkrug
2016-09-22, 01:33
Michael Herger <slim (AT) herger (DOT) net> writes:

>> That looks really nice - but it would be even nicer, if I could use it
>> with an LMS server which is running on a different machine. Any chance
>> of adding this?
>
> Ha! It's certainly something I've been thinking about - because I'm
> not running my LMS on the Mac. I only implemented this as a POC and to
> get an understanding of BitBar. It's a tool I might be using for other
> purposes, too.
>
> The problem with the "remote" server case is that it's a much more
> complicated case. In the LMS on Mac case we have well defined paths, a
> known environment. But with a remote server? How would we find it? How
> would we restart a service on a remote Windows or Linux machine? A
> BitBar plugin for a remote LMS would not be able to cover the feature
> set I've demoed in the existing plugin. But it could of course feature
> stuff like "now playing" information, basic player control etc. But
> still, server discovery would be a problem, as those plugins are being
> run in intervals, they're not kept in memory to eg. listen for LMS
> instance discovery messages.
>
> What kind of features would you like to see?

I see the problems, but other plugins for BitBar are using settings you
have to set in the plugin - other option would be a config file, in
which these are defined. I don't think an automatic recovery would be
necessary - it could be added later.

Restarting of LMS: the same. A command could be configured in a config
file, I use for LMS on a Linux box e.g.:

,----
| ssh root (AT) 192 (DOT) 168.1.100 'service logitechmediaserver restart'
`----

and have enabled password-less login - so I can restart LMS without
having to issue a password from my Mac. I have *no* idea about Windows.

There should probably be two plugins:

1) for server control and which can start the player control and
settings via the LMS web interface. Now Playing for all connected
players could be a nice feature as well.

2) player control / remote. As I am controlling my players via iPeng
(even when I am on the computer - I really like the iPeng interface) I
am not so much in need of a BitBar plugin for this.

Rainer

--
Rainer M. Krug
email: Rainer<at>krugs<dot>de
PGP: 0x0F52F982

epoch1970
2016-09-27, 02:33
Not that I really care about Bitbar or the like, but I'd like to point we have a great power management plugin thanks to gharris999.
It can do this, among a great many other things (characters unescaped for readability):
$ nc montreux.local 9090
srvrpowerctrl screstart
srvrpowerctrl screstart screstart in 15 seconds.

srvrpowerctrl reboot
srvrpowerctrl reboot reboot in 15 seconds.
"screstart" restarts the LMS service.
"reboot" restarts the whole machine if you've configured the plugin to fit your machine's specifics.

I think that's way more portable than remote command execution.

rkrug
2016-09-27, 02:46
epoch1970 <epoch1970.7mp7mn (AT) no-mx (DOT) forums.slimdevices.com> writes:

> Not that I really care about Bitbar or the like, but I'd like to point
> we have a great power management plugin thanks to gharris999.

You are referring to https://github.com/gharris999/SrvrPowerCtrl this
one?

> It can do this, among a great many other things (characters unescaped
> for readability):
> Code:
> --------------------
> $ nc montreux.local 9090
> srvrpowerctrl screstart
> srvrpowerctrl screstart screstart in 15 seconds.
>
> srvrpowerctrl reboot
> srvrpowerctrl reboot reboot in 15 seconds.
> --------------------
>
> "screstart" restarts the LMS service.
> "reboot" restarts the whole machine if you've configured the plugin to
> fit your machine's specifics.
>
> I think that way's more portable than some remote command execution.

agreed.

How can I install this plugin?

Rainer

>
>
>
> 3 SB 3 Libratone Loop, Zipp Mini iPeng (iPhone + iPad) LMS 7.9
> (linux) with plugins: CD Player, WaveInput, Triode's BBC iPlayer by bpa
> IRBlaster by Gwendesign (Felix) Server Power Control by Gordon
> Harris Smart Mix, Music Walk With Me, What Was That Tune? by Michael
> Herger PowerSave by Jason Holtzapple Song Info, Song Lyrics by
> Erland Isaksson AirPlay Bridge by philippe_44 WeatherTime by Martin
> Rehfeld Auto Dim Display, SaverSwitcher, ContextMenu by Peter Watkins.
> ------------------------------------------------------------------------
> epoch1970's Profile: http://forums.slimdevices.com/member.php?userid=16711
> View this thread: http://forums.slimdevices.com/showthread.php?t=106168
>
>

epoch1970
2016-09-27, 10:10
ServerPowerControl has a thread (http://forums.slimdevices.com/showthread.php?48521-Announce-Beta-version-of-SvrPowerControl) in the 1/3-party software subforum.

Since GoogleCode has gone dark the repository is no longer available. You have to download manually the plugin.
Then, last time I've tried installing the plugin I've found a bug in a post-install script that could damage the /etc/sudoers file format. I don't know if the bug is still there but I suspect it is.
For all these reasons, I would recommend reading post #1, then *read posts on pages 213 down* (to 216, as of now...)

Installing is not complicated, even today. Simply I advise a bit of caution during post-install. With that, I think you'll find SPC runs great.

rkrug
2016-09-28, 00:50
epoch1970 <epoch1970.7mpstz (AT) no-mx (DOT) forums.slimdevices.com> writes:

> ServerPowerControl has 'a thread'
> (http://forums.slimdevices.com/showthread.php?48521-Announce-Beta-version-of-SvrPowerControl)
> in the 1/3-party software subforum.
>
> Since GoogleCode has gone dark the repository is no longer available.
> You have to download manually the plugin.
> Then, last time I've tried installing the plugin I've found a bug in a
> post-install script that could damage the /etc/sudoers file format. I
> don't know if the bug is still there but I suspect it is.
> For all these reasons, I would recommend reading post #1, then *read
> posts on pages 213 down* (to 216, as of now...)
>
> Installing is not complicated, even today. Simply I advise a bit of
> caution during post-install. With that, I think you'll find SPC runs
> great.

Thanks - I might look into it.

But can't these forums use threads for what they are supposed to be:
Discussing one question and not one plugin?

Rainer

>
>
>
> 3 SB 3 Libratone Loop, Zipp Mini iPeng (iPhone + iPad) LMS 7.9
> (linux) with plugins: CD Player, WaveInput, Triode's BBC iPlayer by bpa
> IRBlaster by Gwendesign (Felix) Server Power Control by Gordon
> Harris Smart Mix, Music Walk With Me, What Was That Tune? by Michael
> Herger PowerSave by Jason Holtzapple Song Info, Song Lyrics by
> Erland Isaksson AirPlay Bridge by philippe_44 WeatherTime by Martin
> Rehfeld Auto Dim Display, SaverSwitcher, ContextMenu by Peter Watkins.
> ------------------------------------------------------------------------
> epoch1970's Profile: http://forums.slimdevices.com/member.php?userid=16711
> View this thread: http://forums.slimdevices.com/showthread.php?t=106168
>
>

Errik128
2016-11-02, 03:33
Hello! Can You make a plugin for browser or android widget that will display the volume level of the player?
I can control vol level by Tasker, but icant see it... (((

pippin
2016-11-02, 03:55
Aren't there several Apps which do that?
I don't know how tasked works but to get the volume you should use the CLI, preferably through JSON/RPC. Details are in the developer section of the forum.

Errik128
2016-11-02, 05:00
I need a widget right on the phone desktop or value% in the notification panel, or on the lockscreen.
I know about the CLI, use it for play/pause just from shortcut, volume control by hardware phones buttons, but did not find how to get the value of volume((
21397

pippin
2016-11-02, 18:59
<playerid> volume ?
Gives you the volume, it's all in the CLI documentation.

OrangeSqueeze and SqueezeCtrl do provide widgets.

sander
2016-11-05, 11:53
I have been playing with Home Assistant https://home-assistant.io/ which has a Squeezebox component available https://home-assistant.io/components/media_player.squeezebox/ . According to the entry for this device in my current set up it has "supported_media_commands: 959" so I'm assuming it can do a lot, but to be honest I haven't figured out how to do much more than get it to talk to the server and report on the devices.

This in conjunction with Harmony Hub http://www.logitech.com/en-us/product/harmony-hub and the api https://github.com/maddox/harmony-api , should allow for some easy near term projects, mainly the ability to put my touch/receiver to sleep after a period of inactivity if there's nothing playing. I use the Powersave plugin which works on ip3k devices, but there was no solution for squeezeplay devices until now. It may be cosmetic (I've never measured the power on those devices), but I like it.

Another near term project is to get a button on the harmony hub smart remote to play a specific favorite. The harmony settings have a button for squeezebox presets, but apparently setting presets on the touch is a little tricky http://forums.slimdevices.com/showthread.php?78416-Setting-presets-on-the-Touch , I also have had problems with presets and dynamic playlists in the past.

Beyond that I have some other plans if I can figure it out to do more with home assistant. One would be to turn off all the Squeezebox screens (blank screensaver or dim to 0) if no one is home to hopefully extend their life. Another would be to disable the current morning alarm if I get up early and turn on another squeezebox, then re-enable it for tomorrow once the alarm time has past, currently I have to do this manually and sometimes forget to re-enable the alarm clock. Another would be to disable the alarm clock automatically on holidays.

If I make any progress of interest I will report back.

Errik128
2016-11-07, 13:49
<playerid> volume ?
Gives you the volume, it's all in the CLI documentation.
Yes, it works through the MobileTelnet. But how to do it in Tasker?

pippin
2016-11-07, 13:51
No idea :) isn't there a talker forum?
BTW: you can use the CLI through JSON/RPC, too, have a look at the developer forum section