Direct buttons for PiCore Player

I’m using PiCore Player and Logitech Media Server to control music. Is there a way to make a button hyperlinked, but not actually open the link? I want to have a button for each of these:

http://172.16.0.241:9000/status.html?p0=pause
http://172.16.0.241:9000/status.html?p0=play
http://172.16.0.241:9000/status.html?p0=mixer&p1=volume&p2=%2B8 VOL UP
http://172.16.0.241:9000/status.html?p0=mixer&p1=volume&p2=-08 VOL DOWN
http://172.16.0.241:9000/status.html?p0=stop

When added as links, the dashboard tries to open them. I would like them to just be action buttons; is that possible?

@sharptools501, you can use the REST API syntax described in the post below in the Hyperlink tile to send the GET request to your PiCore server without opening the link.

For example: (please note that the URL is wrapped within the double quote ", not the and that the community s/w decides to display.:stuck_out_tongue_winking_eye:)

$.get(“http://172.16.0.241:9000/status.html?p0=pause”)

–EDIT–
This wouldn’t work in this specific scenario because it REST API syntax requires HTTPS since most browsers will throw mixed-content warning if sending request to an insecure endpoint.

@James does this look right? I get an HTTP Get failed! message when I try to use the tile

Found this in the console:

VM117:1 Mixed Content: The page at 'https://sharptools.io/dashboard/view/...' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://172.16.0.241:9000/status.html?p0=play'. This request has been blocked; the content must be served over HTTPS.

Oops, I overlooked the endpoints are not https, so this approach wouldn’t work because the most browsers wouldn’t allow the mixed-content requests :expressionless:

So adding SSL on to your PiCorePlayer service would be required for this to work.

I’ve opened up a thread at Tiny Core Linux. Will post any updates here.

Which smart home platform are you using? You may be able to use a Virtual HTTP Switch or something similar. These can make the HTTP request from the hub on your LAN, so they’ll work with the existing HTTP that your PiCore device offers.

For SmartThings, it looks like the Virtual HTTP Button (Switch) is an option.

With Hubitat, you could either use an HTTP Switch or even trigger a Rule Machine rule directly (which itself would have the HTTP action).

1 Like

I’m using SmartThings. I’ve tried the switch but it seems a bit outdated;

Have you tried with a leading slash for the path?

The logs in your linked thread show:

path is: status.html?p0=play

But the description for the configuration for that property says ‘include the forward slash’:

input("DevicePathOn", "string", title:"URL Path", description: "Rest of the URL, include forward slash.", displayDuringSetup: true)

From a quick review of the SmartThings developer docs for HubAction, it looks like the leading slash is needed for the path, so I assume that’s what the developer of this device handler meant.

Parameter Description
path Allowed values are any string of the form /somepath. Default value is /.

Great catch @josh but no cigar;

af0e4bba-89f4-49de-bd7b-edeb69ce5ce5 1:22:18 PM: debug Event data successfully posted to SharpTools.io
af0e4bba-89f4-49de-bd7b-edeb69ce5ce5 1:22:18 PM: debug Event data successfully posted to SharpTools.io
af0e4bba-89f4-49de-bd7b-edeb69ce5ce5 1:22:17 PM: debug updateDevice, params: [appId:af0e4bba-89f4-49de-bd7b-edeb69ce5ce5, param1:devices, param2:204068d2-6a32-4b62-a145-aeb59f7a699d, action:[GET:executeSmartAppGet, POST:executeSmartAppPost, PUT:executeSmartAppPut, DELETE:executeSmartAppDelete, OPTIONS:executeSmartAppOptions], controller:smartAppApi, id:204068d2-6a32-4b62-a145-aeb59f7a699d], request: [arguments:null, command:on]
204068d2-6a32-4b62-a145-aeb59f7a699d 1:22:18 PM: debug GET /status.html?p0=play HTTP/1.1
Accept: */*
User-Agent: Linux UPnP/1.0 SmartThings
HOST: 172.16.0.241:9000
Content-Type: application/x-www-form-urlencoded

204068d2-6a32-4b62-a145-aeb59f7a699d 1:22:18 PM: debug The method is GET
204068d2-6a32-4b62-a145-aeb59f7a699d 1:22:18 PM: debug The Header is [HOST:172.16.0.241:9000, Content-Type:application/x-www-form-urlencoded]
204068d2-6a32-4b62-a145-aeb59f7a699d 1:22:18 PM: debug path is: /status.html?p0=play
204068d2-6a32-4b62-a145-aeb59f7a699d 1:22:18 PM: debug The device id configured is: PICORE-1-PLAY
204068d2-6a32-4b62-a145-aeb59f7a699d 1:22:18 PM: debug ---Sending command--- /status.html?p0=play

Just to preface this, I don’t actually use this particular DTH, so I’m just basing suggestions off of common issues I’ve seen elsewhere. :slight_smile:

Have you tried those URLs directly in your browser and do they work as expected?

http://172.16.0.241:9000/status.html?p0=pause

If the device was manually created in the IDE, did you make sure to assign it to your Location/Hub?

image

Is there any logging or diagnostic tools available on the PiCorePlayer (PCP)? Would be helpful to see if the command if coming through and PCP just doesn’t like something about the request. For example, I noted that the code always seems to add a Content-Type header of "application/x-www-form-urlencoded". Some web servers can be really particular about the requests they receive… and it’s pretty uncommon to include a content-type with a GET request.

Hitting the URL’s directly works fine – also works when added as hyperlinks on a Sharptools dashboard, albeit opens a browser tab for each click.

1 Like

Opened a thread over at slimdevices.com

What about the other questions?

Ugh, I missed assigning it to my hub. :man_facepalming: :man_facepalming:

It works now – but as a clunky switch button :smiley:

1 Like

Since this device implements both the Switch capability and the Momentary capability…

While you are editing your dashboard, you can tap the ... in the top-right corner of the tile and select Change Layout and choose the Momentary layout.

That way it will act more like a normal push button (stateless) rather than a switch. :slight_smile:

1 Like

This workaround will suffice for now – ideally I can get SSL working on PiCore.

Added a few more devices for these actions;

I wonder if this DTH would work? It’s one of the only discussions I saw around PiCore Player when I searched the SmartThings community and if I’m reading correctly, the device author seems to have tested it with PiCore Player.

Yeah, raised an issue on the repo: Need clarification on set up · Issue #2 · Mellit7/Smartthings-SqueezeBox-Control · GitHub

Found the complete command list here.

1 Like