diff --git a/fhem/CHANGED b/fhem/CHANGED index 3b12d834b..fdcdfaf40 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - feature: 70_XBMC.pm: new commands poweron,poweroff. configurable by attribute powerCmd - added: 71_YAMAHA_NP.pm: New module for controlling Yamaha network players such as CRX-N560(D) - bugfix: FB_CALLMONITOR: fix not working telnet login, when user based authentication is configured in FritzBox diff --git a/fhem/FHEM/70_XBMC.pm b/fhem/FHEM/70_XBMC.pm index 7672b06ce..bf5c548cb 100644 --- a/fhem/FHEM/70_XBMC.pm +++ b/fhem/FHEM/70_XBMC.pm @@ -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 " . $readingFnAttributes; + $hash->{AttrList} = "fork:enable,disable compatibilityMode:xbmc,plex offMode:quit,hibernate,shutdown,standby pingInterval powerCmd " . $readingFnAttributes; $data{RC_makenotify}{XBMC} = "XBMC_RCmakenotify"; $data{RC_layout}{XBMC_RClayout} = "XBMC_RClayout"; @@ -75,6 +75,25 @@ sub XBMC_Define($$) return undef; } +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 :"; + } + + my $cmdToExec = $power ? $cmds[0] : $cmds[1]; + + return "Skipping empty command" if (length($cmdToExec) == 0); + + # execute the power command + fhem($cmdToExec); + + return "Executed command: $cmdToExec"; +} + # Force a connection attempt to XBMC as soon as possible # (e.g. you know you just started it and want to connect immediately without waiting up to 60 s) sub XBMC_Connect($) @@ -778,6 +797,12 @@ sub XBMC_Set($@) elsif($cmd eq 'connect') { return XBMC_Connect($hash); } + elsif($cmd eq 'poweron') { + return XBMC_PowerCmd($hash, 1); + } + elsif($cmd eq 'poweroff') { + return XBMC_PowerCmd($hash, 0); + } my $res = "Unknown argument " . $cmd . ", choose one of " . "off play:all,audio,video,picture playpause:all,audio,video,picture pause:all,audio,video,picture " . "prev:all,audio,video,picture next:all,audio,video,picture goto stop:all,audio,video,picture " . @@ -814,7 +839,7 @@ sub XBMC_Set($@) "mute:toggle,on,off volume:slider,0,1,100 quit:noArg " . "eject:noArg hibernate:noArg reboot:noArg shutdown:noArg suspend:noArg " . "videolibrary:scan,clean audiolibrary:scan,clean statusRequest jsonraw " . - "connect"; + "connect poweron poweroff"; return $res ; } @@ -1380,6 +1405,8 @@ sub XBMC_HTTP_Request($$@)
  • hibernate - the XBMC host will be put into hibernation
  • reboot - the XBMC host will be rebooted
  • connect - try to connect to the XBMC host immediately
  • +
  • poweron - executes power-on command provided by the attribute powerCmd
  • +
  • poweroff - executes power-off command provided by the attribute powerCmd