From a9919f3a60e41f3a9e57f7b5e42f7aca0ba29498 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Tue, 8 Aug 2017 07:53:34 +0200 Subject: [PATCH] add nfc support --- 73_AMADCommBridge.pm | 2 +- 74_AMADDevice.pm | 24 +- ...1.xml => 74_AMADautomagicFlowset_4.0.2.xml | 1117 +++++++++-------- 3 files changed, 620 insertions(+), 523 deletions(-) rename 74_AMADautomagicFlowset_4.0.1.xml => 74_AMADautomagicFlowset_4.0.2.xml (85%) diff --git a/73_AMADCommBridge.pm b/73_AMADCommBridge.pm index 2860619..998412d 100644 --- a/73_AMADCommBridge.pm +++ b/73_AMADCommBridge.pm @@ -75,7 +75,7 @@ eval "use JSON;1" or $missingModul .= "JSON "; my $modulversion = "4.0.1"; -my $flowsetversion = "4.0.1"; +my $flowsetversion = "4.0.2"; diff --git a/74_AMADDevice.pm b/74_AMADDevice.pm index 33ade9a..8d8d2ff 100644 --- a/74_AMADDevice.pm +++ b/74_AMADDevice.pm @@ -58,8 +58,8 @@ eval "use Encode qw(encode encode_utf8);1" or $missingModul .= "Encode "; eval "use JSON;1" or $missingModul .= "JSON "; -my $modulversion = "4.0.4"; -my $flowsetversion = "4.0.1"; +my $modulversion = "4.0.5"; +my $flowsetversion = "4.0.2"; @@ -383,15 +383,18 @@ sub AMADDevice_WriteReadings($$) { $v =~ s/\bnull\b//g; $v = encode_utf8($v); - readingsBulkUpdateIfChanged($hash, $t, $v, 1) if( defined( $v ) and ($t ne 'deviceState' + readingsBulkUpdateIfChanged($hash, $t, $v, 1) if( defined( $v ) and ($t ne 'deviceState' or $t ne 'incomingCallerName' - or $t ne 'incomingCallerNumber') + or $t ne 'incomingCallerNumber' + or $t ne 'nfcLastTagID') ); readingsBulkUpdateIfChanged( $hash, $t, ($v / AttrVal($name,'setVolFactor',1)) ) if( $t eq 'volume' and AttrVal($name,'setVolFactor',1) > 1 ); readingsBulkUpdate( $hash, '.'.$t, $v ) if( $t eq 'deviceState' ); - readingsBulkUpdate( $hash, $t, $v ) if( $t eq 'incomingCallerName' ); - readingsBulkUpdate( $hash, $t, $v ) if( $t eq 'incomingCallerNumber' ); + readingsBulkUpdate( $hash, $t, $v ) if( $t eq 'incomingCallerName' + or $t eq 'incomingCallerNumber' + or $t eq 'nfcLastTagID' + ); } readingsBulkUpdateIfChanged( $hash, "deviceState", "offline", 1 ) if( $decode_json->{payload}{airplanemode} && $decode_json->{payload}{airplanemode} eq "on" ); @@ -630,6 +633,14 @@ sub AMADDevice_Set($$@) { $method = "POST"; } + elsif( lc $cmd eq 'nfc' ) { + + my $mod = join( " ", @args ); + + $uri = $host . ":" . $port . "/fhem-amad/setCommands/setnfc?nfc=".$mod; + $method = "POST"; + } + elsif( lc $cmd eq 'system' ) { my $systemcmd = join( " ", @args ); @@ -770,6 +781,7 @@ sub AMADDevice_Set($$@) { $list .= " openApp:$apps" if( AttrVal( $name, "setOpenApp", "none" ) ne "none" ); $list .= " system:reboot,shutdown,airplanemodeON" if( AttrVal( $name, "root", "0" ) eq "1" ); $list .= " changetoBTDevice:$btdev" if( AttrVal( $name, "setBluetoothDevice", "none" ) ne "none" ); + $list .= " nfc:on,off" if( AttrVal( $name, "root", "0" ) eq "1" ); $list .= " volume:slider,0,1,$volMax"; $list .= " volumeNotification:slider,0,1,$notifyVolMax"; $list .= " volumeRingSound:slider,0,1,$ringSoundVolMax"; diff --git a/74_AMADautomagicFlowset_4.0.1.xml b/74_AMADautomagicFlowset_4.0.2.xml similarity index 85% rename from 74_AMADautomagicFlowset_4.0.1.xml rename to 74_AMADautomagicFlowset_4.0.2.xml index 1dae04b..ba4d2d0 100644 --- a/74_AMADautomagicFlowset_4.0.1.xml +++ b/74_AMADautomagicFlowset_4.0.2.xml @@ -271,6 +271,23 @@ irname=getString("name") true com.amazon.mp3,com.amazon.avod.thirdpartyclient,com.audible.application,com.rhapsody.alditalk,com.spotify.music,com.google.android.videos,com.google.android.music,org.smblott.intentradioio,de.maxdome.app.android,tunein.player,org.videolan.vlc,com.google.android.youtube,com.sec.android.app.music + + false + NFC State + true + true + true + true + true + + + false + NFC TagIDs + true + false + TAG_123 + + false Periodischer Timer: alle 120s @@ -639,6 +656,11 @@ irname=getString("name") Expression: multimediaControl" request_path == "/fhem-amad/setCommands/multimediaControl" + + false + Expression: nfc" + request_path == "/fhem-amad/setCommands/setnfc" + false Expression: notifysnd" @@ -739,6 +761,16 @@ irname=getString("name") Expression: param_lockmod == "lock" param_lockmod == "lock" + + true + Expression: param_nfc == "off" + param_nfc == "off" + + + true + Expression: param_nfc == "on" + param_nfc == "on" + true Expression: param_notifyfile == "RedAlert.mp3" @@ -2112,6 +2144,16 @@ Connection: close Neustart + + true + NFC ein-/ausschalten: Aus + false + + + true + NFC ein-/ausschalten: Ein + true + false Notification Lautstärke Speichern @@ -2470,6 +2512,18 @@ global_userflowstate = "none"; Script: global_fhemip = {value} + + true + Script: if (trigger == "NFC TagIDs" ) { nfcLastTagID = "\"nfcLastTagID\":" + " \"" + {nfc_tag_ids} + "\""} if (trigger == "NFC State" ) { nfc = "\"nfc\":" + " \"" + {nfc_state} + "\""} fhemcmd = "setreading"; + + true Script: if(index == 0) { sprachassi = "ja"; } else { sprachassi = "nein"; } @@ -2831,7 +2885,7 @@ fhemcmd = "setreading"; false Script: Set FHEMDATA JSON -