From bf3b1e00e391a44bfc9d2af301a226c1f52b50a7 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Tue, 25 Aug 2015 21:51:35 +0200 Subject: [PATCH] set Auswahl nach Attributeinstellung --- 74_AMAD.pm | 56 ++- ...=> Automagic_FHEM-AMAD_FlowsSet_v0.5.1.xml | 418 +++++++++--------- 2 files changed, 251 insertions(+), 223 deletions(-) rename Automagic_FHEM-AMAD_FlowsSet_v0.5.0.xml => Automagic_FHEM-AMAD_FlowsSet_v0.5.1.xml (64%) diff --git a/74_AMAD.pm b/74_AMAD.pm index b11c0a8..fc39e62 100644 --- a/74_AMAD.pm +++ b/74_AMAD.pm @@ -33,7 +33,8 @@ use Time::HiRes qw(gettimeofday); use HttpUtils; -my $VERSION = "0.5.0"; +my $version = "0.5.1"; + sub AMAD_Initialize($) { @@ -48,10 +49,9 @@ sub AMAD_Initialize($) { $hash->{AttrList} = "setOpenApp ". "setFullscreen:0,1 ". "setScreenOrientation:0,1 ". - "setScreenMsg:0,1 ". - "setOpenURL:0,1 ". + "setScreenBrightness:0,1 ". "setMediaPlayer:0,1 ". - "setAlarmTime:0,1 ". + "interval ". "port ". "disable:1 "; $hash->{AttrList} .= $readingFnAttributes; @@ -79,7 +79,7 @@ sub AMAD_Define($$) { $hash->{HOST} = $host; $hash->{PORT} = $port; $hash->{INTERVAL} = $interval; - $hash->{VERSION} = $VERSION; + $hash->{VERSION} = $version; Log3 $name, 3, "AMAD ($name) - defined with host $hash->{HOST} and interval $hash->{INTERVAL} (sec)"; @@ -161,22 +161,22 @@ sub AMAD_GetUpdateTimer($) sub AMAD_Set($$@) { my ($hash, $name, $cmd, @val) = @_; - my $apps = AttrVal("$name","openApp","none"); + my $apps = AttrVal("$name","setOpenApp","none"); my $list = ""; - $list .= "screenMsg " if (AttrVal("$name","setScreenMsg","0") eq "1"); + $list .= "screenMsg "; $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 .= "screenBrightness:slider,0,1,255 " if (AttrVal("$name","setScreenBrightness","0") eq "1"); $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 .= "openURL "; $list .= "openApp:$apps " if (AttrVal("$name","setOpenApp","none") ne "none"); - $list .= "nextAlarmTime:time " if (AttrVal("$name","setAlarmTime","0") eq "1"); + $list .= "nextAlarmTime:time "; $list .= "statusRequest:noArg "; @@ -190,7 +190,7 @@ sub AMAD_Set($$@) || lc $cmd eq 'screenfullscreen' || lc $cmd eq 'screen' || lc $cmd eq 'openurl' - || lc $cmd eq 'openApp' + || lc $cmd eq 'openapp' || lc $cmd eq 'nextalarmtime' || lc $cmd eq 'statusrequest') { @@ -213,12 +213,12 @@ sub AMAD_RetrieveAutomagicInfo($) HttpUtils_NonblockingGet( { - url => $url, - timeout => 5, - hash => $hash, - method => "GET", - doTrigger => 1, - callback => \&AMAD_RetrieveAutomagicInfoFinished, + url => $url, + timeout => 5, + hash => $hash, + method => "GET", + doTrigger => 1, + callback => \&AMAD_RetrieveAutomagicInfoFinished, } ); Log3 $name, 4, "AMAD ($name) - NonblockingGet get URL"; @@ -289,12 +289,12 @@ sub AMAD_HTTP_POST($$) HttpUtils_NonblockingGet( { - url => $url, - timeout => 5, - hash => $hash, - method => "POST", - doTrigger => 1, - callback => \&AMAD_HTTP_POSTerrorHandling, + url => $url, + timeout => 5, + hash => $hash, + method => "POST", + doTrigger => 1, + callback => \&AMAD_HTTP_POSTerrorHandling, } ); Log3 $name, 4, "AMAD ($name) - Send HTTP POST with URL $url"; @@ -437,6 +437,7 @@ sub AMAD_SelectSetCmd($$@) return AMAD_HTTP_POST ($hash,$url); } + elsif (lc $cmd eq 'nextalarmtime') { my $alarmTime = join(" ", @data); my @alarm = split(":", $alarmTime); @@ -447,10 +448,19 @@ sub AMAD_SelectSetCmd($$@) Log3 $name, 4, "AMAD ($name) - Starte Update GetUpdateLocal"; return AMAD_HTTP_POST ($hash,$url); } + elsif (lc $cmd eq 'statusrequest') { AMAD_GetUpdateLocal($hash); return undef; } + + elsif (lc $cmd eq 'openapp') { + my $app = join(" ", @data); + + my $url = "http://" . $host . ":" . $port . "/fhem-amad/setCommands/openApp?app=$app"; + + return AMAD_HTTP_POST ($hash,$url); + } return undef; } diff --git a/Automagic_FHEM-AMAD_FlowsSet_v0.5.0.xml b/Automagic_FHEM-AMAD_FlowsSet_v0.5.1.xml similarity index 64% rename from Automagic_FHEM-AMAD_FlowsSet_v0.5.0.xml rename to Automagic_FHEM-AMAD_FlowsSet_v0.5.1.xml index da5d661..8fc487f 100644 --- a/Automagic_FHEM-AMAD_FlowsSet_v0.5.0.xml +++ b/Automagic_FHEM-AMAD_FlowsSet_v0.5.1.xml @@ -40,8 +40,8 @@ album = getString("album"); HIGHER_THAN - true - Benachrichtigung in Statusbar angezeigt: ch.gridvision.ppam.androidautomagic + false + Benachrichtigung in Statusbar angezeigt: Automagic ch.gridvision.ppam.androidautomagic TEXT CONTAINS_TEXT @@ -87,6 +87,21 @@ album = getString("album"); Expression: App5 param_app == "" + + false + Expression: mediaPlayer" + request_path == "/fhem-amad/setCommands/mediaPlayer" + + + false + Expression: openApp" + request_path == "/fhem-amad/setCommands/openApp" + + + false + Expression: openURL" + request_path == "/fhem-amad/setCommands/openURL" + true Expression: param_button == "back" @@ -143,65 +158,50 @@ album = getString("album"); param_screen=="on" - true - Expression: request_path == "/fhem-amad/setCommands/mediaPlayer" - request_path == "/fhem-amad/setCommands/mediaPlayer" - - - true - Expression: request_path == "/fhem-amad/setCommands/openApp" - request_path == "/fhem-amad/setCommands/openApp" - - - true - Expression: request_path == "/fhem-amad/setCommands/openURL" - request_path == "/fhem-amad/setCommands/openURL" - - - true - Expression: request_path == "/fhem-amad/setCommands/screenMsg" + false + Expression: screenMsg" request_path == "/fhem-amad/setCommands/screenMsg" - true - Expression: request_path == "/fhem-amad/setCommands/setAlarm" + false + Expression: setAlarm" request_path == "/fhem-amad/setCommands/setAlarm" - true - Expression: request_path == "/fhem-amad/setCommands/setBrightness" + false + Expression: setBrightness" request_path == "/fhem-amad/setCommands/setBrightness" - true - Expression: request_path == "/fhem-amad/setCommands/setScreenFullscreen" + false + Expression: setScreenFullscreen" request_path == "/fhem-amad/setCommands/setScreenFullscreen" - true - Expression: request_path == "/fhem-amad/setCommands/setScreenOnOff" + false + Expression: setScreenOnOff" request_path == "/fhem-amad/setCommands/setScreenOnOff" - true - Expression: request_path == "/fhem-amad/setCommands/setScreenOrientation" + false + Expression: setScreenOrientation" request_path == "/fhem-amad/setCommands/setScreenOrientation" - true - Expression: request_path == "/fhem-amad/setCommands/setVolume" + false + Expression: setVolume" request_path == "/fhem-amad/setCommands/setVolume" - - true - Expression: request_path == "/fhem-amad/setCommands/ttsMsg" - request_path == "/fhem-amad/setCommands/ttsMsg" - true Expression: trigger == "com.android.music.metachanged" trigger == "com.android.music.metachanged" + + false + Expression: ttsMsg" + request_path == "/fhem-amad/setCommands/ttsMsg" + true WLAN Verbunden: TuxNet-AP01 @@ -209,8 +209,26 @@ album = getString("album"); TuxNet-AP01 - true - App Starten: com.google.android.music + false + App Starten: App3 + + + + + false + App Starten: App4 + + + + + false + App Starten: App5 + + + + + false + App Starten: PlayMusic com.google.android.music @@ -349,27 +367,27 @@ album = getString("album"); text/plain - true - Initialisiere Variable Nächster Alarm: Variable next_alarm + false + Initialisiere Variable Nächster Alarm: next_alarm next_alarm - true - Initialisiere Variable Systemeinstellung: System screen_brightness to screenBrightness + false + Initialisiere Variable Systemeinstellung: screenBrightness SYSTEM screen_brightness screenBrightness - true - Initialisiere Variable Systemeinstellung: System volume_music_bt_a2dp to volumeMusikBluetooth + false + Initialisiere Variable Systemeinstellung: volumeMusikBluetooth SYSTEM volume_music_bt_a2dp volumeMusikBluetooth - true - Initialisiere Variable Systemeinstellung: System volume_music_speaker to volumeMusikSpeaker + false + Initialisiere Variable Systemeinstellung: volumeMusikSpeaker SYSTEM volume_music_speaker volumeMusikSpeaker @@ -404,9 +422,9 @@ album = getString("album"); true - Schalte Display ein: Hell für 60s + Schalte Display ein: Hell für 120s true - 60s + 120s true @@ -518,57 +536,57 @@ album = getString("album"); Informations FHEM Info / Steuerung über AMAD Modul true - QUEUE + STOP 120 - Initialisiere Variable Nächster Alarm: Variable next_alarm - Initialisiere Variable Systemeinstellung: System volume_music_bt_a2dp to volumeMusikBluetooth - Initialisiere Variable Systemeinstellung: System volume_music_speaker to volumeMusikSpeaker - Initialisiere Variable Systemeinstellung: System screen_brightness to screenBrightness - Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}" - Script: next_alarmday = "{next_alarm,dateformat,c}" - Display eingeschaltet - Script: screen_state = "on" - Benachrichtigung in Statusbar angezeigt: ch.gridvision.ppam.androidautomagic - Script: screen_state = "off" - Display automatisch drehen eingeschaltet - Script: screen_orientation = "default" - Script: screen_orientation = "portrait" - Script: screen_orientation = "landscape" - Display Orientierung: Portrait - HTTP Response - Pause: 2s (Gerät wach halten) - Akku Ladestand: grösser als 0% + Script: next_alarmday = "{next_alarm,dateformat,c}" + Display eingeschaltet + Script: screen_state = "on" + Script: screen_state = "off" + Script: screen_orientation = "default" + Script: screen_orientation = "portrait" + Script: screen_orientation = "landscape" + Display Orientierung: Portrait + HTTP Response + Pause: 2s (Gerät wach halten) + Akku Ladestand: grösser als 0% + Initialisiere Variable Systemeinstellung: volumeMusikBluetooth + Initialisiere Variable Systemeinstellung: volumeMusikSpeaker + Initialisiere Variable Systemeinstellung: screenBrightness + Initialisiere Variable Nächster Alarm: next_alarm + Benachrichtigung in Statusbar angezeigt: Automagic + Display automatisch drehen eingeschaltet + Script: next_alarmtime = "{next_alarm,dateformat,HH:mm}" HTTP Request: /fhem-amad/deviceInfo/, Port 8090 - - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + SetCommands @@ -582,111 +600,111 @@ album = getString("album"); Expression: param_screen=="off" Expression: param_screen=="on" - Expression: request_path == "/fhem-amad/setCommands/setVolume" - Expression: request_path == "/fhem-amad/setCommands/setScreenOnOff" - Schalte Display ein: Hell für 60s - Gerät sperren - Lautstärken setzen - Expression: request_path == "/fhem-amad/setCommands/setBrightness" - Expression: request_path == "/fhem-amad/setCommands/setAlarm" - Benachrichtigung auf Bildschirm: {param_message} (lange) - Expression: request_path == "/fhem-amad/setCommands/screenMsg" - URL in Browser öffnen: {param_url} (mit Chrome) - Expression: request_path == "/fhem-amad/setCommands/openURL" - Audio Player steuern: Medienknopf Stopp (Google Play Musik) - Expression: param_button == "play" - Audio Player steuern: Medienknopf Play (Google Play Musik) - Audio Player steuern: Medienknopf Weiter (Google Play Musik) - Expression: param_button == "next" - Audio Player steuern: Medienknopf Zurück (Google Play Musik) - Sprachausgabe: {param_message} - Setze Systemeinstellung: System screen_brightness auf {param_brightness} - Expression: request_path == "/fhem-amad/setCommands/ttsMsg" - Expression: param_button == "stop" - Expression: request_path == "/fhem-amad/setCommands/mediaPlayer" - Expression: trigger == "com.android.music.metachanged" - Expression: param_button == "back" - Setze Display Orientierung: Landscape - Setze Display Orientierung: Portrait - Setze Display Orientierung: Auf Default zurücksetzen - Expression: param_orientation == "landscape" - Expression: param_orientation == "portrait" - Expression: param_orientation == "default" - Expression: param_fullscreen == "on" - Expression: param_fullscreen == "off" - Setze Vollbild Modus: Navigation nicht anzeigen - Setze Vollbild Modus: Auf Default zurücksetzen - Expression: App1 - Expression: App3 - Expression: App2 - Expression: App4 - Expression: App5 - App Starten: tuneinradio - App Starten: tuneinradio - App Starten: tuneinradio - App Starten: com.google.android.music - App Starten: tuneinradio - WLAN Verbunden: TuxNet-AP01 - HTTP Request: GET http://fhem-tuxnet.tuxnet.local:8085/fhem?cmd=setreading%20Nexus10Wohnzimmer%20currentMusicTrack%20{encodeURLForm(track)} speichern in response - HTTP Request: GET http://fhem-tuxnet.tuxnet.local:8085/fhem?cmd=setreading%20Nexus10Wohnzimmer%20currentMusicAlbum%20{encodeURLForm(album)} speichern in response - HTTP Request: GET http://fhem-tuxnet.tuxnet.local:8085/fhem?cmd=setreading%20Nexus10Wohnzimmer%20currentMusicArtist%20{encodeURLForm(artist)} speichern in response - Expression: request_path == "/fhem-amad/setCommands/setScreenFullscreen" - Expression: request_path == "/fhem-amad/setCommands/openApp" - Expression: request_path == "/fhem-amad/setCommands/setScreenOrientation" - Setze Alarm: um {param_hour}:{param_minute} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Audio Player steuern: Medienknopf Stopp (Google Play Musik) + Expression: param_button == "play" + Audio Player steuern: Medienknopf Play (Google Play Musik) + Audio Player steuern: Medienknopf Weiter (Google Play Musik) + Expression: param_button == "next" + Audio Player steuern: Medienknopf Zurück (Google Play Musik) + Sprachausgabe: {param_message} + Expression: param_button == "stop" + Expression: trigger == "com.android.music.metachanged" + Expression: param_button == "back" + Setze Display Orientierung: Landscape + Setze Display Orientierung: Portrait + Setze Display Orientierung: Auf Default zurücksetzen + Expression: param_orientation == "landscape" + Expression: param_orientation == "portrait" + Expression: param_orientation == "default" + Expression: param_fullscreen == "on" + Expression: param_fullscreen == "off" + Setze Vollbild Modus: Auf Default zurücksetzen + Expression: App3 + Expression: App4 + Expression: App5 + App Starten: tuneinradio + WLAN Verbunden: TuxNet-AP01 + HTTP Request: GET http://fhem-tuxnet.tuxnet.local:8085/fhem?cmd=setreading%20Nexus10Wohnzimmer%20currentMusicTrack%20{encodeURLForm(track)} speichern in response + HTTP Request: GET http://fhem-tuxnet.tuxnet.local:8085/fhem?cmd=setreading%20Nexus10Wohnzimmer%20currentMusicAlbum%20{encodeURLForm(album)} speichern in response + HTTP Request: GET http://fhem-tuxnet.tuxnet.local:8085/fhem?cmd=setreading%20Nexus10Wohnzimmer%20currentMusicArtist%20{encodeURLForm(artist)} speichern in response + Expression: setVolume" + Expression: openApp" + Expression: setScreenOnOff" + Expression: ttsMsg" + Expression: setBrightness" + Expression: setAlarm" + Expression: screenMsg" + Expression: openURL" + Expression: mediaPlayer" + Expression: setScreenFullscreen" + Expression: setScreenOrientation" + Lautstärken setzen + Setze Systemeinstellung: System screen_brightness auf {param_brightness} + Setze Alarm: um {param_hour}:{param_minute} + URL in Browser öffnen: {param_url} (mit Chrome) + Benachrichtigung auf Bildschirm: {param_message} (lange) + Setze Vollbild Modus: Navigation nicht anzeigen + Gerät sperren + Schalte Display ein: Hell für 120s + App Starten: App3 + App Starten: App4 + App Starten: App5 + App Starten: PlayMusic + Expression: App2 + Expression: App1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file