From b2a2cc1313adbae686b406ea641ecb7141628d99 Mon Sep 17 00:00:00 2001 From: Byte009 <34764406+Byte009@users.noreply.github.com> Date: Thu, 13 Jun 2019 18:53:40 +0200 Subject: [PATCH] Add files via upload --- FHEM/98_Siro.pm | 149 +++++++++--------------------------------------- 1 file changed, 28 insertions(+), 121 deletions(-) diff --git a/FHEM/98_Siro.pm b/FHEM/98_Siro.pm index 4925240..e6afa0d 100644 --- a/FHEM/98_Siro.pm +++ b/FHEM/98_Siro.pm @@ -2,7 +2,7 @@ # # Siro module for FHEM # Thanks for templates/coding from SIGNALduino team and Jarnsen_darkmission_ralf9 -# +# Thanks to Dr. Smagmag for decoding the protocol, which made this module possible # Needs SIGNALduino. # Published under GNU GPL License, v2 # History: @@ -289,11 +289,7 @@ sub Define($$) { $hash->{MODEL} = "LE-serie"; $modules{Siro}{defptr}{$devpointer} = $hash; AssignIoPort($hash); - - # CommandAttr( undef,$name . ' devStateIcon {if (ReadingsVal( $name, \'state\', \'undef\' ) =~ m/[a-z]/ ) { return \'programming:edit_settings notAvaible:hue_room_garage runningUp.*:fts_shutter_up runningDown.*:fts_shutter_down\'}else{return \'[0-9]{1,3}:fts_shutter_1w_\'.(int($state/10)*10)}}' ) - # if ( AttrVal($name,'devStateIcon','none') eq 'none' ); - # attributliste anlegen if ($hash->{CHANNEL_RECEIVE} eq '0') @@ -313,21 +309,16 @@ sub Define($$) { setDevAttrList($name, $hash->{AttrList}); $hash->{MODEL} = "LE-Device"; } - - + my $webcmd = "webCmd stop:open:close:fav:pct"; $webcmd = "webCmd stop:open:close:fav" if $hash->{CHANNEL_RECEIVE} eq '0'; - - - + CommandAttr( undef,$name . ' devStateIcon {return FHEM::Siro::Siro_icon($name)}' ) if ( AttrVal($name,'devStateIcon','none') eq 'none' ); - - + CommandAttr(undef,$name . ' '.$webcmd) if ( AttrVal($name,'webCmd','none') eq 'none' ); - - + Log3( $name, 5, "Siro_define: angelegtes Device - code -> $code name -> $name hash -> $hash " ); } @@ -384,27 +375,24 @@ sub SendCommand($@) { my $command = $siro_c2b{$cmd}; my $io = $hash->{IODev}; # IO-Device (SIGNALduino) - #if ( $hash->{helper}{exexcmd} eq "off") # send kommand blockiert / keine ausf?hrung if ( defined($hash->{helper}{exexcmd}) and $hash->{helper}{exexcmd} eq "off") # send kommand blockiert / keine ausf?hrung { - Log3( $name, 5,"Siro_sendCommand: ausf?hrung durch helper blockiert "); + Log3( $name, 5,"Siro_sendCommand: ausfuehrung durch helper blockiert "); return; - } - #if ( $hash->{helper}{ignorecmd} eq "on") # send kommand blockiert / keine ausf?hrung if ( defined($hash->{helper}{ignorecmd}) and $hash->{helper}{ignorecmd} eq "on") # send kommand blockiert / keine ausf?hrung { - Log3( $name, 5,"Siro_sendCommand: ausführung einmalig blockiert "); + Log3( $name, 5,"Siro_sendCommand: ausfuehrung einmalig blockiert "); delete( $hash->{helper}{ignorecmd} ); return; } - #Log3( $name, 5,"Siro_sendCommand: args1 - $args[1]"); + Log3( $name, 5,"Siro_sendCommand: args1 - $args[1]"); - if ( defined($args[1]) and $args[1] eq "longstop" || defined $hash->{helper}{progmode} and $hash->{helper}{progmode} eq "on") + if ( (defined($args[1]) and $args[1] eq "longstop" )|| (defined $hash->{helper}{progmode} and $hash->{helper}{progmode} eq "on")) { $SignalRepeats = AttrVal( $name, 'SIRO_signalLongStopRepeats', '15' ); } @@ -412,18 +400,16 @@ sub SendCommand($@) { { $SignalRepeats = AttrVal( $name, 'SIRO_signalRepeats', '10' ); } - + + Log3( $name, 5,"Siro_sendCommand: repeats - $SignalRepeats"); + $chan = AttrVal( $name, 'SIRO_send_channel', undef ); if ( !defined($chan) ) { $chan = $hash->{CHANNEL_RECEIVE}; } - $binChannel = sprintf( "%04b", $chan ); - my $value = $name . " " . join( " ", @args ); - - my $sendid = AttrVal( $name, 'SIRO_send_id', 'undef' ); if ( $sendid eq 'undef') { @@ -432,12 +418,7 @@ sub SendCommand($@) { else{ $binHash = sprintf( "%028b", hex( $sendid ) ); } - - - - Log3 $io, 5, "Siro_sendCommand: BinHash: = $binHash"; - $binCommand = sprintf( "%08b", hex($command) ); Log3 $io, 5, "Siro_sendCommand: BinCommand: = $binCommand"; @@ -469,12 +450,8 @@ sub Parse($$) { if ( my $lh = $modules{Siro}{defptr}{$testid} ) { my $name = $lh->{NAME}; - # Log3 $hash, 5,"Siro_Parse: Incomming msg from IODevice $testid - $name device is defined"; - - - # if ( defined($name)&& $testcmd ne "54")# prüfe auf doppele msg falls gerät vorhanden und cmd nicht stop - if ( defined($name)&& $testcmd ne "54")# pr?fe auf doppele msg falls ger?t vorhanden und cmd nicht stop - + + if ( defined($name)&& $testcmd ne "54")# pr?fe auf doppele msg falls ger?t vorhanden und cmd nicht stop { Log3 $lh, 5,"Siro_Parse: Incomming msg $msg from IODevice name/DEF $testid - Hash -> $lh"; @@ -583,17 +560,14 @@ sub Parse($$) { } } - Log3( $name, 5, "Siro Parse Befehl: $newstate"); - - + Log3( $name, 5, "Siro Parse Befehl: $newstate"); + if ($lh->{helper}{progmode} eq "on") { Log3( $name, 4, "Siro Parse deactivated cause off programmingmode"); return; } - - if ( defined($name) ) {#device vorhanden my $parseaborted = 0; $lh->{helper}{parse_aborted} = $parseaborted; @@ -608,17 +582,10 @@ sub Parse($$) { { $lh->{helper}{remotecmd} = "on"; #verhindert das senden von signalen nur wenn nicht auf anderem kanal gesendet wird } - - - + my $aktstate = ReadingsVal( $name, 'state', '0' ); my $lock =ReadingsVal( $name, 'remote_lock', 'off' ); - - #if (($lock ne 'on') or ($lock eq 'on' and ($aktstate ne '0' and $aktstate ne '100'))) - #{ - - if ($defchannnel ne '0') { Set( $lh, $name, $newstate ); @@ -627,14 +594,10 @@ sub Parse($$) { Log3 $lh, 5, "Siro_Parse: eingehender Gruppenbefehl , weiterleitung an deviceverteiler"; Log3 $lh, 5, "Siro_Parse: eingehender Gruppenbefehl $newstate"; readingsSingleUpdate( $lh, "ActionTrigger", "remote", 1 ); - Distributor($name.' '.$newstate.' '.$testcmd); - return $name; } - - - + Log3 $lh, 5, "Siro_Parse: hash->{helper}{remotecmd} - ".$lh->{helper}{remotecmd}; Log3( $name, 3, "Siro-Parse ($name) : Signal FB emfangen - $newstate"); Log3( $name, 5, "Siro-Parse ($name) : test remote_lock - $lock"); @@ -648,10 +611,7 @@ sub Parse($$) { $lh->{helper}{savedcmds}{cmd1} = 'close' if $aktstate eq "100" ; $lh->{helper}{savedcmds}{cmd2} = $aktstate; # invers noch zu berücksichtigen - InternalTimer( (time + 0.5), "FHEM::Siro::Restartset", "$name" ); - - } return $name; } @@ -732,9 +692,7 @@ sub Set($@) { return "" if ( IsDisabled($name) ); $hash->{helper}{progmode} = "off" if !defined $hash->{helper}{progmode}; - - - + # versionschange #changeconfig @@ -744,18 +702,12 @@ sub Set($@) { } # pruefe auf unbekannte sets - if ( $cmd =~ m/^exec.*/ )# empfangene sequenz aus programmiermode { $args[1] = $cmd; $cmd = "sequenz"; } - - - - - #Log3( $name, 0, "SiroTEST $name ".$hash->{CHANNEL_RECEIVE}); - + if ($defchannnel eq '0') { %sets = %setszero; @@ -763,8 +715,7 @@ sub Set($@) { else { %sets = %setsstandart; } - - + if ( !exists( $sets{$cmd} ) ) { my @cList; my $atts = AttrVal( $name, 'setList', "" ); @@ -798,10 +749,7 @@ sub Set($@) { SendCommand( $hash, $sendCommands{$cmd} ); return; } - - - - + ############################# # programmiermodus @@ -828,8 +776,6 @@ sub Set($@) { } if ($cmd eq "prog_mode_on" && $hash->{helper}{progmode} ne "on") - - { readingsSingleUpdate( $hash, "state", 'programming', 1 ); $hash->{helper}{progmode} = "on"; @@ -887,17 +833,12 @@ sub Set($@) { $aktcmdfrom = "remote"; } ############################# - readingsBeginUpdate($hash); - readingsBulkUpdate( $hash, "ActionTrigger", $aktcmdfrom, 1 ); - readingsBulkUpdate( $hash, "LastActionTime", $lastactiontime, 0 ); readingsBulkUpdate( $hash, "BetweentActionTime", $betweentime, 0 ); readingsBulkUpdate( $hash, "ActionTime", $actiontime, 0 ); - readingsEndUpdate($hash, 1); - - + readingsEndUpdate($hash, 1); # befehl aus %sendCommands ermitteln my $comand = $sendCommands{$cmd}; # auzuf?hrender befehl Log3( $name, 5, "Siro-Set: ermittelter Befehl: $comand " ); @@ -939,9 +880,7 @@ sub Set($@) { readingsSingleUpdate( $hash, "remote_lock", $args[1], 1 ) ; return; } - - - + ############################# # set reset_motor_term reset_motor_term if ($comand eq "reset_motor_term") @@ -1052,18 +991,13 @@ sub Set($@) { { $comand = "on" if AttrVal( $name, 'SIRO_inversPosition',0 ) eq "0"; $comand = "off" if AttrVal( $name, 'SIRO_inversPosition',0 ) eq "1"; - Log3( $name, 4, "Siro-Set: mapping level 100 - on"); } - - - - + if ($comand eq "level" and $zielposition eq "0") { $comand = "off" if AttrVal( $name, 'SIRO_inversPosition',0 ) eq "0"; $comand = "on" if AttrVal( $name, 'SIRO_inversPosition',0 ) eq "1"; - Log3( $name, 4, "Siro-Set: mapping level 0 - off"); } @@ -1182,8 +1116,6 @@ sub Set($@) { Log3( $name, 3, "Siro-Set ($name) : set Down"); if ($downtime eq "undef" || $uptime eq "undef") # bei ungesetzten fahrzeiten { - - readingsBeginUpdate($hash); readingsBulkUpdate( $hash, "state", "100" ) ; readingsBulkUpdate( $hash, "pct", "100" ) ; @@ -1191,9 +1123,6 @@ sub Set($@) { readingsBulkUpdate( $hash, "LastAction", $comand ); readingsEndUpdate( $hash, 1); SendCommand( $hash, 'on' ); - - #return; - } if ($state eq "undef" || $state eq "notAvaible") { $state = 0; } my $waytodrive = 100 - $state; @@ -1219,11 +1148,9 @@ sub Set($@) { if ($comand eq "on") { readingsSingleUpdate( $hash, "state", "runningDown" , 1 ) ; - # internen timer setzen runningtime - dann states setzen Log3( $name, 5, "Siro-Set: setze state down , setze Timer - $comand"); InternalTimer( $endaction, "FHEM::Siro::Finish", "$name" ); - } else{ readingsSingleUpdate( $hash, "state", "runningDownfortimer" , 1 ) ; @@ -1252,16 +1179,10 @@ sub Set($@) { # if ($state eq "undef" || $state eq "notAvaible") { $state = 100; } - my $waytodrive = 0 + $state; if (AttrVal( $name, 'SIRO_inversPosition',0 ) eq "1"){$waytodrive = 0 + (100- $state);} - my $timetodrive = $waytodrive * $up1time; - - my $endaction = time + $timetodrive; - - Log3( $name, 5, "Siro-Set: off downtime - waytodrive $waytodrive"); Log3( $name, 5, "Siro-Set: off downtime - state $state"); Log3( $name, 5, "Siro-Set: off downtime - up1time $up1time"); @@ -1488,7 +1409,7 @@ sub versionchange($) { CommandAttr(undef,$name . ' SIRO_inversPosition ' . $attr) if ( AttrVal($name,'invers_position','undef') ne 'undef' ); fhem("deleteattr $name invers_position"); - CommandAttr( undef,$name . ' devStateIcon {if (ReadingsVal( $name, \'state\', \'undef\' ) =~ m/[a-z]/ ) { return \'programming:edit_settings notAvaible:hue_room_garage runningUp.*:fts_shutter_up runningDown.*:fts_shutter_down\'}else{return \'[0-9]{1,3}:fts_shutter_1w_\'.(int($state/10)*10)}}' ); + CommandAttr( undef,$name . ' devStateIcon {return FHEM::Siro::Siro_icon($name)}' ); CommandAttr(undef,$name . ' webCmd stop:open:close:fav:pct'); $attr = AttrVal($name,'operation_mode','undef'); @@ -1668,19 +1589,13 @@ sub Siro_icon($) my ($name) = @_; my $hash = $defs{$name}; my $state = ReadingsVal( $name, 'state', 'undef' ); - - + if ($state =~ m/[a-z].*/){$state=0;} - - + my $invers = AttrVal( $name, 'SIRO_inversPosition',0 ); my $ret ="programming:edit_settings notAvaible:hue_room_garage runningUp.*:fts_shutter_up runningDown.*:fts_shutter_down ".$state.":fts_shutter_1w_".(int($state/10)*10); - $ret ="programming:edit_settings notAvaible:hue_room_garage runningUp.*:fts_shutter_up runningDown.*:fts_shutter_down ".$state.":fts_shutter_1w_".(100 - (int($state/10)*10)) if $invers eq "1"; - - $ret =".*:fts_shutter_all" if ($hash->{CHANNEL_RECEIVE} eq '0'); - return $ret; } @@ -1698,9 +1613,6 @@ sub Distributor($) { my @devicelist = devspec2array($devspec); shift @devicelist; my $devicelist = join(" ",@devicelist); - - - #Log3( $name, 5, "Siro-Distributor : betroffene devices - @list"); my $owndef = $hash->{ID}; Log3( $name, 5, "Siro-Distributor : own DEF - ".$owndef); @@ -1724,12 +1636,7 @@ sub Distributor($) { readingsSingleUpdate( $hash, "LastAction", $arg, 1 ); readingsSingleUpdate( $hash, "state", $arg, 1 ); readingsSingleUpdate( $hash, "GroupDevices", $devicelist, 1 ); - - - - - delete( $hash->{Signalduino_RAWMSG} ); delete( $hash->{Signalduino_MSGCNT} ); delete( $hash->{Signalduino_RSSI} );