diff --git a/fhem/FHEM/10_ZWave.pm b/fhem/FHEM/10_ZWave.pm
index 583c3ef2e..574ff46c7 100755
--- a/fhem/FHEM/10_ZWave.pm
+++ b/fhem/FHEM/10_ZWave.pm
@@ -405,7 +405,7 @@ my %zwave_quietCmds = (
sendNonce=>1,
secEncap=>1,
- secNonce=>1
+ secNonce=>1
);
my %zwave_cmdArgs = (
@@ -529,7 +529,7 @@ ZWave_Define($$)
$proposed = $p if($defs{$p}{homeId} && $defs{$p}{homeId} eq $homeId);
}
}
- AssignIoPort($hash, $proposed);
+ AssignIoPort($hash, $proposed);
if(@a) { # Autocreate: set the classes, execute the init calls
ZWave_SetClasses($homeId, $id, undef, $a[0]);
@@ -736,7 +736,7 @@ ZWave_Cmd($$@)
my $data;
- if($cmd eq "neighborUpdate" ||
+ if($cmd eq "neighborUpdate" ||
$cmd eq "neighborList") {
$data = $cmdFmt;
@@ -1858,20 +1858,20 @@ ZWave_plusInfoParse($$$$$)
}
my %zwave_sensorBinaryTypeV2 = (
- "00"=>"unknown",
- "01"=>"generalPurpose",
- "02"=>"smoke",
- "03"=>"CO",
- "04"=>"CO2",
- "05"=>"heat",
- "06"=>"water",
- "07"=>"freeze",
- "08"=>"tamper",
- "09"=>"aux",
- "0a"=>"doorWindow",
- "0b"=>"tilt",
- "0c"=>"motion",
- "0d"=>"glassBreak"
+ "00"=>"unknown",
+ "01"=>"generalPurpose",
+ "02"=>"smoke",
+ "03"=>"CO",
+ "04"=>"CO2",
+ "05"=>"heat",
+ "06"=>"water",
+ "07"=>"freeze",
+ "08"=>"tamper",
+ "09"=>"aux",
+ "0a"=>"doorWindow",
+ "0b"=>"tilt",
+ "0c"=>"motion",
+ "0d"=>"glassBreak"
);
sub
@@ -1896,6 +1896,34 @@ ZWave_assocGroup($$$$)
return sprintf("assocGroup_%d:Max %d Nodes %s", hex($gId),hex($max), $nodes);
}
+sub
+ZWave_CRC16($)
+{
+ my ($msg) = @_;
+ my $buf = pack 'H*', $msg;
+ my $len = length($buf);
+
+ my $poly = 0x1021; #CRC-CCITT (CRC-16) x16 + x12 + x5 + 1
+ my $crc16 = 0x1D0F; #Startvalue
+
+ for(my $i=0; $i<$len; $i++) {
+ my $byte = ord(substr($buf, $i, 1));
+ $byte = $byte * 0x100; # expand to 16 Bit
+ for(0..7) {
+ if(($byte & 0x8000) ^ ($crc16 & 0x8000)) { # if Hi-bits are different
+ $crc16 <<= 1;
+ $crc16 ^= $poly;
+ } else {
+ $crc16 <<= 1;
+ }
+ $crc16 &= 0xFFFF;
+ $byte <<= 1;
+ $byte &= 0xFFFF;
+ }
+ }
+ return sprintf "%x", $crc16;
+}
+
##############################################
# SECURITY (start)
##############################################
@@ -2619,7 +2647,7 @@ ZWave_addToSendStack($$)
if(ZWave_isWakeUp($hash)) {
# SECURITY XXX and neighborList
- if ($cmd =~ m/^......988[01].*/ || $cmd =~ m/^80..0101$/) {
+ if ($cmd =~ m/^......988[01].*/ || $cmd =~ m/^80..0101$/) {
Log3 $hash->{NAME}, 5, "$hash->{NAME}: Sendstack bypassed for $cmd";
} else {
return "Scheduled for sending after WAKEUP" if(!$hash->{wakeupAlive});
@@ -2875,9 +2903,16 @@ ZWave_Parse($$@)
$arg = sprintf("%s%02x%s", $1, hex($2) & 0x7f, $3);
}
- if($arg =~ /^..5601(.*)..../) { # CRC_16_ENCAP: Unwrap encapsulated command
+ if($arg =~ /^..5601(.*)(....)/) { # CRC_16_ENCAP: Unwrap encapsulated command
#Log3 $ioName, 4, "CRC FIX, MSG: ($1)"; # see Forum #23494
- $arg = sprintf("%02x$1", length($1)/2);
+ my $crc16 = ZWave_CRC16("5601".$1);
+ if ($2 eq $crc16) {
+ $arg = sprintf("%02x$1", length($1)/2);
+ } else {
+ Log3 $ioName, 4, "$ioName CRC_16 checksum mismatch, received $2," .
+ " calculated $crc16";
+ return "";
+ }
}
my ($baseHash, $baseId, $ep) = ("",$id,"");
@@ -3159,11 +3194,11 @@ s2Hex($)
Class BASIC_WINDOW_COVERING
coveringClose
Starts closing the window cover. Moving stops if blinds are fully closed or
- a coveringStop command was issued.
+ a coveringStop command was issued.
coveringOpen
Starts opening the window cover. Moving stops if blinds are fully open or
- a coveringStop command was issued.
+ a coveringStop command was issued.
coveringStop
Stop moving the window cover. Blinds are partially open (closed).
@@ -3194,7 +3229,7 @@ s2Hex($)
set <name> wcrgb 0 255 0 0 0 (setting full cold white)
-
+
Class CONFIGURATION
configByte cfgAddress 8bitValue
configWord cfgAddress 16bitValue
@@ -3233,7 +3268,7 @@ s2Hex($)
value is supported by the device.
The command will reset ALL accumulated values, it is not possible to
choose a single value.
-
+
Class MULTI_CHANNEL_ASSOCIATION
mcaAdd groupId node1 node2 ... 0 node1 endPoint1 node2 endPoint2 ...
Add a list of node or node:endpoint associations. The latter can be used to
@@ -3265,7 +3300,7 @@ s2Hex($)
level 0=normal, level 1=-1dBm, .., level 9=-9dBm.
powerlevelTest nodeId level frames
send number of frames [1-65535] to nodeId with level [0-9].
-
+
Class PROTECTION
protectionOff
device is unprotected
@@ -3279,19 +3314,19 @@ s2Hex($)
Class SCENE_ACTIVATION
sceneConfig
activate settings for a specific scene.
- Parameters are: sceneId, dimmingDuration (00..ff)
+ Parameters are: sceneId, dimmingDuration (00..ff)
-
+
Class SCENE_ACTUATOR_CONF
sceneConfig
set configuration for a specific scene.
- Parameters are: sceneId, dimmingDuration, finalValue (00..ff)
+ Parameters are: sceneId, dimmingDuration, finalValue (00..ff)
-
+
Class SCENE_CONTROLLER_CONF
groupConfig
set configuration for a specific scene.
- Parameters are: groupId, sceneId, dimmingDuration.
+ Parameters are: groupId, sceneId, dimmingDuration.
Class SECURITY
@@ -3475,7 +3510,7 @@ s2Hex($)
return the indicator status of the node, as indState:on, indState:off or
indState:dim value.
-
+
Class MANUFACTURER_PROPRIETARY
position
Fibaro FGRM-222 only: return the blinds position and slat angle.
@@ -3536,7 +3571,7 @@ s2Hex($)
Get the name from the EEPROM. Note: only ASCII is supported.
location
Get the location from the EEPROM. Note: only ASCII is supported.
-
+
Class POWERLEVEL
powerlevel
Get the current powerlevel and remaining time in this level.
@@ -3581,7 +3616,7 @@ s2Hex($)
alarm alarmType
return the nodes alarm status of the requested alarmType. 00 = GENERIC,
01 = SMOKE, 02 = CO, 03 = CO2, 04 = HEAT, 05 = WATER, ff = returns the
- nodes first supported alarm type.
+ nodes first supported alarm type.
Class SENSOR_BINARY
@@ -3608,7 +3643,7 @@ s2Hex($)
swmStatus
return the status of the node, as state:on, state:off or state:dim value.
-
+
Class THERMOSTAT_MODE
thermostatMode
request the mode
@@ -3648,7 +3683,7 @@ s2Hex($)
zwavePlusInfo
request the zwavePlusInfo
-
+
@@ -3740,7 +3775,7 @@ s2Hex($)
config_X:Y
Note: if the model is set (see MANUFACTURER_SPECIFIC get), then more
specific config messages are available.
-
+
Class DEVICE_RESET_LOCALLY
deviceResetLocally:yes
@@ -3766,7 +3801,7 @@ s2Hex($)
(VenetianBlindMode)
position:[%]
(RollerBlindMode)
-
+
Class MANUFACTURER_SPECIFIC
modelId:hexValue hexValue hexValue
model:manufacturerName productName
@@ -3795,16 +3830,16 @@ s2Hex($)
NOTE: "current 0 remain 0" means normal mode without timeout
powerlvlTest:node x status y frameAck z
NOTE: status 0=failed, 1=success (at least one ACK), 2=in progress
-
+
Class PROTECTION
protection:[on|off|seq]
Class SCENE_ACTIVATION
scene_Id:level finalValue
-
+
Class SCENE_ACTUATOR_CONF
scene_Id:level dimmingDuration finalValue
-
+
Class SCENE_CONTROLLER_CONF
group_Id:scene dimmingDuration
@@ -3814,7 +3849,7 @@ s2Hex($)
intended to generate event
Class SENSOR_ALARM
- alarm_type_X:level Y node $nodeID seconds $seconds
+ alarm_type_X:level Y node $nodeID seconds $seconds
Class SENSOR_BINARY
SENSORY_BINARY V1:
@@ -3906,7 +3941,7 @@ s2Hex($)
state:swmBeginUp
state:swmBeginDown
state:swmEnd
-
+
Class THERMOSTAT_MODE
off
cooling
@@ -3935,7 +3970,7 @@ s2Hex($)
wakeup:notification
wakeupReport:interval:X target:Y
wakeupIntervalCapabilitiesReport:min W max X default Y step Z
-
+
Class ZWAVEPLUS_INFO
zwavePlusInfo:version: V role: W node: X installerIcon: Y userIcon: Z