Wishlist: 45_TRX um readings zu RFXTRX Status erweitern

Begonnen von KernSani, 09 September 2016, 00:07:53

Vorheriges Thema - Nächstes Thema

KernSani

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
RasPi: RFXTRX, HM, zigbee2mqtt, mySensors, JeeLink, miLight, squeezbox, Alexa, Siri, ...

KernSani

#1
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

RasPi: RFXTRX, HM, zigbee2mqtt, mySensors, JeeLink, miLight, squeezbox, Alexa, Siri, ...

KölnSolar

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
RPi3/2 buster/stretch-SamsungAV_E/N-RFXTRX-IT-RSL-NC5462-Oregon-CUL433-GT-TMBBQ-01e-CUL868-FS20-EMGZ-1W(GPIO)-DS18B20-CO2-USBRS232-USBRS422-Betty_Boop-EchoDot-OBIS(Easymeter-Q3/EMH-KW8)-PCA301(S'duino)-Deebot(mqtt2)-zigbee2mqtt

KernSani

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 ;-)
RasPi: RFXTRX, HM, zigbee2mqtt, mySensors, JeeLink, miLight, squeezbox, Alexa, Siri, ...

ext23

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
HM, KNX, FS20, 1-Wire, PanStamp, AVR-NET-IO, EM1000EM, PCA301, EC3000, HM-LAN, CUL868, RFXtrx433, LGW, DMX @Ubuntu-Server (Hauptsystem) & Raspberry Pi (Satellit)

mi.ke

Tach.
Sowas steht bei mir in den "Attributes" unter "comment"

Wichtig für mich zu wissen, da ich drei verschiedene RFXtrx nutze.
FHEM 5.9 | RPi4 + 5 x RPi(Z) + FB7590 + FB 6890 LTE via LAN und WAN (VPN) verbunden.
2 x CUL868 + 3 x RFXTRX(e) + 6 x HMwLanGW + 4 x z2tGw + 5 x LGW + 2 x IRBlast + CO2 +++
FS20, FHT, FMS, Elro(mod), CM160, Revolt, LGTV, STV, AVR, withings, HM-sec-*, HM-CC-RT-DN, AMAD, PCA301, arlo, Aqara

ext23

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 ;-)
HM, KNX, FS20, 1-Wire, PanStamp, AVR-NET-IO, EM1000EM, PCA301, EC3000, HM-LAN, CUL868, RFXtrx433, LGW, DMX @Ubuntu-Server (Hauptsystem) & Raspberry Pi (Satellit)

RaspiCOC

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.