Hello,
It would be great to add in WU and weather.com plugin the possibility to
manage macros from other plugins. For instance this way
Code:
--------------------
my $funcptr = undef;
...
$funcptr = Slim::Control::Request::addDispatch(['sdtMacroString'],
[1, 1, 1, \¯oString]);
...
sub macroString {
my $request = shift;
my $client = $request->client();
$log->debug("Inside CLI request macroString");
my $format = $request->getParam('format');
my $period = $request->getParam('period');
#Default period to 0 if not provided
if (!defined $period) {$period = -1;}
$log->debug("Incoming string: $format Period: $period");
my $macroString = replaceMacrosPer($format, $period, $client);
$log->debug("Outgoing string: $macroString");
$request->addResult( "macroString", $macroString );
if (defined $funcptr && ref($funcptr) eq 'CODE') {
$request->addParam('format', $macroString);
eval { &{$funcptr}($request) };
# arrange for some useful logging if we fail
if ($@) {
$log->error('Error while trying to run function
coderef: [' . $@ . ']');
$request->setStatusBadDispatch();
$request->dump('Request');
}
}
else {
$request->setStatusDone();
}
}
--------------------
funcptr is defined if another plugin already set the dispatch, each
plugin must call funcptr to chain sdtMacroString calls
I made a plugin (https://guillaumezin.github.io/DomoticzControl/) and I
want to be able to add the state of some device on CustomClock this way.
What do you think?
------------------------------------------------------------------------
barberousse's Profile: http://forums.slimdevices.com/member.php?userid=63897
View this thread: http://forums.slimdevices.com/showthread.php?t=14327
_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins