FHEM Forum

FHEM - Hausautomations-Systeme => RFXTRX => Thema gestartet von: KernSani am 09 September 2016, 00:07:53

Titel: Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: KernSani am 09 September 2016, 00:07:53
Hi,

nachdem ich gerade gelernt habe, dass TRX beim initialisieren ein paar sehr sinnvolle Statusmeldungen ins Log schreibt, habe ich ein wenig experimentiert und quick&dirty 45_TRX um ein paar readings ergänzt (siehe Screenshot). Könnte man sowas in den Standard einbauen? Ich fände es recht hilfreich im IODevice auf die Schnelle zu sehen, welche Protokolle aktiv sind, etc...?

Danke,

Grüße,

Oli
Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: KernSani am 09 September 2016, 00:38:42
Da mir gerade nichts Dümmeres eingefallen ist, habe ich kurz eine Routine für 99_myUtils.pm gebastelt (im wesentlichen aus 45_TRX kopiert), die die oben dargestellten readings erzeugt...

sub myUtils_getTRXStatus($) {
my($name) = @_;
my $trx = $defs{$name};

my $freq = "";
my $protocols = "";
my $firmware = "";

# Get Status
my $init = pack('H*', "0D00000102000000000000000000");
DevIo_SimpleWrite($trx, $init, 0);
usleep(50000); # wait 50 ms
my $buf = unpack('H*',DevIo_TimeoutRead($trx, 0.2));

    if (! $buf) {
      Log3 $name, 1, "TRX: Initialization Error: No character read";
      return "TRX: Initialization Error $name: no char read";
    } elsif ($buf !~ m/0d0100....................../ && $buf !~ m/140100..................................../) {
      Log3 $name, 1, "TRX: Initialization Error hexline='$buf', expected 0d0100......................";
      return "TRX: Initialization Error %name expected 0D010, but buf=$buf received.";
    } else {
      Log3 $name,1, "TRX: Init OK";

      # Analyse result and display it:
      if ($buf =~ m/0d0100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/) {
        my $status = "";

        my $seqnbr = $1;
        my $cmnd = $2;
        my $msg1 = $3;
        my $msg2 = ord(pack('H*', $4));
        my $msg3 = ord(pack('H*', $5));
        my $msg4 = ord(pack('H*', $6));
        my $msg5 = ord(pack('H*', $7));
        $freq = {
        '50' => '310MHz',
        '51' => '315MHz',
        '52' => '433.92MHz receiver only',
        '53' => '433.92MHz transceiver',
        '55' => '868.00MHz',
        '56' => '868.00MHz FSK',
        '57' => '868.30MHz',
        '58' => '868.30MHz FSK',
        '59' => '868.35MHz',
        '5a' => '868.35MHz FSK',
        '5b' => '868.95MHz'
                 }->{$msg1} || 'unknown Mhz';
        $firmware = $msg2;
        $protocols .= "undecoded " if ($msg3 & 0x80);
        $protocols .= "RFU " if ($msg3 & 0x40);
        $protocols .= "ByronSX " if ($msg3 & 0x20);
        $protocols .= "RSL " if ($msg3 & 0x10);
        $protocols .= "Lighting4 " if ($msg3 & 0x08);
        $protocols .= "FineOffset/Viking " if ($msg3 & 0x04);
        $protocols .= "Rubicson " if ($msg3 & 0x02);
        $protocols .= "AE/Blyss " if ($msg3 & 0x01);
        $protocols .= "BlindsT1/T2/T3/T4 " if ($msg4 & 0x80);
        $protocols .= "BlindsT0  " if ($msg4 & 0x40);
        $protocols .= "ProGuard " if ($msg4 & 0x20);
        $protocols .= "FS20 " if ($msg4 & 0x10);
        $protocols .= "LaCrosse " if ($msg4 & 0x08);
        $protocols .= "Hideki " if ($msg4 & 0x04);
        $protocols .= "LightwaveRF " if ($msg4 & 0x02);
        $protocols .= "Mertik " if ($msg4 & 0x01);
        $protocols .= "Visonic " if ($msg5 & 0x80);
        $protocols .= "ATI " if ($msg5 & 0x40);
        $protocols .= "OREGON " if ($msg5 & 0x20);
        $protocols .= "KOPPLA " if ($msg5 & 0x10);
        $protocols .= "HOMEEASY " if ($msg5 & 0x08);
        $protocols .= "AC " if ($msg5 & 0x04);
        $protocols .= "ARC " if ($msg5 & 0x02);
        $protocols .= "X10 " if ($msg5 & 0x01);
      }
      # Since 1001
      if ($buf =~ m/140100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/) {
        my $status = "";

        my $seqnbr = $1;
        my $cmnd = $2;
        my $msg1 = $3;
        my $msg2 = ord(pack('H*', $4));
        my $msg3 = ord(pack('H*', $5));
        my $msg4 = ord(pack('H*', $6));
        my $msg5 = ord(pack('H*', $7));
        my $msg6 = ord(pack('H*', $8));
        $freq = {
        '50' => '310MHz',
        '51' => '315MHz',
        '52' => '433.92MHz receiver only',
        '53' => '433.92MHz transceiver',
        '55' => '868.00MHz',
        '56' => '868.00MHz FSK',
        '57' => '868.30MHz',
        '58' => '868.30MHz FSK',
        '59' => '868.35MHz',
        '5a' => '868.35MHz FSK',
        '5b' => '868.95MHz'
                 }->{$msg1} || 'unknown Mhz';
        $firmware = $msg2+1000;
$protocols .= "undecoded " if ($msg3 & 0x80);
        $protocols .= "RFU " if ($msg3 & 0x40);
        $protocols .= "ByronSX " if ($msg3 & 0x20);
        $protocols .= "RSL " if ($msg3 & 0x10);
        $protocols .= "Lighting4 " if ($msg3 & 0x08);
        $protocols .= "FineOffset/Viking " if ($msg3 & 0x04);
        $protocols .= "Rubicson " if ($msg3 & 0x02);
        $protocols .= "AE/Blyss " if ($msg3 & 0x01);
        $protocols .= "BlindsT1/T2/T3/T4 " if ($msg4 & 0x80);
        $protocols .= "BlindsT0  " if ($msg4 & 0x40);
        $protocols .= "ProGuard " if ($msg4 & 0x20);
        $protocols .= "FS20 " if ($msg4 & 0x10);
        $protocols .= "LaCrosse " if ($msg4 & 0x08);
        $protocols .= "Hideki " if ($msg4 & 0x04);
        $protocols .= "LightwaveRF " if ($msg4 & 0x02);
        $protocols .= "Mertik " if ($msg4 & 0x01);
        $protocols .= "Visonic " if ($msg5 & 0x80);
        $protocols .= "ATI " if ($msg5 & 0x40);
        $protocols .= "OREGON " if ($msg5 & 0x20);
        $protocols .= "KOPPLA " if ($msg5 & 0x10);
        $protocols .= "HOMEEASY " if ($msg5 & 0x08);
        $protocols .= "AC " if ($msg5 & 0x04);
        $protocols .= "ARC " if ($msg5 & 0x02);
        $protocols .= "X10 " if ($msg5 & 0x01);
        $protocols .= "HomeComfort " if ($msg6 & 0x02);
        $protocols .= "KEELOQ " if ($msg6 & 0x01);
      }
    readingsSingleUpdate($trx, "frequency", $freq, 1);
readingsSingleUpdate($trx, "firmware", $firmware, 1);
readingsSingleUpdate($trx, "protocols", $protocols, 1);

}
}


