Hallo,
ich würde gerne WMZ, die ich über eine IR Kopf auslesen kann mit Smarthome.py auslesen und die Daten auswerten. Sie kommunizieren über Mbus, ich habe im Netz ein Skript gefunden, dass die Zählerdaten abrufen kann:
Gibt es hier schon irgendwelche Ansätze?
ich würde gerne WMZ, die ich über eine IR Kopf auslesen kann mit Smarthome.py auslesen und die Daten auswerten. Sie kommunizieren über Mbus, ich habe im Netz ein Skript gefunden, dass die Zählerdaten abrufen kann:
Code:
har *buf;
char in[256] = "";
ssize_t ret_out;
.... Init serielle Schnittstelle
int fd = open ("/dev/ttyUSB0", O_RDWR | O_NOCTTY );
set_interface_attribs (fd, B2400, 0); // set speed to 2,400 bps, 8n1
(no parity)
set_blocking (fd, 0 ); // set no blocking
strcpy( in,
"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU" );
ret_out = write (fd, in, strlen(in)); // sent wakeup
usleep ((1000 + 25) * 100); // sleep enough to transmit plus
buf = read_data( fd);
// Initialisiere MBus -> ACK mit 'E5'
in[0] = 0x10;
in[1] = 0x40; // Init MBus
in[2] = 0x00;
in[3] = 0x40; // Checksumme = in[1] + in [2]
in[4] = 0x16;
ret_out = write (fd, in, 5); // sent
usleep ((1000 + 25) * 100); // sleep enough to transmit plus
buf = read_data( fd);
if( buf[5] == 0xE5 ) {
// Get Data from MBus
in[0] = 0x10;
in[1] = 0x5B; // GetData
in[2] = 0x00;
in[3] = 0x5B; // Checksumme = in[1] + in [2]
in[4] = 0x16;
ret_out = write (fd, in, 5);
usleep ((1000 + 25) * 100); // sleep enough to transmit plus
buf = read_data( fd);
// Zaehlerstand
double waerme = ((double) toInt(&buf[26])) + (100.0 * (double)
toInt(&buf[27])) + (1000.0 * (double) toInt(&buf[28])) + (10000.0 *
(double) toInt(&buf[29]));
//aktuelle Leistung
double leistung = ((double) toInt(&buf[44])) + (100.0 * (double)
toInt(&buf[45])) + (1000.0 * (double) toInt(&buf[46])) + (10000.0 *
(double) toInt(&buf[47]));
}
int toInt( char *in ) {
char out[2];
int iOut = 0;
sprintf( out, "%02x", in[0] );
iOut = atoi( out );
return iOut;


Kommentar