Ankündigung

Einklappen
Keine Ankündigung bisher.

Plugin: Multi-PWM zum Multi-RTR

Einklappen
Dieses Thema ist geschlossen.
X
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    [wiregate] Plugin: Multi-PWM zum Multi-RTR

    Hallo,

    ich nutze den Multi-RTR v0.6 aus dem openautomation SVN für 8 Räume mit jeweils Fußboden- und Wandheizung.
    Da ich keinen Heizungsaktor habe, sondern die Ventile über mehrere 1wire 8-fach Outputs ansteuere, habe ich einen PWM (stetig, DPT 5, 1 Byte) zu schalt (schaltend, DPT 1, 1 Bit) umsetzer-Plugin gebraucht.

    Klar ist das Plugin derzeit very basic, aber vielleicht ist es hier für jemanden von Nutzen.

    Config:
    ActuatorGA (Input): GA für den 1 Byte Wert aus dem Multi-RTR (deswegen heißt der Key hier gleich wie im Multi-RTR)
    SwitchGA (Output): GA für den Schalt-Kanal
    Invert: für normale (NC) Ventile 0, für NO-Ventile 1

    SwitchRRD (optional): Name eines RRD-Files für den Schaltzustand

    Global:
    CycleMinutes: Minuten pro PWM-Zyklus
    ResolutionPercent: Auflösung in %


    Schöne Grüße,

    Patrick

    Code:
    #############################################################################
    # Plugin: Multi-PWM
    #
    # @version 0.1
    # @copyright Copyright (c) 2011, Patrick Prasse
    # @license http://opensource.org/licenses/gpl-license.php GNU Public License
    #
    # Credits to Christian Mayer (mail at ChristianMayer.de) for his Multi-RTR plugin, which inspired this plugin
    # Credits to Michael Markstaller
    #
    
    #############################################################################
    # Configuration:
    my %controllers = (
      'Schlafzimmer'   => {
        'ActuatorGA' => '1/7/40',
        'SwitchGA'   => '1/7/41',
        'SwitchRRD' => 'Schlafzimmer_Switch',
        'Invert'        => 1,
      },
      'Bad'   => {
        'ActuatorGA' => '1/7/42',
        'SwitchGA'   => '1/7/43',
        'SwitchRRD' => 'Bad_Switch',
        'Invert'        => 1,
      },
    );
    
    my %default = (
      'CycleMinutes'  => 7.5,
      'ResolutionPercent' => 5,
    );
    
    
    # $plugin_info{$plugname.'_cycle'} wird unten dynamisch berechnet.
    
    use List::Util qw[min max];
    use POSIX;
    
    my $busActive = !(!keys %msg); # true if script was called due to bus traffic
    my $ret_val = '';
    
    if( !$busActive ) # unnecesary during bus traffic
    {
      my $min_cycle = 60;
      for my $this_controller_name ( keys %controllers )
      {
        my %this_controller = (%{$controllers{ $this_controller_name }}, %default);
        $min_cycle = ceil( min( $min_cycle, $this_controller{'CycleMinutes'}*60/100*$this_controller{'ResolutionPercent'} ) );
    
        $plugin_subscribe{ $this_controller{'ActuatorGA'} }{$plugname} = 1;
        if( !defined $plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'} )
        {
          $plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'} = 0;
        }
        if( !defined $plugin_info{$plugname.'_'.$this_controller_name.'_pwm_value'} )
        {
          $plugin_info{$plugname.'_'.$this_controller_name.'_pwm_value'} = 0;
        }
      }
      $plugin_info{$plugname.'_cycle'} = $min_cycle;
    }
    else
    {
      for my $this_controller_name ( keys %controllers )
      {
        my %this_controller = (%{$controllers{ $this_controller_name }}, %default);
        if( $msg{'apci'} eq "A_GroupValue_Write" and $msg{'dst'} eq $this_controller{'ActuatorGA'} )
        {
          if (!defined $msg{'value'})
          {
            # falls GA/DPT nicht importiert
            $msg{'value'} = decode_dpt5($msg{'data'});
          }
          $plugin_info{$plugname.'_'.$this_controller_name.'_pwm_value'} = $msg{'value'};
        }
      }
    }
    
    for my $this_controller_name ( keys %controllers )
    {
      my %this_controller = (%{$controllers{ $this_controller_name }}, %default);
    
      my $pct_per_sec = 1/($this_controller{'CycleMinutes'}*60/100);
      my $timediff = time() - $plugin_info{$plugname.'_tlast'};
      my $pctdiff = $timediff * $pct_per_sec;
      my $change_value;
    
      $plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'} += $pctdiff;
    #  $ret_val .= ' '.$this_controller_name.' pct_count='.$plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'};
    
      if( $plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'} >= 100 )
      {
        $plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'} = 0;
        if( $plugin_info{$plugname.'_'.$this_controller_name.'_pwm_value'} > 0 )
        {
          $change_value = 1;
        }
        else
        {
          $change_value = 0;
        }
      }
      else
      {
        if( $plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'} >= $plugin_info{$plugname.'_'.$this_controller_name.'_pwm_value'} )
        {
          $change_value = 0;
        }
      }
    
      if( defined $change_value )
      {
        if( defined $this_controller{ 'SwitchRRD' } )
        {
          update_rrd( $this_controller{ 'SwitchRRD' }, '', $change_value ? 10 : 0 );
        }
        if( $this_controller{ 'Invert' } )
        {
          knx_write( $this_controller{ 'SwitchGA' }, $change_value ? 0 : 1, 1 );
        }
        else
        {
          knx_write( $this_controller{ 'SwitchGA' }, $change_value ? 1 : 0, 1 );
        }
        $plugin_info{$plugname.'_'.$this_controller_name.'_last'} = $change_value;
      }
      $ret_val .= ' '.$this_controller_name.
        '('.$plugin_info{$plugname.'_'.$this_controller_name.'_pwm_value'}.'/'.$plugin_info{$plugname.'_'.$this_controller_name.'_pct_count'}.'): '.
        ($plugin_info{$plugname.'_'.$this_controller_name.'_last'} ? 'AN' : 'AUS').($this_controller{ 'Invert' } ? '-INVERT' : '');
    }
    
    $plugin_info{$plugname.'_tlast'} = time();
    
    return $ret_val;

    #2
    Sieht gut aus! Dann kann ich jetzt mal die eigenen RTR's endlich umstellen
    (ich hab ja auch keine "Heizungsaktoren", die % verstehen sondern SSR..)

    Makki
    EIB/KNX & WireGate & HS3, Russound,mpd,vdr,DM8000, DALI, DMX
    -> Bitte KEINE PNs!

    Kommentar


      #3
      Hallo,

      ich habe dein Plugin versucht.
      ich habe normale Thermoelektrische stellantriebe...
      Also Strom drauf = offen
      Strom weg = zu

      Also in deinem Plugin auf 0 gesetzt.

      Aus dem Multi RTR Plugin bekommt dein RTR Plugin die ventil Stelungen mit.
      Aber es steht immer auf aus. (hab jetzt 12 std mitgeloggt)
      Solltemp: 23°
      Isttemp: 21°

      Logeintrag:

      Code:
      2013-12-01 18:19:48.905,Multi-RTR, dt: 60.563; ,0s,
      2013-12-01 18:20:05.847,RTR, Wohnzimmer(0/73.5575008922154): AUS,0.3s,
      Wenn ich invert auf "1" Stelle dann hat es logischerweise immer offen...

      Ich hoffe du kannst mir weiterhelfen.

      Gruß Volker

      Kommentar

      Lädt...
      X