Hi, I hope this is the correct forum section for this.
I’ve recently started developing a volumio plugin, and have a couple of questions that I’ve been unable to answer myself through digging around. I have a development background, though not in really this kind.
Some background on the plugin… it’s intended to allow control of an Onkyo receiver that my volumio raspberry pi is connected to. Rather than having to turn the receiver on through it’s own app or manually, I wanted to create a plugin that does this automatically. I’ve had no problem getting this to work, but I’ve run into some issues with some of the more standard plugin features.
Mar 09 21:38:26 volumiozero volumio[4859]: info: ONKYO-CONTROL: saveConnectionConfig() data: {"autolocate":true,"receiverIP":"","receiverPort":"60128"}
Mar 09 21:38:27 volumiozero volumio[4859]: fs.js:641
Mar 09 21:38:27 volumiozero volumio[4859]: return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
Mar 09 21:38:27 volumiozero volumio[4859]: ^
Mar 09 21:38:27 volumiozero volumio[4859]: Error: ENOENT: no such file or directory, open '/data/configuration/miscellanea/onkyo_control/config.json'
Mar 09 21:38:27 volumiozero volumio[4859]: at Error (native)
Mar 09 21:38:27 volumiozero volumio[4859]: at Object.fs.openSync (fs.js:641:18)
Mar 09 21:38:27 volumiozero volumio[4859]: at Object.fs.writeFileSync (fs.js:1347:33)
Mar 09 21:38:27 volumiozero volumio[4859]: at Object.writeFileSync (/data/plugins/miscellanea/onkyo_control/node_modules/jsonfile/index.js:115:13)
Mar 09 21:38:27 volumiozero volumio[4859]: at Config.save (/data/plugins/miscellanea/onkyo_control/node_modules/v-conf/index.js:209:11)
Mar 09 21:38:27 volumiozero volumio[4859]: at Timeout._onTimeout (/data/plugins/miscellanea/onkyo_control/node_modules/v-conf/index.js:184:18)
Mar 09 21:38:27 volumiozero volumio[4859]: at ontimeout (timers.js:386:14)
Mar 09 21:38:27 volumiozero volumio[4859]: at tryOnTimeout (timers.js:250:5)
Mar 09 21:38:27 volumiozero volumio[4859]: at Timer.listOnTimeout (timers.js:214:5)
Looking at other plugins, I can’t find any reference to this file being created in the code. While I could create it manually, I’d prefer my plugin to be done properly, and while I could create it with the correct permissions in the install.sh file… I get the feeling that this isn’t the correct way this should happen.
How should the file be created? By me somewhere in code? Or automatically, but I’m missing something?
Can toast messages be internationalised? The following code produces a toast, but the text stays the same? Other plugins seem to have these strings hard coded, which means they can’t be internationalised. Is there any existing way to replace these strings so far?
Hi, for the configuration , I don’t see anything wrong. The conf files are created upon installation of plugin.
How did you initialize it?
With the plugin helper?
Adding this seemed to fix the problem and the “/data/configuration/miscellanea/onkyo_control/config.json” is now created fine.
I did create the plugin using the helper with “volumio plugin init”, and I’ve just created another test plugin. It doesn’t look like this method exists in the default template index.js file, though it is mentioned in the docs here: volumio.github.io/docs/Plugin_S … ex.js.html
I’m not sure how the plugin helper creates this default file exactly. Does it just copy from the example_plugin folder in volumio_plugins? It looks like that function is missing from there as well.
I’m not sure if this function is deliberately not there by default, or if it’s a bug though. I could just be misunderstanding, though it does seem that all the plugins that I checked have it. If it helps, the index.js file that I generated with “volumio plugin init” is:
[code]‘use strict’;
var libQ = require(‘kew’);
var fs=require(‘fs-extra’);
var config = new (require(‘v-conf’))();
var exec = require(‘child_process’).exec;
var execSync = require(‘child_process’).execSync;
module.exports = initTest;
function initTest(context) {
var self = this;
initTest.prototype.onVolumioStart = function()
{
var self = this;
var configFile=this.commandRouter.pluginManager.getConfigurationFile(this.context,‘config.json’);
this.config = new (require(‘v-conf’))();
this.config.loadFile(configFile);
return libQ.resolve();
}
initTest.prototype.onStart = function() {
var self = this;
var defer=libQ.defer();
// Once the Plugin has successfull started resolve the promise
defer.resolve();
return defer.promise;
};
initTest.prototype.onStop = function() {
var self = this;
var defer=libQ.defer();
// Once the Plugin has successfull stopped resolve the promise
defer.resolve();
return libQ.resolve();
};
initTest.prototype.onRestart = function() {
var self = this;
// Optional, use if you need it
};
initTest.prototype.setUIConfig = function(data) {
var self = this;
//Perform your installation tasks here
};
initTest.prototype.getConf = function(varName) {
var self = this;
//Perform your installation tasks here
};
initTest.prototype.setConf = function(varName, varValue) {
var self = this;
//Perform your installation tasks here
};
// Playback Controls ---------------------------------------------------------------------------------------
// If your plugin is not a music_sevice don’t use this part and delete it
initTest.prototype.addToBrowseSources = function () {
// Use this function to add your music service plugin to music sources
//var data = {name: 'Spotify', uri: 'spotify',plugin_type:'music_service',plugin_name:'spop'};
this.commandRouter.volumioAddToBrowseSources(data);
};
initTest.prototype.handleBrowseUri = function (curUri) {
var self = this;
//self.commandRouter.logger.info(curUri);
var response;
return response;
};
// Define a method to clear, add, and play an array of tracks
initTest.prototype.clearAddPlayTrack = function(track) {
var self = this;
self.commandRouter.pushConsoleMessage(‘[’ + Date.now() + '] ’ + ‘initTest::clearAddPlayTrack’);
orderoftheflame ,
Thanks! It’s been over a month since your post and the “getConfigurationFiles” function is still missing when generating a base plug-in with “volumio plugin init”. Your post was of great help.
Running Volumio in DEV mode, “volumio dev” from the command line, lets you see “console.log()” output. With your post and some debugging lines I finally figure it out.
I’ve not had a lot of time to finish the bits I want to on my plugin off, when I do I’ll try to get it merged in if anyone else with an Onkyo receiver wants to use it.