From 9977df7adcbcf752e63b599e77732a4edb4fc35f Mon Sep 17 00:00:00 2001 From: klassm <> Date: Sat, 8 Feb 2014 13:53:09 +0000 Subject: [PATCH] Add deviceFilter to 98_gcmsend git-svn-id: https://svn.fhem.de/fhem/trunk@4848 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/98_gcmsend.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fhem/contrib/98_gcmsend.pm b/fhem/contrib/98_gcmsend.pm index a76dac381..e257ff475 100644 --- a/fhem/contrib/98_gcmsend.pm +++ b/fhem/contrib/98_gcmsend.pm @@ -14,7 +14,7 @@ gcmsend_Initialize($) $hash->{DefFn} = "gcmsend_Define"; $hash->{NotifyFn} = "gcmsend_notify"; $hash->{SetFn} = "gcmsend_set"; - $hash->{AttrList} = "loglevel:0,1,2,3,4,5 regIds apiKey stateFilter vibrate"; + $hash->{AttrList} = "loglevel:0,1,2,3,4,5 regIds apiKey stateFilter vibrate deviceFilter"; } sub @@ -125,7 +125,7 @@ sub gcmsend_fillGeneralPayload($$) { $vibrate = "true"; } - return $payloadString . + return $payloadString . "," . "\"source\":\"gcmsend_fhem\"," . "\"vibrate\":\"$vibrate\""; } @@ -214,8 +214,11 @@ sub gcmsend_notify($$) my $name = $dev->{NAME}; my $gcmName = $gcm->{NAME}; + my $deviceFilter = AttrVal($gcm->{NAME}, "deviceFilter", ""); + return if $name eq $gcmName; return if(!$dev->{CHANGED}); # Some previous notify deleted the array. + return if (! ($deviceFilter eq "") && !($name =~ m/$deviceFilter/)); my $stateFilter = AttrVal($gcm->{NAME}, "stateFilter", ""); @@ -335,10 +338,12 @@ sub gcmsend_notify($$)
Registration IDs Google sends the messages to (multiple values separated by "|"
  • attr <name> apiKey <string>
    API-Key for GCM (can be found within the Google API Console)
  • -
  • attr <name> stateFilter <string> +
  • attr <name> stateFilter <regexp>
    Send a GCM message only if the attribute matches the attribute filter regexp
  • attr <name> vibrate (true|false)
    Make the receiving device vibrate upon receiving the message. Must be true or false.
  • +
  • attr <name> deviceFilter <regexp> +
    Send a GCM notify only is the device name matches the given filter regexp.