Hey all,
Simple: Can you access Plugin routines/data/preferences in SqueezeOS?
I'm trying to get up to speed on Applet writing - I want to have SuperDateTime on the Touch, simple as that. What I don't want to do is re-write all the downloading and parsing and preference setting that Greg has so masterfully done.
I have glanced through the plugin documentation, and applet documentation, but it's not really clear to me.
Can I access a plugin from a LUA program? Plugin functions? Can LUA call Perl routines like C++ can call Fortran?
What's a good way to access preference data from LUA?
Thanks!
-Dan
Results 1 to 10 of 225
Hybrid View
-
2010-04-24, 10:00 #1Senior Member
- Join Date
- Aug 2007
- Location
- Portland, OR, USA
- Posts
- 218
Wanting to port SuperDateTime to Touch - need help
-
2010-04-24, 13:25 #2
Hey Dan-
I covered some of this in an email I sent you earlier today, but I think LUA-based plugins have their own settings separate than traditional plugins.
Yes, LUA can communicate with Perl plugins. In the basic SuperDateTime LUA applet I referred you to it achieves this to retrieve the current weather conditions that the SDT Perl plugin is keeping track of.
-Greg
-
2010-04-24, 22:57 #3
What does SDT expose in the form of CLI/JSON commands to get the data ?
Which can I trust have a stable interface ? Everything registered with addDispatch ?
If it only expose simple text or image items it would be nice to integrate this with the "Custom Clock" applet so anyone can design their own screen and decide where to position things and combine it with other data supported by Custom Clock.
Also, does it send any notifications with notifyFromArray when some value is changed ? This would make it possible to avoid polling from the applet side.Erland Isaksson (My homepage)
(Developer of many plugins/applets (both free and commercial).
If you like to encourage future presence on this forum and/or third party plugin/applet development, consider purchasing some plugins)
You may also want to try my Android apps Squeeze Display and RSS Photo Show
Interested in the future of music streaming ? ickStream - A world of music at your fingertips.
-
2010-04-24, 23:00 #4
plympton, you can give it a try in a separate applet first and then maybe we could integrate it in Custom Clock as a second step ?
Erland Isaksson (My homepage)
(Developer of many plugins/applets (both free and commercial).
If you like to encourage future presence on this forum and/or third party plugin/applet development, consider purchasing some plugins)
You may also want to try my Android apps Squeeze Display and RSS Photo Show
Interested in the future of music streaming ? ickStream - A world of music at your fingertips.
-
2010-04-24, 23:42 #5Senior Member
- Join Date
- Aug 2007
- Location
- Portland, OR, USA
- Posts
- 218
Can do. I've got an applet reading the data from the JSON interface from SuperDateTime. I'm spending a lot of time getting my head wrapped around LUA & its weirdnesses, as well as the SqueezeOS object model and how it's all put together (praying to the documentation gods isn't working)
Here's an image of my work-in-progress. It's completely hard-coded for my preferences, but it is getting the data from SuperDateTime (though not using the preferences set in the Web UI)
PS: The code is embarrassingly awful, so I won't upload it yet.
-DanLast edited by plympton; 2010-04-25 at 00:46. Reason: Added Screenshot
-
2010-04-25, 07:08 #6
Hi Erland-
I like the sound of this! I had actually tweaked the custom clock applet to retrieve some SDT content but it would definitely make more sense to have you natively support SDT.
SDT supports several CLI/JSON commands that basically return the hashes that SDT uses internally. The hashes evolved over time as the plugin grew and might not be the most elegant, but I wouldn't expect them to change other than possible additions. I can also make a cleaner API-specific hash if need be.
What would you expect to be provided for images? Where/how do I include the image files in the SBS plugin so that applets can access them via some sort of text url?
I'll try to clean up some API documentation on this.
I wasn't aware of notifyFromArray. Can you provide an example or point me in the direction of an existing plugin that makes use of this in a similar fashion?
Thanks
-Greg
-
2010-04-25, 09:13 #7
A url if it's a image handled by SBS it's enough with the part, if it's an image available someone on Internet I need a complete url including host and port, for for example:
/plugins/SuperDateTime/html/images/someimage.png
Or
http://somesite:1234/folder/someimage.png
An image in the folder (inside your plugin dir):
HTML/EN/html/plugins/SuperDateTime/html/images/someimage.png
Is available as url:
http://localhost:9000/plugins/SuperDateTime/html/images/someimage.png
In this case, since it's a SBS url, it's enough if you provide:
/plugins/SuperDateTime/html/images/someimage.png
Honestly, I'm not 100% sure if this is the correct way, but I know it works because I used it in Custom Clock Helper:
You can specify a $client object in the first parameter if you only want to send it to a specific player.Code:my $data = { 'attr1' => 'value1', 'attr1' => 'value2', }; Slim::Control::Request::notifyFromArray(undef,['superdatetime','somethingupdated',$data);
You will also need to add the notification in initPlugin with addDispatch, as this:
The "superdatetime", "somethingupdated" notification about is just an example, you should of course use names that are relevant in your case.Code:Slim::Control::Request::addDispatch(['superdatetime', 'somethingupdated'],[0, 1, 0, undef]);
The notifyFromArray can take any number of parameters, so the above sample with a single data parameter is just an example, in the TrackStat plugin I for example use:
And the corresponding addDispatch call:Code:Slim::Control::Request::notifyFromArray($client, ['trackstat', 'changedstatistic', $url, $track->id, $playCount, $lastPlayed]);
Code:Slim::Control::Request::addDispatch(['trackstat', 'changedstatistic', '_url', '_trackid', '_playcount',' _lastplayed'],[0, 0, 0, undef]);
Erland Isaksson (My homepage)
(Developer of many plugins/applets (both free and commercial).
If you like to encourage future presence on this forum and/or third party plugin/applet development, consider purchasing some plugins)
You may also want to try my Android apps Squeeze Display and RSS Photo Show
Interested in the future of music streaming ? ickStream - A world of music at your fingertips.
-
2010-04-26, 09:00 #8
Integration of SDT with Custom Clock would be AWESOME!

Reply With Quote

