From d1ec8f88b41f99dfdc17f4293f89df7b02d964ec Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sun, 6 Aug 2017 09:40:09 +0000 Subject: [PATCH] 10_ZWave.pm: DOOR_LOCK_LOGGING implementation by Zephyr (Forum #75068) git-svn-id: https://svn.fhem.de/fhem/trunk@14853 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_ZWave.pm | 123 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/10_ZWave.pm b/fhem/FHEM/10_ZWave.pm index b98747de0..ddd20bd64 100755 --- a/fhem/FHEM/10_ZWave.pm +++ b/fhem/FHEM/10_ZWave.pm @@ -265,7 +265,11 @@ my %zwave_class = ( RATE_TBL_MONITOR => { id => '49' }, TARIFF_CONFIG => { id => '4a' }, TARIFF_TBL_MONITOR => { id => '4b' }, - DOOR_LOCK_LOGGING => { id => '4c' }, + DOOR_LOCK_LOGGING => { id => '4c', + get => { doorLockLoggingRecordsSupported => '01', + doorLockLoggingRecord => '03%02x' }, + parse => { "034c02(.*)" => '"doorLockLoggingRecordsSupported:".hex($val)', + "..4c04(.*)" => 'ZWave_doorLLRParse($hash, $1)'} }, NETWORK_MANAGEMANT_BASIC => { id => '4d' }, SCHEDULE_ENTRY_LOCK => { id => '4e', # V1, V2, V3 get => { scheduleEntryLockTypeSupported => '09', @@ -2343,6 +2347,99 @@ ZWave_mfsParse($$$$$) return sprintf("model:0x%s 0x%s 0x%s", $mf, $prod, $id); } +sub +ZWave_doorLLRParse($$) +{ + my ($hash, $val) = @_; + my $result; + my $name = $hash->{NAME}; + my @eventTypeHash = ( 'none', #not defined + 'Lock Command: Keypad access code verified lock command', #evtT 1 + 'Unlock Command: Keypad access code verified unlock command', #evtT 2 + 'Lock Command: Keypad lock button pressed', #evtT 3 + 'Unlock command: Keypad unlock button pressed', #evtT 4 + 'Lock Command: Keypad access code out of schedule', #evtT 5 + 'Unlock Command: Keypad access code out of schedule', #evtT 6 + 'Keypad illegal access code entered', #evtT 7 + 'Key or latch operation locked (manual)', #evtT 8 + 'Key or latch operation unlocked (manual)', #evtT 9 + 'Auto lock operation', #evtT 10 + 'Auto unlock operation', #evtT 11 + 'Lock Command: Z-Wave access code verified', #evtT 12 + 'Unlock Command: Z-Wave access code verified', #evtT 13 + 'Lock Command: Z-Wave (no code)', #evtT 14 + 'Unlock Command: Z-Wave (no code)', #evtT 15 + 'Lock Command: Z-Wave access code out of schedule', #evtT 16 + 'Unlock Command Z-Wave access code out of schedule', #evtT 17 + 'Z-Wave illegal access code entered', #evtT 18 + 'Key or latch operation locked (manual)', #evtT 19 + 'Key or latch operation unlocked (manual)', #evtT 20 + 'Lock secured', #evtT 21 + 'Lock unsecured', #evtT 22 + 'User code added', #evtT 23 + 'User code deleted', #evtT 24 + 'All user codes deleted', #evtT 25 + 'Master code changed', #evtT 26 + 'User code changed', #evtT 27 + 'Lock reset', #evtT 28 + 'Configuration changed', #evtT 29 + 'Low battery', #evtT 30 + 'New Battery installed', #evtT 31 + ); + # |- $recordNumber + # | |- $timestampYear + # | | |- $timestampMonth + # | | | |- $timestampDay + # | | | | |- $recordStatusTimestampHour + # | | | | | |- $timestampMinute + # | | | | | | |- $timestampSecond + # | | | | | | | |- $eventType + # | | | | | | | | |- $userIdentifier + # | | | | | | | | | |- $userCodeLength + # 20 07e1 07 1f 34 28 2b 08 00 00 + if( $val =~ /^(..)(....)(..)(..)(..)(..)(..)(..)(..)(..)/ ) { + my $recordNumber = hex($1); + my $timestampYear = hex($2); + my $timestampMonth = hex($3); + my $timestampDay = hex($4); + my $recordStatusTimestampHour = sprintf( "%b", hex($5) ); + my $recordStatus = substr $recordStatusTimestampHour, 0, 1; + $recordStatus = oct( "0b$recordStatus" ); + my $timestampHour = substr $recordStatusTimestampHour, 1, 5; + $timestampHour = oct( "0b$timestampHour" ); + my $timestampMinute = hex($6); + my $timestampSecond = hex($7); + my $eventTypeNumber = hex($8); + my $userIdentifier = hex($9); + my $userCodeLength = hex($10); + + my $timestamp = sprintf ("%4d-%02d-%02d %02d:%02d:%02d", + $timestampYear,$timestampMonth,$timestampDay,$timestampHour, + $timestampMinute,$timestampSecond); + + $result = "doorLockLoggingRecord:". + "recordNr: $recordNumber ". + "recordStatus: $recordStatus ". + "eventType: $eventTypeHash[$eventTypeNumber] ". + "userIdentifier: $userIdentifier ". + "userCodeLength: $userCodeLength ". + "timestamp: $timestamp"; + } + + # |- $userCode + # 20 07e1 07 1f 34 28 2b 08 00 00 3132333435 + if( $val =~ /^(..)(....)(..)(..)(..)(..)(..)(..)(..)(..)(.+)/ ) { + my $userCode = "recieved but not saved."; + $result .= " USER_CODE: $userCode"; + } + + if( $result ne '' ) { + return $result; + } else { + return "doorLockLoggingRecord:$val"; + } +} + my @zwave_wd = ("none","mon","tue","wed","thu","fri","sat","sun"); sub @@ -5066,7 +5163,11 @@ s2Hex($)