2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

fhemweb-detailscreen of remotecontrol now displays a preview, added RC_summaryFn incl attr rc_devStateIcon so no weblink is required anymore

git-svn-id: https://svn.fhem.de/fhem/trunk@3502 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ulimaass 2013-07-25 15:33:26 +00:00
parent a2344e93f5
commit fb23aa765a
2 changed files with 162 additions and 107 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII # Add changes at the top of the list. Keep it in ASCII
- SVN - SVN
- feature: 95_remotecontrol does not require a weblink anymore (UliM)
- feature: optional sleep parameter quiet - feature: optional sleep parameter quiet
- feature: additional buttons for use with 95_remotecontrol - feature: additional buttons for use with 95_remotecontrol
- feature: new module 71_LISTENLIVE.pm for use with media players (betateilchen) - feature: new module 71_LISTENLIVE.pm for use with media players (betateilchen)

View File

@ -43,7 +43,7 @@
# fixed minor html-bug - June 26, 2013 # fixed minor html-bug - June 26, 2013
# added css-tags rc_body and rc_button - June 27, 2013 # added css-tags rc_body and rc_button - June 27, 2013
# deleted leading \n at beginning of html-code - June 30, 2013 # deleted leading \n at beginning of html-code - June 30, 2013
# fhemweb-detailscreen of remotecontrol now displays a preview, added htmlNoTable for RC_attr2html(), added RC_summaryFn incl attr rc_devStateIcon
package main; package main;
@ -57,11 +57,13 @@ sub RC_Set($@);
sub RC_Get($@); sub RC_Get($@);
sub RC_Attr(@); sub RC_Attr(@);
sub RC_array2attr($@); sub RC_array2attr($@);
sub RC_attr2html($); sub RC_attr2html($@);
sub RC_layout_delete($); sub RC_layout_delete($);
sub RC_layout_samsung(); sub RC_layout_samsung();
sub RC_layout_itunes(); sub RC_layout_itunes();
sub RC_detailFn($$$$);
sub RC_webCmdFn($$$);
sub RC_summaryFn($$$$);
##################################### #####################################
# Initialize module # Initialize module
@ -73,9 +75,13 @@ remotecontrol_Initialize($)
$hash->{SetFn} = "RC_Set"; $hash->{SetFn} = "RC_Set";
$hash->{AttrFn} = "RC_Attr"; $hash->{AttrFn} = "RC_Attr";
$hash->{DefFn} = "RC_Define"; $hash->{DefFn} = "RC_Define";
$hash->{AttrList}= "rc_iconpath rc_iconprefix loglevel:0,1,2,3,4,5,6 ". $hash->{AttrList} = "rc_iconpath rc_iconprefix loglevel:0,1,2,3,4,5,6 rc_devStateIcon:0,1 ".
"row00 row01 row02 row03 row04 row05 row06 row07 row08 row09 ". "row00 row01 row02 row03 row04 row05 row06 row07 row08 row09 ".
"row10 row11 row12 row13 row14 row15 row16 row17 row18 row19"; "row10 row11 row12 row13 row14 row15 row16 row17 row18 row19";
$hash->{FW_detailFn} = "RC_detailFn"; # displays rc preview in fhemweb detail-screen
$hash->{FW_summaryFn} = "RC_summaryFn"; # displays rc instead of status icon in fhemweb room-view
$data{webCmdFn}{remotecontrol} = "RC_webCmdFn"; # displays rc instead of device-commands on the calling device
$data{RC_layout}{samsung} = "RC_layout_samsung"; $data{RC_layout}{samsung} = "RC_layout_samsung";
$data{RC_layout}{itunes} = "RC_layout_itunes"; $data{RC_layout}{itunes} = "RC_layout_itunes";
@ -131,7 +137,7 @@ RC_Set($@)
$layoutlist .= $fn."\n"; $layoutlist .= $fn."\n";
next if ($fn ne $par); next if ($fn ne $par);
no strict "refs"; no strict "refs";
@rows = &{$data{RC_layout}{$fn}}(); @rows = &{$data{RC_layout}{$fn}}($fn);
use strict "refs"; use strict "refs";
} }
if ($#rows > 0) { if ($#rows > 0) {
@ -170,7 +176,7 @@ RC_Set($@)
} }
## set ? ## set ?
} elsif ($cmd eq "?") { } elsif ($cmd eq "?") {
my $ret = "Unknown argument $cmd choose one of makeweblink makenotify state layout:"; my $ret = "Unknown argument $cmd choose one of makeweblink makenotify state .remotecontrol:remotecontrol layout:";
foreach my $fn (sort keys %{$data{RC_layout}}) { foreach my $fn (sort keys %{$data{RC_layout}}) {
$ret .= $fn . ","; $ret .= $fn . ",";
} }
@ -214,23 +220,23 @@ RC_Get($@)
##################################### #####################################
# Convert all rowXX-attribute-values into htmlcode # Convert all rowXX-attribute-values into htmlcode
sub sub
RC_attr2html($) { RC_attr2html($@) {
my $name = shift; my ($name,$htmlNoTable) = @_;
my $iconpath = AttrVal("$name","rc_iconpath","icons/remotecontrol"); my $iconpath = AttrVal("$name","rc_iconpath","icons/remotecontrol");
my $iconprefix = AttrVal("$name","rc_iconprefix",""); my $iconprefix = AttrVal("$name","rc_iconprefix","");
my $rc_html; my $rc_html;
my $row; my $row;
$rc_html = "<div class=\"remotecontrol\">"; $rc_html = "<div class=\"remotecontrol\">";
# $rc_html = "<div class=\"remotecontrol\" id=\"$name\">"; # provokes update by longpoll # $rc_html = "<div class=\"remotecontrol\" id=\"$name\">"; # provokes update by longpoll
$rc_html.= '<table class="rc_body">'; $rc_html.= '<table class="rc_body">' if (!$htmlNoTable);
foreach my $rownr (0..19) { foreach my $rownr (0..19) {
$rownr = sprintf("%2.2d",$rownr); $rownr = sprintf("%2.2d",$rownr);
$row = AttrVal("$name","row$rownr",undef); $row = AttrVal("$name","row$rownr",undef);
next if (!$row); next if (!$row);
$rc_html .= "<tr>\n"; $rc_html .= "<tr>\n" if (!$htmlNoTable);
my @btn = split (",",$row); my @btn = split (",",$row);
foreach my $btnnr (0..$#btn) { foreach my $btnnr (0..$#btn) {
$rc_html .= '<td class="rc_button">'; $rc_html .= '<td class="rc_button">';# if (!$htmlNoTable);
if ($btn[$btnnr] ne "") { if ($btn[$btnnr] ne "") {
my $cmd; my $cmd;
my $img; my $img;
@ -241,7 +247,11 @@ RC_attr2html($) {
$cmd = $btn[$btnnr]; $cmd = $btn[$btnnr];
$img = $btn[$btnnr]; $img = $btn[$btnnr];
} }
if ($img =~ m/\.svg/) { # convert svg-images
$img = FW_makeImage($img, $cmd, "rc-button");
} else {
$img = "<img src=\"$FW_ME/$iconpath/$iconprefix$img\">"; $img = "<img src=\"$FW_ME/$iconpath/$iconprefix$img\">";
}
if ($cmd || $cmd eq "0") { if ($cmd || $cmd eq "0") {
$cmd = "cmd.$name=set $name $cmd"; $cmd = "cmd.$name=set $name $cmd";
$rc_html .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmd')\">$img</a>"; $rc_html .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmd')\">$img</a>";
@ -249,11 +259,13 @@ RC_attr2html($) {
$rc_html .= $img; $rc_html .= $img;
} }
} }
$rc_html .= "</td>\n"; $rc_html .= "</td>";# if (!$htmlNoTable);
$rc_html .= "\n";
} }
$rc_html .= "</tr>\n"; $rc_html .= "</tr>\n" if (!$htmlNoTable);
} }
$rc_html .= "</table></div>"; $rc_html .= "</table>" if (!$htmlNoTable);
$rc_html .= "</div>";
return $rc_html; return $rc_html;
} }
@ -289,6 +301,43 @@ RC_array2attr($@)
} }
##################
#remotecontrol-specific fhemweb detail-screen
sub
RC_detailFn($$$$) {
my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
my $hash = $defs{$d};
$hash->{".htmlCode"} = RC_attr2html($d) if ($hash->{".htmlCode"} eq "");
return $hash->{".htmlCode"};
}
##################
#remotecontrol-specific webCmdFn to be used
# calling module needs to provide ".remotecontrol:remotecontrol" in its return to 'set <device> ?'
sub
RC_webCmdFn($$$) {
my ($FW_wname, $d, $FW_room, $cmd, $values) = @_;
return undef if($values !~ m/remotecontrol/);
my @args = split("[ \t]+", $cmd);
return RC_attr2html($args[1],1) if ($args[1]);
return undef;
}
##################
#remotecontrol-specific summaryFn to be used
# displays the remote on the remote-device itself in FHEMWEB room-overview
sub
RC_summaryFn($$$$) {
my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
my $hash = $defs{$d};
my $name = $hash->{NAME};
return undef if (AttrVal($name,"rc_devStateIcon",1) != 1);
return RC_attr2html($name);
}
##################################### #####################################
# Default-layout for samsung # Default-layout for samsung
sub sub
@ -357,7 +406,6 @@ RC_layout_itunes() {
<tr><td><code>define rc1 remotecontrol</code></td><td><code># defines a "blank" remotecontrol</code></td></tr> <tr><td><code>define rc1 remotecontrol</code></td><td><code># defines a "blank" remotecontrol</code></td></tr>
<tr><td><code>get rc1 layout</code></td><td><code># displays all available predefined layouts</code></td></tr> <tr><td><code>get rc1 layout</code></td><td><code># displays all available predefined layouts</code></td></tr>
<tr><td><code>set rc1 layout samsung</code></td><td><code># assigns keys for a SamsungTV</code></td></tr> <tr><td><code>set rc1 layout samsung</code></td><td><code># assigns keys for a SamsungTV</code></td></tr>
<tr><td><code>set rc1 makeweblink</code></td><td><code># creates weblink_rc1 which displays the remotecontrol in fhemweb or floorplan</code></td></tr>
<tr><td><code>set rc1 makenotify myTV</code></td><td><code># creates notify_rc1 which forwards every buttonclick to myTV for execution</code></td></tr> <tr><td><code>set rc1 makenotify myTV</code></td><td><code># creates notify_rc1 which forwards every buttonclick to myTV for execution</code></td></tr>
<tr><td colspan="2"><b>Note:</b> keys can be changed at any time, it is not necessary to redefine the weblink</td></tr> <tr><td colspan="2"><b>Note:</b> keys can be changed at any time, it is not necessary to redefine the weblink</td></tr>
<tr><td><code>attr rc1 row15 VOLUP,VOLDOWN</code></td></tr> <tr><td><code>attr rc1 row15 VOLUP,VOLDOWN</code></td></tr>
@ -389,10 +437,13 @@ RC_layout_itunes() {
<ul> <ul>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a name="rc_iconpath">rc_iconpath</a><br> <li><a name="rc_iconpath">rc_iconpath</a><br>
path for icons, default is "icons"</li> path for icons, default is "icons" . The attribute-value will be used for all icon-files except .svg .</li>
<li><a name="rc_iconprefix">rc_iconprefix</a><br> <li><a name="rc_iconprefix">rc_iconprefix</a><br>
prefix for icon-files, default is "" . </li> prefix for icon-files, default is "" . The attribute-value will be used for all icon-files except .svg .</li>
<li>Note: Icon-names (button-image-file-names) will be composed as <code>fhem/&lt;rc_iconpath&gt;/&lt;rc_iconprefix&gt;&lt;command|image&gt;</code></li> <li>Note: Icon-names (button-image-file-names) will be composed as <code>fhem/&lt;rc_iconpath&gt;/&lt;rc_iconprefix&gt;&lt;command|image&gt;</code><br>
For .svg -icons, the access sequence is according to the FHEMWEB-attribute iconPath, default is openautomation:fhemSVG:default .</li>
<li><a name="rc_devStateIcon">rc_devStateIcon</a><br>
In FHEMWEB-room-overview, displays the button-layout on the rc-device itself. Default is 1, set to 0 is the remotecontrol-device should not display its buttons in FHEMWEB roomview.</li>
<br> <br>
<li><a href="#rowXX">rowXX</a><br> <li><a href="#rowXX">rowXX</a><br>
<code>attr &lt;rc-name&gt; rowXX &lt;command&gt;[:&lt;image&gt;][,&lt;command&gt;[:&lt;image&gt;]][,...]</code><br> <code>attr &lt;rc-name&gt; rowXX &lt;command&gt;[:&lt;image&gt;][,&lt;command&gt;[:&lt;image&gt;]][,...]</code><br>
@ -441,7 +492,6 @@ RC_layout_itunes() {
<tr><td><code>define rc1 remotecontrol</code></td><td><code># erzeugt eine "leere" remotecontrol</code></td></tr> <tr><td><code>define rc1 remotecontrol</code></td><td><code># erzeugt eine "leere" remotecontrol</code></td></tr>
<tr><td><code>get rc1 layout</code></td><td><code># zeigt alle vorhandenen vordefinierten layouts an</code></td></tr> <tr><td><code>get rc1 layout</code></td><td><code># zeigt alle vorhandenen vordefinierten layouts an</code></td></tr>
<tr><td><code>set rc1 layout samsung</code></td><td><code># laedt das layout für SamsungTV</code></td></tr> <tr><td><code>set rc1 layout samsung</code></td><td><code># laedt das layout für SamsungTV</code></td></tr>
<tr><td><code>set rc1 makeweblink</code></td><td><code># erzeugt weblink_rc1 der die remotecontrol in fhemweb or floorplan anzeigt</code></td></tr>
<tr><td><code>set rc1 makenotify myTV</code></td><td><code># erzeugt notify_rc1, das jeden Tastendruck an myTV weitergibt</code></td></tr> <tr><td><code>set rc1 makenotify myTV</code></td><td><code># erzeugt notify_rc1, das jeden Tastendruck an myTV weitergibt</code></td></tr>
<tr><td colspan="2"><b>Hinweis:</b>die Tastenbelegung kann jederzeit geaendert werden, ohne dass der weblink erneut erzeugt werden muss.</td></tr> <tr><td colspan="2"><b>Hinweis:</b>die Tastenbelegung kann jederzeit geaendert werden, ohne dass der weblink erneut erzeugt werden muss.</td></tr>
<tr><td><code>attr rc1 row15 VOLUP,VOLDOWN</code></td></tr> <tr><td><code>attr rc1 row15 VOLUP,VOLDOWN</code></td></tr>
@ -465,10 +515,14 @@ RC_layout_itunes() {
<ul> <ul>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a name="rc_iconpath">rc_iconpath</a><br> <li><a name="rc_iconpath">rc_iconpath</a><br>
Pfad für icons, default ist "icons"</li> Pfad für icons, default ist "icons" . Der Attribut-Wert wird für alle icon-Dateien verwendet ausser .svg .</li>
<li><a name="rc_iconprefix">rc_iconprefix</a><br> <li><a name="rc_iconprefix">rc_iconprefix</a><br>
Prefix für icon-Dateien, default ist "" . </li> Prefix für icon-Dateien, default ist "" . Der Attribut-Wert wird für alle icon-Dateien verwendet ausser .svg .</li>
<li>Note: Icon-Namen (Tasten-Bild-Datei-Namen) werden zusammengesetzt als fhem/&lt;rc_iconpath&gt;/&lt;rc_iconprefix&gt;&lt;command|image&gt;</li> <li>Note: Icon-Namen (Tasten-Bild-Datei-Namen) werden zusammengesetzt als fhem/&lt;rc_iconpath&gt;/&lt;rc_iconprefix&gt;&lt;command|image&gt;<br>
Fuer .svg -icons ist die Zugriffsfolge gemaess dem FHEMWEB-Attribut iconPath, default ist openautomation:fhemSVG:default .
</li>
<li><a name="rc_devStateIcon">rc_devStateIcon</a><br>
Zeigt das button-layout auf dem remotecontrol-device selbst in der FHEMWEB-Raumansicht an. Default ist 1, durch setzen auf 0 erscheint in der FHEMWEB-Raumansciht nicht das layout, sondern nur der Status "Initialized".</li>
<br> <br>
<li><a href="#rowXX">rowXX</a><br> <li><a href="#rowXX">rowXX</a><br>