From 07c4dc0f85415dd4a1c31c81555eccf7ffceccdd Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Fri, 6 May 2016 20:06:36 +0000 Subject: [PATCH] ZWave/ZWDongle: Special handling for ZW_SET_DEFAULT (Forum #53087) git-svn-id: https://svn.fhem.de/fhem/trunk@11400 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_ZWDongle.pm | 39 +++++++++++++++++++++++++++++++++------ fhem/FHEM/10_ZWave.pm | 14 ++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/00_ZWDongle.pm b/fhem/FHEM/00_ZWDongle.pm index e07cbb95a..929376408 100755 --- a/fhem/FHEM/00_ZWDongle.pm +++ b/fhem/FHEM/00_ZWDongle.pm @@ -27,6 +27,7 @@ my %sets = ( "removeNode" => { cmd => "4b%02x@", # ZW_REMOVE_NODE_FROM_NETWORK' param => {onNw=>0xc1, on=>0x81, off=>0x05 } }, "createNode" => { cmd => "60%02x" }, # ZW_REQUEST_NODE_INFO' + "factoryReset" => { cmd => "" }, # ZW_SET_DEFAULT "removeFailedNode" => { cmd => "61%02x@" }, # ZW_REMOVE_FAILED_NODE_ID "replaceFailedNode"=> { cmd => "63%02x@" }, # ZW_REPLACE_FAILED_NODE "sendNIF" => { cmd => "12%02x05@" },# ZW_SEND_NODE_INFORMATION @@ -214,6 +215,15 @@ ZWDongle_Set($@) close(IN); return "Restored $l bytes from $fName"; } + + if($type eq "factoryReset") { + return "Reset to default is not supported by this device" + if(ReadingsVal($name, "caps","") !~ m/ZW_SET_DEFAULT/); + return "Read commandref before use! -> Usage: set $name factoryReset yes" + if(int(@a) != 1 || $a[0] !~ m/^(yes)$/); + ZWDongle_Write($hash,"","0042"); + return "Reseted $name to factory default and assigned new random HomeId"; + } if($type eq "removeFailedNode" || $type eq "replaceFailedNode" || @@ -291,6 +301,14 @@ ZWDongle_Get($@) ReadingsVal($name, "caps","") !~ m/\b$zw_func_id{$fb}\b/) { return "$cmd is unsupported by this controller"; } + + if($cmd eq "raw") { + if($a[0] =~ s/^42//) { + Log3 $hash, 4, "ZWDongle *** get $name $cmd 42".join(" ",@a)." blocked"; + return "raw 0x42 (ZW_SET_DEFAULT) blocked. Read commandref first and ". + "use instead: set $name factoryReset"; + } + } Log3 $hash, 4, "ZWDongle *** get $name $cmd ".join(" ",@a); @@ -394,7 +412,7 @@ ZWDongle_Get($@) $msg = zwlib_parseNeighborList($hash, $msg); } elsif($cmd eq "sucNodeId") { ############################ - $msg = ($r[2]==0)?"no":hex($r[2]) + $msg = ($r[2]==0)?"no":hex($r[2]); } @@ -856,22 +874,29 @@ ZWDongle_Ready($)
  • createNode id
    - Request the class information for the specified node, and create a fhem + Request the class information for the specified node, and create a FHEM device upon reception of the answer. Used to create FHEM devices for nodes included with another software or if the fhem.cfg got lost. For the node id see the get nodeList command below. Note: the node must be "alive", i.e. for battery based devices you have to press the "wakeup" button 1-2 seconds before entering this command in FHEM.
  • +
  • factoryReset [yes]
    + Reset controller to default state. + Erase all node and routing infos, assign a new random HomeId. + To control a device it must be re-included and re-configured. + !Use this with care AND only if You know what You do! + Note: the corresponding FHEM devices have to be deleted manually.
  • +
  • removeFailedNode
    Remove a non-responding node -that must be on the failed Node list- from the routing table in controller. Instead,always use removeNode if possible. - Note: the corresponding fhem device have to be deleted manually.
  • + Note: the corresponding FHEM device have to be deleted manually.
  • removeNode [onNw|on|off]
    Activate (or deactivate) exclusion mode. "on" activates standard exclusion. "onNw" activates network wide exclusion (only SDK 4.5-4.9, SDK 6.x and - above). Note: the corresponding fhem device have to be deleted + above). Note: the corresponding FHEM device have to be deleted manually.
  • reopen
    @@ -886,7 +911,7 @@ ZWDongle_Ready($) Configure a Controller Node to be a SUC/SIS or not. [nodeId] to be SUC/SIS [sucState] 0 = deactivate; 1 = activate - [capabilities] 0 = basic SUC 1 = SIS
  • + [capabilities] 0 = basic SUC; 1 = SIS
    @@ -971,7 +996,9 @@ ZWDongle_Ready($)
  • ZW_REQUEST_NODE_NEIGHBOR_UPDATE [started|done|failed]
  • -
  • ZW_SET_SUC_NODE_ID [setSucNodeOk|setSucNodefailed] +
  • ZW_SET_DEFAULT [done] +
  • +
  • ZW_SET_SUC_NODE_ID [setSucNodeOk|setSucNodeFailed]
  • diff --git a/fhem/FHEM/10_ZWave.pm b/fhem/FHEM/10_ZWave.pm index d05da09c4..d9ce72cae 100755 --- a/fhem/FHEM/10_ZWave.pm +++ b/fhem/FHEM/10_ZWave.pm @@ -3704,6 +3704,7 @@ ZWave_Parse($$@) DoTrigger($ioName, "$cmd $retval"); return ""; } + if($cmd eq "ZW_SET_SUC_NODE_ID") { my $retval; if($arg eq "00") { $retval = 'setSucNodeFailed'; @@ -3718,6 +3719,19 @@ ZWave_Parse($$@) return ""; } + if($msg =~ m/^00(..)(..*)/) { # 00==REQUEST from the ZWDongle + my ($cmd, $arg) = ($1, $2); + $cmd = $zw_func_id{$cmd} if($zw_func_id{$cmd}); + if($cmd eq "ZW_SET_DEFAULT") { + my $retval; + if($arg eq "01") { $retval = 'done'; + } else { $retval = 'unknown_'.$arg; # should never happen + } + DoTrigger($ioName, "$cmd $retval"); + return ""; + } + } + if($msg !~ m/^00(..)(..)(..)(.*)/) { # 00=REQUEST Log3 $ioName, 4, "$ioName: UNKNOWN msg $msg"; return "";