Als Parameter wird der IODevicename übergeben also, z.B. in der Kommandozeile (oder einfach ein notify auf TRX_0="initialized" o.ä.)
{myUtils_getTRXStatus("TRX_0")}

Grüße,

Oli

Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: KölnSolar am 09 September 2016, 09:22:56
Hi Oli,
nett, aber doch irgendwie überflüssig. Die Informationen werden doch beim fhem-Start gelogged. Und soooo oft vergisst man ja nicht, was man definiert hatte. ;)
Grüße
Markus
Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: KernSani am 09 September 2016, 09:50:14
Zitat von: KölnSolar am 09 September 2016, 09:22:56
Und soooo oft vergisst man ja nicht, was man definiert hatte. ;)
Doch... ich vergesse das immer, da ich da eigentlich nie reinschaue, ausser ein Forumsuser will's wissen... und dann das Tageslog vom letzten restart zu finden ist extrem mühsam ;-)
Aber ich stimme dir zu, sicher nicht lebenswichtig... Tut aber auch nicht weh ;-)
Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: ext23 am 09 September 2016, 12:25:43
Ja aber es wäre schon gut wenn das mal enthalten ist! Allein schon die FW Version. Und wie gesagt es gab ja mal ein Modul wo es drin war, aber das würde nicht übernommen. Ich weiß gar nicht wer das damals erweitert hatte, aber findet man bestimmt hier im Forum.

/Daniel
Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: mi.ke am 09 September 2016, 12:41:43
Tach.
Sowas steht bei mir in den "Attributes" unter "comment"

Wichtig für mich zu wissen, da ich drei verschiedene RFXtrx nutze.
Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: ext23 am 09 September 2016, 12:52:45
Naja wenn du das immer vorbildlich nachträgst, ich hab das auch auf einem extra Zettel, aber der stimmt nicht immer ;-)

Und richtig ich habe auch mehrere von den Dingern, da kommt man schon durcheinander ;-)
Titel: Antw:Wishlist: 45_TRX um readings zu RFXTRX Status erweitern
Beitrag von: RaspiCOC am 10 Oktober 2016, 13:16:54
Schließe mich dem Wunsch an. Habe die Protokolle zwar auch in den Comments, da ich aber zwei RFXTRX mit unterschiedlichen Protokollen fahre, wäre das wirklich hilfreich.