From 8bb52539c25afd2da869156989451b18b19ce8b4 Mon Sep 17 00:00:00 2001 From: Byte009 <34764406+Byte009@users.noreply.github.com> Date: Fri, 31 May 2019 08:45:08 +0200 Subject: [PATCH] Add files via upload --- FHEM/98_Siro.pm | 110 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 83 insertions(+), 27 deletions(-) diff --git a/FHEM/98_Siro.pm b/FHEM/98_Siro.pm index 1d4de31..4a26fcd 100644 --- a/FHEM/98_Siro.pm +++ b/FHEM/98_Siro.pm @@ -1,4 +1,4 @@ -# $Id: 98_Siro.pm 16472 2018-03-23 15:03:57Z Byte09 $ +# $Id: 98_Siro.pm 19490 2019-05-30 07:05:46Z Byte09 $ # # Siro module for FHEM # Thanks for templates/coding from SIGNALduino team and Jarnsen_darkmission_ralf9 @@ -41,16 +41,20 @@ sub Siro_Initialize($) { . " SIRO_signalRepeats:1,2,3,4,5,6,7,8,9" . " SIRO_inversPosition:0,1" . " SIRO_Battery_low" + . " SIRO_downLimit:slider,0,1,100" . " SIRO_signalLongStopRepeats:10,15,20,40,45,50" . " $readingFnAttributes" . " SIRO_send_channel:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" + + + . " SIRO_send_id" . " SIRO_time_to_open" . " SIRO_time_to_close" . " SIRO_debug:0,1" #oldversion entfernen mit kommender version - + # . " SIRO_channel:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" . " SignalRepeats:1,2,3,4,5,6,7,8,9" . " SignalLongStopRepeats:10,15,20,40,45,50" . " channel_send_mode_1:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15" @@ -148,6 +152,7 @@ my %sets = ( "prog_mode_off" => "noArg", "reset_motor_term" => "noArg", "pct" => "slider,0,1,100", # Wird nur bei vorhandenen time_to attributen gesetzt + "position" => "slider,0,1,100", # Wird nur bei vorhandenen time_to attributen gesetzt "state" => "noArg", "set_favorite" => "noArg", "del_favorite" => "only_modul,only_shutter,shutter_and_modul", @@ -159,6 +164,7 @@ my %sets = ( my %sendCommands = ( "pct" => "level", "level" => "level", + "position" => "level", "stop" => "stop", "off" => "off", "on" => "on", @@ -291,6 +297,17 @@ sub SendCommand($@) { return; } + + if ( $hash->{helper}{ignorecmd} eq "on") # send kommand blockiert / keine ausf?hrung + { + Log3( $name, 5,"Siro_sendCommand: ausführung einmalig blockiert "); + + delete( $hash->{helper}{ignorecmd} ); + return; + + } + + Log3( $name, 5,"Siro_sendCommand: args1 - $args[1]"); @@ -338,8 +355,8 @@ sub SendCommand($@) { IOWrite( $hash, 'sendMsg', $message ) if AttrVal( $name, 'SIRO_debug', "0" ) ne "1"; Log3( $name, 5, -"Siro_sendCommand: name -> $name command -> $cmd channel -> $chan bincmd -> $binCommand bin -> $bin - message -> $message"); +"Siro_sendCommand: name-$name command-$cmd channel-$chan bincmd-$binCommand bin-$bin id-$sendid + message-$message"); return $ret; } @@ -669,8 +686,8 @@ sub Set($@) { # setze actiontime und lastactiontime # umbauen zu bulk update RemoveInternalTimer($name); #alle vorhandenen timer l?schen - delete( $hash->{helper}{exexcmd} ); # on/off off blockiert befehlsausf?hrung / l?schen vor jedem durchgang - + #delete( $hash->{helper}{exexcmd} ); # on/off off blockiert befehlsausf?hrung / l?schen vor jedem durchgang + $hash->{helper}{exexcmd}="on"; #setze helper neu wenn signal von fb kommt if ($hash->{helper}{remotecmd} eq "on") @@ -684,11 +701,43 @@ sub Set($@) { readingsBulkUpdate( $hash, "LastActionTime", $lastactiontime, 0 ); readingsBulkUpdate( $hash, "BetweentActionTime", $betweentime, 0 ); readingsEndUpdate($hash, 1); + + # befehl aus %sendCommands ermitteln my $comand = $sendCommands{$cmd}; # auzuf?hrender befehl Log3( $name, 5, "Siro-Set: ermittelter Befehl: $comand " ); - - + + ############################### + # limit testen , falls limit wird on zu level limit + my $downlimit = AttrVal( $name, 'SIRO_downLimit','undef' ) ; + if ($downlimit ne "undef" && ($comand eq 'on' || $comand eq 'level') && $hash->{helper}{exexcmd} ne "off") + # nur wenn befehl nicht von fb kommt + { + if (!defined $zielposition){$zielposition = 100} + if ( $position < $downlimit ) + { + $comand = 'level'; + $zielposition = $downlimit; + } + my $sendchan = AttrVal( $name, 'SIRO_send_channel', 'undef' ); + if ( $sendchan ne $hash->{CHANNEL_RECEIVE} && $position >= $downlimit ) + { + return; + } + } +################## + if ($downlimit ne "undef" && ($comand eq 'on' || $comand eq 'level') && $hash->{helper}{exexcmd} eq "off") + # nur wenn befehl von fb kommt + { + if ( $position < $downlimit ) + { + delete( $hash->{helper}{exexcmd} ); + $hash->{helper}{ignorecmd} ="on"; + $comand = 'level'; + $zielposition = $downlimit; + } + } +############################ # set reset_motor_term reset_motor_term if ($comand eq "reset_motor_term") { @@ -697,7 +746,7 @@ sub Set($@) { return; } - # pr?fe auf laufende aktion nur bei definierten laufzeiten + # pruefe auf laufende aktion nur bei definierten laufzeiten # wenn vorhanden neuberechnung aller readings if ($aktendaction > time && ($downtime ne "undef" || $uptime ne "undef")) { @@ -737,6 +786,7 @@ sub Set($@) { readingsBeginUpdate($hash); readingsBulkUpdate( $hash, "state", $newposition ) ; readingsBulkUpdate( $hash, "pct", $newposition ) ; + readingsBulkUpdate( $hash, "position", $newposition) ; readingsBulkUpdate( $hash, "aktRunningAction", "noAction" ) ; readingsBulkUpdate( $hash, "aktEndAction", 0 ) ; readingsBulkUpdate( $hash, "aktTimeAction", 0 ) ; @@ -1096,6 +1146,7 @@ sub Finish($) { readingsBeginUpdate($hash); readingsBulkUpdate( $hash, "state", $state ) ; readingsBulkUpdate( $hash, "pct", $state ) ; + readingsBulkUpdate( $hash, "position", $state ) ; readingsBulkUpdate( $hash, "aktRunningAction", "noAction" ) ; readingsBulkUpdate( $hash, "aktEndAction", 0 ) ; readingsBulkUpdate( $hash, "aktTimeAction", 0 ) ; @@ -1111,7 +1162,7 @@ sub Restartset($) { my ( $name, $arg ) = split( / /, $input ); my $hash = $defs{$name}; return "" if ( IsDisabled($name) ); - Log3( $name, 5, "Siro-Restartset : aufgerufen"); + Log3( $name, 0, "Siro-Restartset : aufgerufen"); my $cmd = $hash->{helper}{savedcmds}{cmd1}; my $pos = $hash->{helper}{savedcmds}{cmd2}; delete( $hash->{helper}{savedcmds} ); @@ -1175,6 +1226,7 @@ sub versionchange($) { readingsBeginUpdate($hash); readingsBulkUpdate( $hash, "state", "0" ); readingsBulkUpdate( $hash, "pct", "0" ) ; + readingsBulkUpdate( $hash, "position", "0" ) ; readingsBulkUpdate( $hash, "motor-term", $seconds ) ; readingsEndUpdate( $hash, 1 ); @@ -1230,7 +1282,7 @@ my ( $FW_wname, $d, $room, $pageHash ) =@_; # pageHash is set for summaryFn. $msg.= $sendid ; } $msg.= " und dem Kanal: "; - my $sendchan = AttrVal( $name, 'SIRO_send_channel', 'undef' ); + my $sendchan = AttrVal( $name, 'SIRO_send_channel', 'undef' ); if ( $sendchan eq 'undef') { $msg.= $hash->{CHANNEL_RECEIVE} ; @@ -1446,25 +1498,20 @@ set Siro1 progmode_on enable the programming mode
=end html - - - =begin html_DE - -

Siro protocol


@@ -1505,7 +1552,7 @@ Ein Autocreate (falls aktiviert), legt das Device mit der ID der Fernbedienung u set_favorite del_favorite - + Beispiele:


- + Hinweise:

+ +
- Get + Get
Attributes

=end html_DE + + + =cut \ No newline at end of file