70_XBMC: Splitted attribute powerCmd in powerCmdOn and powerCmdOff

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7610 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
vbs2
2015-01-17 22:10:48 +00:00
parent 72906a2de6
commit ad875d12c9

View File

@@ -29,7 +29,7 @@ sub XBMC_Initialize($$)
$hash->{ReadFn} = "XBMC_Read";
$hash->{ReadyFn} = "XBMC_Ready";
$hash->{UndefFn} = "XBMC_Undefine";
$hash->{AttrList} = "fork:enable,disable compatibilityMode:xbmc,plex offMode:quit,hibernate,shutdown,standby pingInterval powerCmd " . $readingFnAttributes;
$hash->{AttrList} = "fork:enable,disable compatibilityMode:xbmc,plex offMode:quit,hibernate,shutdown,standby pingInterval powerCmdOn powerCmdOff " . $readingFnAttributes;
$data{RC_makenotify}{XBMC} = "XBMC_RCmakenotify";
$data{RC_layout}{XBMC_RClayout} = "XBMC_RClayout";
@@ -79,14 +79,10 @@ sub XBMC_PowerCmd($$)
{
my ($hash, $power) = @_;
my @cmds = split ":", AttrVal($hash->{NAME},'powerCmd','');
if (scalar(@cmds) != 2) {
return "Attribute powerCmd has an invalid format. Use <powerOnCmd>:<powerOffCmd>";
}
my $attrName = $power ? "powerCmdOn" : "powerCmdOff";
my $cmdToExec = AttrVal($hash->{NAME}, $attrName, '');
my $cmdToExec = $power ? $cmds[0] : $cmds[1];
return "Skipping empty command" if (length($cmdToExec) == 0);
return "Error: Attribute $attrName not set!" if (length($cmdToExec) == 0);
# execute the power command
fhem($cmdToExec);
@@ -1405,8 +1401,8 @@ sub XBMC_HTTP_Request($$@)
<li><b>hibernate</b> - the XBMC host will be put into hibernation</li>
<li><b>reboot</b> - the XBMC host will be rebooted</li>
<li><b>connect</b> - try to connect to the XBMC host immediately</li>
<li><b>poweron</b> - executes power-on command provided by the attribute powerCmd</li>
<li><b>poweroff</b> - executes power-off command provided by the attribute powerCmd</li>
<li><b>poweron</b> - executes power on command provided by the attribute powerCmd</li>
<li><b>poweroff</b> - executes power off command provided by the attribute powerCmd</li>
</ul>
</ul>
<br><br>
@@ -1483,6 +1479,10 @@ sub XBMC_HTTP_Request($$@)
If XBMC does not run all the time it used to be the case that FHEM blocks because it cannot reach XBMC (only happened
if TCP was used). If you encounter problems like FHEM not responding for a few seconds then you should set <code>attr &lt;XBMC_device&gt; fork enable</code>
which will move the search for XBMC into a separate process.</li>
<li>powerCmdOn<br>
Custom FHEM command to be executed when setting poweron. Is meant to be used in conjuction with devStateIcon</li>
<li>powerCmdOff<br>
Custom FHEM command to be executed when setting poweroff. Is meant to be used in conjuction with devStateIcon</li>
</ul>
</ul>