diff --git a/FHEM/00_ZWDongle.pm b/FHEM/00_ZWDongle.pm
index 4116458e0..481ce384e 100755
--- a/FHEM/00_ZWDongle.pm
+++ b/FHEM/00_ZWDongle.pm
@@ -26,6 +26,12 @@ my %sets = (
onNwSec=>0xc1, onSec=>0x81 } },
"backupCreate" => { cmd => "" },
"backupRestore" => { cmd => "" },
+ "controllerChange" => { cmd => "4d%02x@", #ZW_CONTROLLER_CHANGE
+ param => { on =>0x02, stop =>0x05,
+ stopFailed =>0x06 } },
+ "createNewPrimary" => { cmd => "4c%02x@", # ZW_CREATE_NEW_PRIMARY
+ param => { on =>0x02, stop =>0x05,
+ stopFailed =>0x06 } },
"createNode" => { cmd => "60%02x" }, # ZW_REQUEST_NODE_INFO
"factoryReset" => { cmd => "" }, # ZW_SET_DEFAULT
"learnMode" => { cmd => "50%02x@", # ZW_SET_LEARN_MODE
@@ -446,7 +452,9 @@ ZWDongle_DoInit($)
ZWDongle_Clear($hash);
ZWDongle_Get($hash, $name, "caps");
+ ZWDongle_Get($hash, $name, "ctrlCaps");
ZWDongle_Get($hash, $name, "homeId");
+ ZWDongle_Get($hash, $name, "sucNodeId");
ZWDongle_Get($hash, $name, ("random", 32)); # Sec relevant
ZWDongle_Set($hash, $name, ("timeouts", 100, 15)); # Sec relevant
ZWDongle_ReadAnswer($hash, "timeouts", "^0106");
@@ -844,7 +852,7 @@ ZWDongle_Ready($)
Set
- - addNode [on|onNw|onSec|onNwSec|off]
+ - addNode <on|onNw|onSec|onNwSec|off>
Activate (or deactivate) inclusion mode. The controller (i.e. the dongle)
will accept inclusion (i.e. pairing/learning) requests only while in this
mode. After activating inclusion mode usually you have to press a switch
@@ -856,7 +864,7 @@ ZWDongle_Ready($)
device supports the SECURITY class, then a secure inclusion is attempted.
- - backupCreate [64k|128k|256k]
+ - backupCreate <64k|128k|256k>
read out the NVRAM of the ZWDongle, and store it in a file called
<ZWDongle_Name>.bin in the modpath folder. Since the size of the
NVRAM is currently unknown to FHEM, you have to specify the size. The
@@ -869,8 +877,20 @@ ZWDongle_Ready($)
Restore the file created by backupCreate. Restoring the file takes about
the same time as saving it, and FHEM is blocked during this time.
+
+ - controllerChange <on|stop|stopFailed>
+ Add a controller to the current network and transfer role as primary to it.
+ Invoking controller is converted to secondary.
+ <stop> = stop controllerChange
+ <stopFailed> = stop controllerChange and report an error
+
+ - createNewPrimary <on|stop|stopFailed>
+ Add a controller to the current network as a replacement for an old
+ primary. Command can be invoked only by a secondary configured as basic SUC
+ <stop> = stop controllerChange
+ <stopFailed> = stop controllerChange and report an error
- - createNode id
+ - createNode <decimal nodeId>
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
@@ -878,24 +898,24 @@ ZWDongle_Ready($)
for battery based devices you have to press the "wakeup" button 1-2 seconds
before entering this command in FHEM.
- - factoryReset [yes]
+ - 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.
- - learnMode [on|onNw|disable]
+ - learnMode <on|onNw|disable>
Add or remove controller to/from an other network.
Assign a homeId, nodeId and receive/store nodeList and routing infos.
- - removeFailedNode
+ - removeFailedNode <decimal nodeId>
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.
- - removeNode [onNw|on|off]
+ - 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
@@ -905,15 +925,15 @@ ZWDongle_Ready($)
First close and then open the device. Used for debugging purposes.
- - replaceFailedNode
+ - replaceFailedNode <decimal nodeId>
Replace a non-responding node with a new one. The non-responding node
must be on the failed node list.
- - sucNodeId [nodeId] [sucState] [capabilities]
- 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
+ - sucNodeId <decimal nodeId> <sucState> <capabilities>
+ 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
@@ -921,39 +941,39 @@ ZWDongle_Ready($)
Get
- - nodeList
- return the list of included nodenames or UNKNOWN_id, if there is no
- corresponding device in FHEM. Can be used to recreate fhem-nodes with the
- createNode command.
-
- homeId
return the six hex-digit homeId of the controller.
- - isFailedNode
+ - isFailedNode <decimal nodeId>
return if a node is stored in the failed node list.
- caps, ctrlCaps, version
return different controller specific information. Needed by developers
only.
- - neighborList [onlyRep] nodeId
+ - neighborList [excludeDead] [onlyRep] <decimal nodeId>
return data for the decimal nodeId.
With onlyRep the result will include only nodes with repeater
functionality.
- - nodeInfo
+ - nodeInfo <decimal nodeId>
return node specific information. Needed by developers only.
+
+ - nodeList
+ return the list of included nodenames or UNKNOWN_id, if there is no
+ corresponding device in FHEM. Can be used to recreate FHEM-nodes with the
+ createNode command.
- - random N
- request N random bytes from the controller.
+ - random <N>
+ request <N> random bytes from the controller.
- - raw
- Send raw data to the controller. Developer only.
+ - raw <hex>
+ Send raw data <hex> to the controller. Developer only.
- sucNodeId
- return the currently registered SUC node ID.
+ return the currently registered decimal SUC node ID.
@@ -978,7 +998,14 @@ ZWDongle_Ready($)
Generated events:
- - ZW_ADD_NODE_TO_NETWORK [learnReady|nodeFound|controller|done|failed]
+
- UNDEFINED ZWave_${type6}_$id ZWave $homeId $id $classes"
+
+ - ZW_ADD_NODE_TO_NETWORK [learnReady|nodeFound|slave|controller|
+ done|failed]
+
+ - ZW_CONTROLLER_CHANGE [learnReady|nodeFound|controller|done|failed]
+
+ - ZW_CREATE_NEW_PRIMARY [learnReady|nodeFound|controller|done|failed]
- ZW_REMOVE_FAILED_NODE_ID
[failedNodeRemoveStarted|notPrimaryController|noCallbackFunction|
@@ -994,8 +1021,6 @@ ZWDongle_Ready($)
failedNodeRemoveFail|nodeOk|failedNodeReplace|
failedNodeReplaceDone|failedNodeRemoveFailed]
- - UNDEFINED ZWave_${type6}_$id ZWave $homeId $id $classes"
-
- ZW_REQUEST_NODE_NEIGHBOR_UPDATE [started|done|failed]
- ZW_SET_DEFAULT [done]
diff --git a/FHEM/10_ZWave.pm b/FHEM/10_ZWave.pm
index 9a899510d..3d4f1d4bf 100755
--- a/FHEM/10_ZWave.pm
+++ b/FHEM/10_ZWave.pm
@@ -3888,7 +3888,18 @@ ZWave_Parse($$@)
} elsif($id eq "06") { $evt = 'callbackFailed';
} else { $evt = 'unknown_'.$id; # do not know
}
-
+
+ } elsif($cmd eq "ZW_CONTROLLER_CHANGE" ||
+ $cmd eq "ZW_CREATE_NEW_PRIMARY") {
+ my @vals = ("learnReady", "nodeFound", "slave","controller", "protocolDone",
+ "done", "failed"); # slave should never happen
+ $evt = ($id eq "00" || hex($id)>@vals+1) ? "unknownArg" : $vals[hex($id)-1];
+ if($cmd eq "ZW_CREATE_NEW_PRIMARY" && $evt eq "protocolDone") {
+ AnalyzeCommand(undef, "set $ioName createNewPrimary stop");
+ }
+ if($cmd eq "ZW_CONTROLLER_CHANGE" && $evt eq "protocolDone") {
+ AnalyzeCommand(undef, "set $ioName addNode off");
+ }
}
if($evt) {