Hi Folks,
ich bin gerade dabei mein PZEM004T mittels ECMD in fhem einzubinden.
Das senden funktioniert und ich erhalte
2018.12.24 09:20:14 5 : ECMDDevice: Analyze command >{chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}<
2018.12.24 09:20:14 5 : Phase1: sending command ���\001\001\000\032 (\260\300\250\001\001\000\032)
2018.12.24 09:20:14 5 : Phase1: write ���\001\001\000\032 (\260\300\250\001\001\000\032)
2018.12.24 09:20:14 5 : SW: b0c0a80101001a
2018.12.24 09:20:14 5 : Starting notify loop for L1, 1 event(s), first is Volt
2018.12.24 09:20:14 5 : End notify loop for L1
2018.12.24 09:20:14 5 : Phase1: read �\000�\003\000\000� (\240\000\356\003\000\000\221)
2018.12.24 09:20:14 5 : Phase1: Spontaneously received �\000�\003\000\000� (\240\000\356\003\000\000\221)
2018.12.24 09:20:14 5 : Phase1: dispatch �\000�\003\000\000�
2018.12.24 09:20:14 5 : Phase1: partial message �\004\000\000� (\356\004\000\000\222) expired.
2018.12.24 09:20:14 5 : Phase1: trying to match message �\000�\003\000\000� (\240\000\356\003\000\000\221)
2018.12.24 09:20:14 5 : Phase1: partial message �\000�\003\000\000� (\240\000\356\003\000\000\221) kept
das ist die message die ich brauche
2018.12.24 09:20:14 5 : Phase1: trying to match message �\000�\003\000\000� (\240\000\356\003\000\000\221)
meine classdev
set Volt cmd {chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}
reading Volt match "\240\"
nun scheint es ja so, das das match nicht auf octal funktioniert, auf was muss ich matchen damit ich weitermachen kann?
mfg maik
File Rev Last Change
66_ECMD.pm 16372 2018-03-10 13:09:24Z neubert
doif.js 15546 2017-12-03 09:57:42Z Ellert
fhemweb.js 16727 2018-05-11 09:12:01Z rudolfkoenig
fhemweb_readingsGroup.js 15189 2017-10-03 17:53:27Z justme1968
svg.js 16617 2018-04-15 09:30:12Z rudolfkoenig
File Rev Last Change
67_ECMDDevice.pm 12877 2016-12-26 09:15:55Z neubert
doif.js 15546 2017-12-03 09:57:42Z Ellert
fhemweb.js 16727 2018-05-11 09:12:01Z rudolfkoenig
fhemweb_readingsGroup.js 15189 2017-10-03 17:53:27Z justme1968
svg.js 16617 2018-04-15 09:30:12Z rudolfkoenig
Zitat von: TiPpFeHlEr am 24 Dezember 2018, 09:28:02
set Volt cmd {chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}
reading Volt match "\240\"
Ein \ zu viel vor dem "
Viele Grüße
Boris
hmmmm..
ok
classdev
set Volt cmd {chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}
reading Volt match "\240"
set Amp cmd {chr(177).chr(192).chr(168).chr(1).chr(1).chr(0).chr(27)}
reading Amp match "\241"
set Watt cmd {chr(178).chr(192).chr(168).chr(1).chr(1).chr(0).chr(28)}
reading Watt match "\242"
log
2018.12.24 09:51:45 5 : Cmd: >set L1 Volt<
2018.12.24 09:51:45 5 : ECMDDevice: Analyze command >{chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}<
2018.12.24 09:51:45 5 : Phase1: sending command ���\001\001\000\032 (\260\300\250\001\001\000\032)
2018.12.24 09:51:45 5 : Phase1: write ���\001\001\000\032 (\260\300\250\001\001\000\032)
2018.12.24 09:51:45 5 : SW: b0c0a80101001a
2018.12.24 09:51:45 5 : Starting notify loop for L1, 1 event(s), first is Volt
2018.12.24 09:51:45 5 : End notify loop for L1
2018.12.24 09:51:45 5 : Phase1: read � (\240)
2018.12.24 09:51:45 5 : Phase1: Spontaneously received � (\240)
2018.12.24 09:51:45 5 : Phase1: dispatch �
2018.12.24 09:51:45 5 : Phase1: partial message �\000\0003\000\000� (\241\000\000\063\000\000\324) expired.
2018.12.24 09:51:45 5 : Phase1: trying to match message � (\240)
2018.12.24 09:51:45 5 : Phase1: partial message � (\240) kept
2018.12.24 09:51:45 5 : Phase1: read \000�\000\000\000� (\000\356\000\000\000\216)
2018.12.24 09:51:45 5 : Phase1: Spontaneously received \000�\000\000\000� (\000\356\000\000\000\216)
2018.12.24 09:51:45 5 : Phase1: dispatch \000�\000\000\000�
2018.12.24 09:51:45 5 : Phase1: merging partial message � (\240) and \000�\000\000\000� (\000\356\000\000\000\216)
2018.12.24 09:51:45 5 : Phase1: trying to match message �\000�\000\000\000� (\240\000\356\000\000\000\216)
2018.12.24 09:51:45 5 : Phase1: partial message �\000�\000\000\000� (\240\000\356\000\000\000\216) kept
ok manchmal klappt das match
2018.12.24 10:12:32 5 : Cmd: >set L1 Volt<
2018.12.24 10:12:32 5 : ECMDDevice: Analyze command >{chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}<
2018.12.24 10:12:32 5 : Phase1: sending command ���\001\001\000\032 (\260\300\250\001\001\000\032)
2018.12.24 10:12:32 5 : Phase1: write ���\001\001\000\032 (\260\300\250\001\001\000\032)
2018.12.24 10:12:32 5 : SW: b0c0a80101001a
2018.12.24 10:12:32 5 : Starting notify loop for L1, 1 event(s), first is Volt
2018.12.24 10:12:32 5 : End notify loop for L1
2018.12.24 10:12:32 5 : Phase1: read � (\240)
2018.12.24 10:12:32 5 : Phase1: Spontaneously received � (\240)
2018.12.24 10:12:32 5 : Phase1: dispatch �
2018.12.24 10:12:32 5 : Phase1: partial message �\000\0003\000\000� (\241\000\000\063\000\000\324) expired.
2018.12.24 10:12:32 5 : Phase1: trying to match message � (\240)
2018.12.24 10:12:32 5 : Phase1: � (\240) matches regex \240* for reading Volt of device L1 with class L1
2018.12.24 10:12:32 5 : Starting notify loop for L1, 2 event(s), first is Volt: �
2018.12.24 10:12:32 5 : End notify loop for L1
2018.12.24 10:12:32 5 : Phase1: read \000�\a\000\000� (\000\354\007\000\000\223)
2018.12.24 10:12:32 5 : Phase1: Spontaneously received \000�\a\000\000� (\000\354\007\000\000\223)
2018.12.24 10:12:32 5 : Phase1: dispatch \000�\a\000\000�
2018.12.24 10:12:32 5 : Phase1: trying to match message \000�\a\000\000� (\000\354\007\000\000\223)
2018.12.24 10:12:32 5 : Phase1: partial message \000�\a\000\000� (\000\354\007\000\000\223) kept
mfg maik
ok
also ich muss ja auf das gesammte datagramm matchen.
2018.12.24 11:18:46 5 : Phase1: trying to match message �\000�\001\000\000� (\240\000\356\001\000\000\217)
wie muss meine classdef dazu aussehn?
reading Volt match "\240\000.*\000\000.*"
perl ist nicht meine Sprache :-[
mfg maik
Zitat von: TiPpFeHlEr am 24 Dezember 2018, 11:21:43
2018.12.24 11:18:46 5 : Phase1: trying to match message �\000�\001\000\000� (\240\000\356\001\000\000\217)
wie muss meine classdef dazu aussehn?
reading Volt match "\240\000.*\000\000.*"
Sollte passen. Präziser ist
\240\000..\000\000\.
Der Punkt steht für ein beliebiges Zeichen. Im Postprocessing kannst Du dann um jeden Punkt runde Klammern setzen, um dann die drei Matches mit $1, $2, $3 weiterzuverarbeiten und die Werte herauszulesen. Wobei ich jetzt nur geraten habe, dass die Werte an den drei Positionen stehen, dich ich mit den Punkten matche.
Zitat
perl ist nicht meine Sprache :-[
/quote]
Ist ja nicht Perl sondern ein regulärer Ausdruck. ;)
Hi Dr. Boris Neubert,
also
\240\000..\000\000\.
ging nicht, glaube da war ein \ zuviel :o
meine classdef
get Volt cmd {chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}
reading Volt match "\240\000..\000\000."
reading Volt postproc {$_}
get Amp cmd {chr(177).chr(192).chr(168).chr(1).chr(1).chr(0).chr(27)}
reading Amp match "\241\000..\000\000."
get Watt cmd {chr(178).chr(192).chr(168).chr(1).chr(1).chr(0).chr(28)}
reading Watt match "\242\000..\000\000."
nun matched er auf alle 3 Datagramme
ich habs mal auf get geändert, da ich ja werte abholen möchte, ist das egal ?
2018.12.24 16:06:12 5 : ECMDDevice: Analyze command >{chr(177).chr(192).chr(168).chr(1).chr(1).chr(0).chr(27)}<
2018.12.24 16:06:12 5 : Phase1: sending command ���\001\001\000\e (\261\300\250\001\001\000\033)
2018.12.24 16:06:12 5 : Phase1: write ���\001\001\000\e (\261\300\250\001\001\000\033)
2018.12.24 16:06:12 5 : SW: b1c0a80101001b
2018.12.24 16:06:12 5 : Starting notify loop for L1, 1 event(s), first is Amp
2018-12-24 16:06:12 ECMDDevice L1 Amp
2018.12.24 16:06:12 5 : End notify loop for L1
2018.12.24 16:06:12 4 : WEBphone: /fhem?detail=L1&dev.getL1=L1&cmd.getL1=get&arg.getL1=Amp&val.getL1=&XHR=1&addLinks=1&fwcsrf=csrf_998662923726444&fw_id=1046 / RL:24 / text/plain; charset=UTF-8 / Content-Encoding: gzip /
2018.12.24 16:06:12 5 : Phase1: read �\000\000C\000 (\241\000\000\103\000)
2018.12.24 16:06:12 5 : Phase1: Spontaneously received �\000\000C\000 (\241\000\000\103\000)
2018.12.24 16:06:12 5 : Phase1: dispatch �\000\000C\000
2018.12.24 16:06:12 5 : Phase1: trying to match message �\000\000C\000 (\241\000\000\103\000)
2018.12.24 16:06:12 5 : Phase1: partial message �\000\000C\000 (\241\000\000\103\000) kept
2018.12.24 16:06:12 5 : Phase1: read \000� (\000\344)
2018.12.24 16:06:12 5 : Phase1: Spontaneously received \000� (\000\344)
2018.12.24 16:06:12 5 : Phase1: dispatch \000�
2018.12.24 16:06:12 5 : Phase1: merging partial message �\000\000C\000 (\241\000\000\103\000) and \000� (\000\344)
2018.12.24 16:06:12 5 : Phase1: trying to match message �\000\000C\000\000� (\241\000\000\103\000\000\344)
2018.12.24 16:06:12 5 : Phase1: �\000\000C\000\000� (\241\000\000\103\000\000\344) matches regex \241\000..\000\000. for reading Amp of device L1 with class L1
2018.12.24 16:06:12 5 : Starting notify loop for L1, 2 event(s), first is Amp: �\000\000C\000\000�
2018-12-24 16:06:12 ECMDDevice L1 Amp: �C�
2018-12-24 16:06:12 ECMDDevice L1 Amp �C�
2018.12.24 16:06:12 5 : End notify loop for L1
nun muss ich die Empfangenen Werte noch umwandeln und berechnen im postproc.
hier ist aber erstmal Schluss da meine Frage zum match beantwortet ist.
Danke
mfg Maik
für alle dies interressiert, hier meine fertige classdef
set Volt cmd {chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}
get Volt cmd {chr(176).chr(192).chr(168).chr(1).chr(1).chr(0).chr(26)}
reading Volt match "\240\000..\000\000."
reading Volt postproc {\
/^\240\000(.)(.)\000\000(.)$/;\
$_ = ((ord(trim("$1")))+(ord(trim("$2"))/10));\
}
set Amp cmd {chr(177).chr(192).chr(168).chr(1).chr(1).chr(0).chr(27)}
get Amp cmd {chr(177).chr(192).chr(168).chr(1).chr(1).chr(0).chr(27)}
reading Amp match "\241\000..\000\000."
reading Amp postproc {\
/^\241\000(.)(.)\000\000(.)$/;\
$_ = ((ord(trim("$1")))+(ord(trim("$2"))/100));\
}
set Watt cmd {chr(178).chr(192).chr(168).chr(1).chr(1).chr(0).chr(28)}
get Watt cmd {chr(178).chr(192).chr(168).chr(1).chr(1).chr(0).chr(28)}
reading Watt match "\242..\000\000\000."
reading Watt postproc {\
/^\242(.)(.)\000\000\000(.)$/;\
$_ = ((ord(trim("$1"))*256)+(ord(trim("$2"))/1000));\
}
set Energy cmd {chr(179).chr(192).chr(168).chr(1).chr(1).chr(0).chr(29)}
get Energy cmd {chr(179).chr(192).chr(168).chr(1).chr(1).chr(0).chr(29)}
reading Energy match "\243...\000\000."
reading Energy postproc {\
/^\243(.)(.)(.)\000\000(.)$/;\
$_ = (((ord(trim("$1"))*256*256)+(ord(trim("$2"))*256)+(ord(trim("$3"))))/1000);\
}
hab mal den thread namen angepasst, damit jeder was findet.
frohe Weihnachten Maik