From 2a1ac8e71080d2d2d314f6a1d3ea018be444c898 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Mon, 24 Aug 2015 23:26:04 +0200 Subject: [PATCH] =?UTF-8?q?commandref=20angepasst,=20selten=20verwendete?= =?UTF-8?q?=20set=20Befehle=20werden=20erst=20nach=20setzen=20eines=20attr?= =?UTF-8?q?=20eingeblendet,=20neue=20Funktionen=20-=20Bildschirmausrichtun?= =?UTF-8?q?g,=20Vollbildmodus,=20Vorbereitungen=20f=C3=BCr=20openApp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 74_AMAD.pm | 89 +++++++++++++++++++++++++++++++++++++++--------------- README.md | 2 +- 2 files changed, 65 insertions(+), 26 deletions(-) diff --git a/74_AMAD.pm b/74_AMAD.pm index 137e3c5..b11c0a8 100644 --- a/74_AMAD.pm +++ b/74_AMAD.pm @@ -22,8 +22,6 @@ # ################################################################ -###### Version 0.4.3 ############ - @@ -32,20 +30,31 @@ package main; use strict; use warnings; use Time::HiRes qw(gettimeofday); + use HttpUtils; +my $VERSION = "0.5.0"; + + sub AMAD_Initialize($) { my ($hash) = @_; - $hash->{SetFn} = "AMAD_Set"; - $hash->{DefFn} = "AMAD_Define"; - $hash->{UndefFn} = "AMAD_Undef"; - $hash->{AttrFn} = "AMAD_Attr"; - $hash->{ReadFn} = "AMAD_Read"; - $hash->{AttrList} = - "interval disable:1 " - . $readingFnAttributes; + $hash->{SetFn} = "AMAD_Set"; + $hash->{DefFn} = "AMAD_Define"; + $hash->{UndefFn} = "AMAD_Undef"; + $hash->{AttrFn} = "AMAD_Attr"; + $hash->{ReadFn} = "AMAD_Read"; + $hash->{AttrList} = "setOpenApp ". + "setFullscreen:0,1 ". + "setScreenOrientation:0,1 ". + "setScreenMsg:0,1 ". + "setOpenURL:0,1 ". + "setMediaPlayer:0,1 ". + "setAlarmTime:0,1 ". + "port ". + "disable:1 "; + $hash->{AttrList} .= $readingFnAttributes; } sub AMAD_Define($$) { @@ -70,6 +79,7 @@ sub AMAD_Define($$) { $hash->{HOST} = $host; $hash->{PORT} = $port; $hash->{INTERVAL} = $interval; + $hash->{VERSION} = $VERSION; Log3 $name, 3, "AMAD ($name) - defined with host $hash->{HOST} and interval $hash->{INTERVAL} (sec)"; @@ -151,17 +161,23 @@ sub AMAD_GetUpdateTimer($) sub AMAD_Set($$@) { my ($hash, $name, $cmd, @val) = @_; + my $apps = AttrVal("$name","openApp","none"); - my $list = "screenMsg" - . " ttsMsg" - . " volume:slider,0,1,15" - . " deviceState:online,offline" - . " mediaPlayer:play,stop,next,back" - . " screenBrightness:slider,0,1,255" - . " screen:on,off" - . " openURL" - . " nextAlarmTime:time" - . " statusRequest:noArg"; + my $list = ""; + + $list .= "screenMsg " if (AttrVal("$name","setScreenMsg","0") eq "1"); + $list .= "ttsMsg "; + $list .= "volume:slider,0,1,15 "; + $list .= "deviceState:online,offline "; + $list .= "mediaPlayer:play,stop,next,back " if (AttrVal("$name","setMediaPlayer","0") eq "1"); + $list .= "screenBrightness:slider,0,1,255 "; + $list .= "screen:on,off "; + $list .= "screenOrientation:landscape,portrait,default " if (AttrVal("$name","setScreenOrientation","0") eq "1"); + $list .= "screenFullscreen:on,off " if (AttrVal("$name","setFullscreen","0") eq "1"); + $list .= "openURL " if (AttrVal("$name","setOpenURL","0") eq "1"); + $list .= "openApp:$apps " if (AttrVal("$name","setOpenApp","none") ne "none"); + $list .= "nextAlarmTime:time " if (AttrVal("$name","setAlarmTime","0") eq "1"); + $list .= "statusRequest:noArg "; if (lc $cmd eq 'screenmsg' @@ -170,8 +186,11 @@ sub AMAD_Set($$@) || lc $cmd eq 'mediaplayer' || lc $cmd eq 'devicestate' || lc $cmd eq 'screenbrightness' + || lc $cmd eq 'screenorientation' + || lc $cmd eq 'screenfullscreen' || lc $cmd eq 'screen' || lc $cmd eq 'openurl' + || lc $cmd eq 'openApp' || lc $cmd eq 'nextalarmtime' || lc $cmd eq 'statusrequest') { @@ -391,6 +410,26 @@ sub AMAD_SelectSetCmd($$@) return AMAD_HTTP_POST ($hash,$url); } + elsif (lc $cmd eq 'screenorientation') { + my $mod = join(" ", @data); + + my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenOrientation?orientation=$mod"; + + AMAD_GetUpdateLocal($hash); + Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal"; + return AMAD_HTTP_POST ($hash,$url); + } + + elsif (lc $cmd eq 'screenfullscreen') { + my $mod = join(" ", @data); + + my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/setScreenFullscreen?fullscreen=$mod"; + + AMAD_GetUpdateLocal($hash); + Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal"; + return AMAD_HTTP_POST ($hash,$url); + } + elsif (lc $cmd eq 'openurl') { my $openurl = join(" ", @data); @@ -421,21 +460,22 @@ sub AMAD_SelectSetCmd($$@) =pod - =begin html -

AMAD - Automagic Android Device

+

AMAD

-=end html +=end html =begin html_DE -

AMAD - Automagic Android Device

+

AMAD

=end html_DE - =cut \ No newline at end of file diff --git a/README.md b/README.md index 898a5e7..15c1eee 100644 --- a/README.md +++ b/README.md @@ -112,4 +112,4 @@ Der größte Dank geht an meinen Mentor Andre (justme1968), er hat mir mit hilfr Auch möchte ich mich bei Jens bedanken (jensb) welcher mir ebenfalls mit hilfreichen Tips bei meinen aller ersten Gehversuchen beim Perlcode schreiben unterstützt hat. -So und nun noch ein besonderer Dank an pah (Prof. Dr. Peter Henning ), ohne seine Aussage "Keine Ahnung hatten wir alle mal, das ist keine Ausrede" hätte ich bestimmt nicht angefangen Interesse an Modulentwicklung zu zeigen :-) +So und nun noch ein besonderer Dank an pah (Prof. Dr. Peter Henning ), ohne seine Aussage "Keine Ahnung hatten wir alle mal, das ist keine Ausrede" hätte ich bestimmt nicht angefangen Interesse an Modulentwicklung zu zeigen :-) \ No newline at end of file