mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 17:12:32 +00:00
MEDIAPORTAL: Plugins can be retreived and changed to
git-svn-id: https://svn.fhem.de/fhem/trunk@13682 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d73358e628
commit
b6564cc7f7
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 70_MEDIAPORTAL: Plugins can be retreived and changed to
|
||||||
- update: 00_SONOS: New version, see Wiki- or File-Changelog
|
- update: 00_SONOS: New version, see Wiki- or File-Changelog
|
||||||
- update: 88_HMCCU: Code optimized. Fixed Windows process ID bug.
|
- update: 88_HMCCU: Code optimized. Fixed Windows process ID bug.
|
||||||
- bugfix: 71_YAMAHA_NP: Fixed tuner readings in standby.
|
- bugfix: 71_YAMAHA_NP: Fixed tuner readings in standby.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# Changed, adopted and new copyrighted by Reiner Leins (Reinerlein), (c) in February 2016
|
# Changed, adopted and new copyrighted by Reiner Leins (Reinerlein), (c) in March 2017
|
||||||
# Original Copyright by Andreas Kwasnik (gemx)
|
# Original Copyright by Andreas Kwasnik (gemx)
|
||||||
#
|
#
|
||||||
# Fhem is free software: you can redistribute it and/or modify
|
# Fhem is free software: you can redistribute it and/or modify
|
||||||
@ -23,6 +23,9 @@
|
|||||||
#
|
#
|
||||||
########################################################################################
|
########################################################################################
|
||||||
# Changelog
|
# Changelog
|
||||||
|
# 12.03.2017
|
||||||
|
# Es gibt einen neuen Getter "plugins", der das Reading "Plugins" mit den aktuell verfügbaren Plugins und deren WindowIds belegt
|
||||||
|
# Es gibt einen neuen Setter "window" der als Parameter eine WindowId oder einen Pluginnamen (URL-Encoded mit %20 für Leerzeichen!) erhält
|
||||||
# 14.03.2016
|
# 14.03.2016
|
||||||
# Es gibt nun ein Attribut "HeartbeatInterval", mit dem das Intervall für die Verbindungsprüfung festgelegt werden kann. Ein Wert von "0" deaktiviert die Prüfung.
|
# Es gibt nun ein Attribut "HeartbeatInterval", mit dem das Intervall für die Verbindungsprüfung festgelegt werden kann. Ein Wert von "0" deaktiviert die Prüfung.
|
||||||
# Es gibt nun das Attribut "disable", mit dem das Modul deaktiviert werden kann.
|
# Es gibt nun das Attribut "disable", mit dem das Modul deaktiviert werden kann.
|
||||||
@ -54,6 +57,7 @@ use Time::HiRes qw(gettimeofday);
|
|||||||
use DevIo;
|
use DevIo;
|
||||||
use JSON;
|
use JSON;
|
||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
@ -106,7 +110,7 @@ sub MEDIAPORTAL_Define($$) {
|
|||||||
$dev .= ":8017" if ($dev !~ m/:/ && $dev ne "none" && $dev !~ m/\@/);
|
$dev .= ":8017" if ($dev !~ m/:/ && $dev ne "none" && $dev !~ m/\@/);
|
||||||
|
|
||||||
$hash->{DeviceName} = $dev;
|
$hash->{DeviceName} = $dev;
|
||||||
$hash->{STATE} = 'Disconnected';
|
$hash->{STATE} = 'disconnected';
|
||||||
|
|
||||||
my $ret = undef;
|
my $ret = undef;
|
||||||
$ret = DevIo_OpenDev($hash, 0, 'MEDIAPORTAL_DoInit') if AttrVal($hash->{NAME}, 'disable', 0);
|
$ret = DevIo_OpenDev($hash, 0, 'MEDIAPORTAL_DoInit') if AttrVal($hash->{NAME}, 'disable', 0);
|
||||||
@ -185,7 +189,7 @@ sub MEDIAPORTAL_Attribute($@) {
|
|||||||
sub MEDIAPORTAL_DoInit($) {
|
sub MEDIAPORTAL_DoInit($) {
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{STATE} = 'Connecting...';
|
readingsSingleUpdate($hash, 'state', 'Connecting...', 1);
|
||||||
$hash->{helper}{buffer} = '';
|
$hash->{helper}{buffer} = '';
|
||||||
$hash->{helper}{LastStatusTimestamp} = time();
|
$hash->{helper}{LastStatusTimestamp} = time();
|
||||||
|
|
||||||
@ -234,8 +238,10 @@ sub MEDIAPORTAL_Get($@) {
|
|||||||
$cmd = "{\"Type\":\"requestnowplaying\"}\r\n";
|
$cmd = "{\"Type\":\"requestnowplaying\"}\r\n";
|
||||||
} elsif ($cname eq "notify") {
|
} elsif ($cname eq "notify") {
|
||||||
$cmd = '{"Type":"properties","Properties":["#Play.Current.Title","#TV.View.title"]}'."\r\n";
|
$cmd = '{"Type":"properties","Properties":["#Play.Current.Title","#TV.View.title"]}'."\r\n";
|
||||||
|
} elsif ($cname eq "plugins") {
|
||||||
|
$cmd = "{\"Type\":\"plugins\",\"SendIcons\":false}\r\n";
|
||||||
} else {
|
} else {
|
||||||
return "Unknown command '$cname', choose one of status:noArg nowplaying:noArg";
|
return "Unknown command '$cname', choose one of status:noArg nowplaying:noArg plugins:noArg";
|
||||||
}
|
}
|
||||||
|
|
||||||
DevIo_SimpleWrite($hash, $cmd, 0);
|
DevIo_SimpleWrite($hash, $cmd, 0);
|
||||||
@ -290,6 +296,17 @@ sub MEDIAPORTAL_GetNowPlaying($) {
|
|||||||
MEDIAPORTAL_Get($hash, ($hash->{NAME}, 'nowplaying'));
|
MEDIAPORTAL_Get($hash, ($hash->{NAME}, 'nowplaying'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################################################
|
||||||
|
#
|
||||||
|
# MEDIAPORTAL_GetPlugins
|
||||||
|
#
|
||||||
|
########################################################################################
|
||||||
|
sub MEDIAPORTAL_GetPlugins($) {
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
MEDIAPORTAL_Get($hash, ($hash->{NAME}, 'plugins'));
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# MEDIAPORTAL_Set
|
# MEDIAPORTAL_Set
|
||||||
@ -384,8 +401,17 @@ sub MEDIAPORTAL_Set($@) {
|
|||||||
DevIo_OpenDev($hash, 0, 'MEDIAPORTAL_DoInit');
|
DevIo_OpenDev($hash, 0, 'MEDIAPORTAL_DoInit');
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
|
} elsif ($cname eq "window") {
|
||||||
|
my $param = $a[2];
|
||||||
|
if (!looks_like_number($param)) {
|
||||||
|
my %plugins = %{eval(ReadingsVal($hash->{NAME}, 'Plugins', '{}'))};
|
||||||
|
$param =~ s/\%20/ /g;
|
||||||
|
$param = $plugins{$param};
|
||||||
|
}
|
||||||
|
$cmd = "{\"Type\":\"window\",\"Window\":$param}\r\n";
|
||||||
} else {
|
} else {
|
||||||
return "Unknown command '$cname', choose one of wakeup:noArg sleep:noArg connect:noArg reconnect:noArg command:".join(',', split(/ /, $mpcommands))." key Volume:slider,0,1,100 powermode:".join(',', split(/ /, $powermodes))." playfile playchannel playradiochannel playlist";
|
my %plugins = %{eval(ReadingsVal($hash->{NAME}, 'Plugins', '{}'))};
|
||||||
|
return "Unknown command '$cname', choose one of wakeup:noArg sleep:noArg connect:noArg reconnect:noArg command:".join(',', split(/ /, $mpcommands))." key Volume:slider,0,1,100 powermode:".join(',', split(/ /, $powermodes))." playfile playchannel playradiochannel playlist window".((scalar(keys(%plugins)) != 0) ? ':'.join(',', map { s/ /%20/g; $_; } sort(keys(%plugins))) : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
DevIo_SimpleWrite($hash, $cmd, 0);
|
DevIo_SimpleWrite($hash, $cmd, 0);
|
||||||
@ -461,7 +487,9 @@ sub MEDIAPORTAL_ProcessMessage($$) {
|
|||||||
} elsif ($json->{Type} eq "authenticationresponse") {
|
} elsif ($json->{Type} eq "authenticationresponse") {
|
||||||
MEDIAPORTAL_Log $hash->{NAME}, 4, "AUTHRESPONSE received. SUCCESS=$json->{Success}";
|
MEDIAPORTAL_Log $hash->{NAME}, 4, "AUTHRESPONSE received. SUCCESS=$json->{Success}";
|
||||||
|
|
||||||
$hash->{STATE} = "Authenticated. Processing messages.";
|
#readingsSingleUpdate($hash, 'state', 'Authenticated. Processing messages.', 1);
|
||||||
|
readingsSingleUpdate($hash, 'state', 'opened', 1);
|
||||||
|
InternalTimer(gettimeofday() + 1, 'MEDIAPORTAL_GetPlugins', $hash, 0);
|
||||||
} elsif ($json->{Type} eq "status") {
|
} elsif ($json->{Type} eq "status") {
|
||||||
MEDIAPORTAL_Log $hash->{NAME}, 4, 'STATUS received.';
|
MEDIAPORTAL_Log $hash->{NAME}, 4, 'STATUS received.';
|
||||||
|
|
||||||
@ -559,9 +587,16 @@ sub MEDIAPORTAL_ProcessMessage($$) {
|
|||||||
|
|
||||||
MEDIAPORTAL_Log undef, 4, 'JSON: '.Dumper($json);
|
MEDIAPORTAL_Log undef, 4, 'JSON: '.Dumper($json);
|
||||||
} elsif ($json->{Type} eq "facadeinfo") {
|
} elsif ($json->{Type} eq "facadeinfo") {
|
||||||
MEDIAPORTAL_Log $hash->{NAME}, 4, 'FACADEINFO5 received.';
|
MEDIAPORTAL_Log $hash->{NAME}, 4, 'FACADEINFO received.';
|
||||||
} elsif ($json->{Type} eq "dialog") {
|
} elsif ($json->{Type} eq "dialog") {
|
||||||
MEDIAPORTAL_Log $hash->{NAME}, 4, 'DIALOG received.';
|
MEDIAPORTAL_Log $hash->{NAME}, 4, 'DIALOG received.';
|
||||||
|
} elsif ($json->{Type} eq "plugins") {
|
||||||
|
MEDIAPORTAL_Log $hash->{NAME}, 1, 'Plugins received.';
|
||||||
|
my %plugins = ();
|
||||||
|
foreach (@{$json->{Plugins}}) {
|
||||||
|
$plugins{$_->{Name}} = $_->{WindowId};
|
||||||
|
}
|
||||||
|
readingsSingleUpdate($hash, 'Plugins', MEDIAPORTAL_Dumper(\%plugins), 1);
|
||||||
} else {
|
} else {
|
||||||
MEDIAPORTAL_Log $hash->{NAME}, 1, "Unhandled message received: MessageType '$json->{Type}'";
|
MEDIAPORTAL_Log $hash->{NAME}, 1, "Unhandled message received: MessageType '$json->{Type}'";
|
||||||
}
|
}
|
||||||
@ -722,6 +757,21 @@ sub MEDIAPORTAL_posInList($@) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################################################################
|
||||||
|
#
|
||||||
|
# MEDIAPORTAL_Dumper - Returns the 'Dumpered' Output of the given Datastructure-Reference
|
||||||
|
#
|
||||||
|
########################################################################################
|
||||||
|
sub MEDIAPORTAL_Dumper($) {
|
||||||
|
my ($varRef) = @_;
|
||||||
|
|
||||||
|
$Data::Dumper::Indent = 0;
|
||||||
|
my $text = Dumper($varRef);
|
||||||
|
$Data::Dumper::Indent = 2;
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################################
|
########################################################################################
|
||||||
#
|
#
|
||||||
# MEDIAPORTAL_Log - Log to the normal Log-command with the prefix 'SONOSPLAYER'
|
# MEDIAPORTAL_Log - Log to the normal Log-command with the prefix 'SONOSPLAYER'
|
||||||
@ -736,6 +786,8 @@ sub MEDIAPORTAL_Log($$$) {
|
|||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
=item summary Connects to a running MediaPortal instance via the WifiRemote plugin.
|
||||||
|
=item summary_DE Verbindet sich über das Wifiremote-Plugin mit einer Mediaportal-Instanz.
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="MEDIAPORTAL"></a>
|
<a name="MEDIAPORTAL"></a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user