Squeezebox actions from script

Hi,
I’m trying to play music via my squeezebox from a script file using the action squeezeboxPlayUrl, but it seems that the command is not considered and nothing is logged; I’m wondering if I need to qualify the entire reference like the other references since no import is allowed, something like:

org.openhab.action.squeezebox.internal.Squeezebox.squeezeboxPlayUrl

Did anyone use these commands from a script?

P.S. the items are updated correctly and via Habdroid I’m able to play and stop music.

Thank you

I’ve used sendHttpGetRequest from within a rule to play a Pandora station. Have not tried squeezeboxPlayURL.

I’m also running the OH2 squeezebox binding. You are running the OH1 version?

OH1 version

Are other squeezebox actions working (mute, volume, play, pause, etc.)?

I’m using also squeezeboxPower with no success.

Unfortunately, I’m not too familiar with OH1, as I’ve only used OH2. Maybe someone who’s familiar with the OH1 squeezebox actions can jump in here.

Hi,

make sure you have the respective action jar in the addon directory; then add the following import to the rule:

import org.openhab.action.squeezebox.*

in the rule the call should look like this:
//…
val String radioStation = "http://stream.srg-ssr.ch/drs4news/mp3_128.m3u"
squeezeboxPlayUrl(“Schlafzimmer”, radioStation, 55)
//…

with kind regards,
Patrik

Thank you. My doubt come from the fact that in a script file the import key is not allowed.

Ok found out, beginner typical mistake :pensive: when I double checked the jar files I noticed the action one was missing, I had forgotten to copy it. Now it works from the script file.
Thank you.

Do you mind sharing the rule you have?
It might be something I will consider in future to play a Pandora station.
thanks Josh

Hi Josh,

please have a look @ the following wiki page; hope it helps:

with kind regards,
Patrik

Yes, I modeled my rules somewhat after what’s in the Wiki.

There is a bit of a trick to get the URL for a Pandora station. I’ve never been able to find the URL anywhere on Logitech Media Server UI. Here’s what I do to get the Pandora URL.

  • Go to the LMS web interface
  • Bring up the list of Pandora “Your Stations”
  • Heart (favorite) a station
  • Go to your list of Favorites
  • Click on the favorite you just created for your Pandora station

The URL will look something like:
pandora://long-string-of-digits.mp3

Use the above to set p2 in the URL you send to the Squeeze Server.

For example:
http://hostname:9000/status.html?p0=playlist&p1=play&p2=pandora%3A%2F%2F72031231602953337.mp3&player=MACaddress

Thanks Guys,
I’ll have to give it a go when I get a chance.
Josh

Hello,
I Installed Squeezebox on OH2 and communication and players are recogized well.
Now I would like to write a rule but I don’t understand where I find the ID of the player or If I wrote something wrong:

Is still necessary create an item file with OH2 or is itegrated on OH2 Ecosystem?

Thank you very much


import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*
import org.openhab.action.squeezebox.*


rule Voice control
when
    Item VoiceCommand received command
then
    var String command = receivedCommand.toString.toLowerCase
	
	if (command.contains("spegni luce") {
		Scena.sendCommand(4)
		squeezeboxSpeak("00:04:20:29:62:10", "Spegni luce")
    }
	if (command.contains("accendi radio") {
		squeezeboxPower("squeezebox_squeezeboxplayer_D758D8B6_0D7F_490E_BCCF_8BB89A4E9938_000420296210", TRUE)
    }
	if (command.contains("spegni radio") {
		squeezeboxPower("squeezebox_squeezeboxplayer_D758D8B6_0D7F_490E_BCCF_8BB89A4E9938_000420296210", FALSE)
    }	

end

The ID player is the one you used in the config file to identify your device.
f.i.

 Id (MAC address) of your first Squeezebox
squeeze:squeezebox1.id=XX:XX:XX:XX:XX:XX
# Id (MAC address) of your nth Squeezebox
#squeeze:<boxIdN>.id=

then you’ll have

squeezeboxPower("squeezebox1", true)