btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Ask questions about the GEM here.
Post Reply
deepb
Posts: 5
Joined: Tue Dec 07, 2021 4:45 am

btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by deepb » Fri Dec 10, 2021 9:03 am

Hello,

I am trying to us btmon to post to MQTT.

I got btmon from here: https://github.com/BenK22/mtools/blob/i ... /btmon3.py

My config:

Code: Select all

[source]
device_type = gem
ip_read = true
ip_host = 10.0.0.6
ip_port = 80
ip_mode = client
ip_poll_interval = 5
[mqtt]
mqtt_out = true
mqtt_upload_period = 5
mqtt_host = 127.0.0.1
mqtt_clientid = btmon-gem1
When I start btmon with

Code: Select all

python3 btmon3.py --ip --ip-mode=client --ip-host=10.0.0.6  --ip-port=80 --print --device-type=gem
I get an output that looks alright:

Code: Select all

root@openhab:~/btmon# python3 btmon3.py --ip --ip-mode=client --ip-host=10.0.0.6  --ip-port=80 --print --device-type=gem
2021/12/10 15:01:51 btmon: 4.0.0
2021/12/10 15:01:51 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/10 15:01:51 platform: linux
2021/12/10 15:01:51 device type: gem
2021/12/10 15:01:51 device list: ['']
2021/12/10 15:01:51 packet format: gem48ptbin
2021/12/10 15:01:51 schema: counters
2021/12/10 15:01:51 SOCKET: timeout: 60
2021/12/10 15:01:51 SOCKET: server host: 10.0.0.6
2021/12/10 15:01:51 SOCKET: server port: 80

2021/12/10 15:01:59: Serial: 01011343
2021/12/10 15:01:59: Voltage:  241.80V
2021/12/10 15:01:59: Ch01:   -128.619799KWh (   54W)
2021/12/10 15:01:59: Ch02:   -326.071099KWh (   68W)
2021/12/10 15:01:59: Ch03:   -488.204104KWh (  272W)
2021/12/10 15:01:59: Ch04:      0.328359KWh (    8W)
2021/12/10 15:01:59: Ch05:     -0.002141KWh (    0W)
2021/12/10 15:01:59: Ch06:     -0.002517KWh (    0W)
2021/12/10 15:01:59: Ch07:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch08:     -0.000216KWh (    0W)
2021/12/10 15:01:59: Ch09:   -143.683807KWh (   68W)
2021/12/10 15:01:59: Ch10:   -468.186038KWh (  214W)
2021/12/10 15:01:59: Ch11:    -10.443799KWh (    0W)
2021/12/10 15:01:59: Ch12:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch13:     -0.000006KWh (    0W)
2021/12/10 15:01:59: Ch14:     -0.009339KWh (    0W)
2021/12/10 15:01:59: Ch15:     -0.000004KWh (    0W)
2021/12/10 15:01:59: Ch16:     -0.000006KWh (    0W)
2021/12/10 15:01:59: Ch17:     -0.000004KWh (    0W)
2021/12/10 15:01:59: Ch18:     -0.001485KWh (    0W)
2021/12/10 15:01:59: Ch19:     -0.000005KWh (    0W)
2021/12/10 15:01:59: Ch20:     -0.000061KWh (    0W)
2021/12/10 15:01:59: Ch21:     -0.000010KWh (    0W)
2021/12/10 15:01:59: Ch22:     -0.000063KWh (    0W)
2021/12/10 15:01:59: Ch23:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch24:     -0.000009KWh (    0W)
2021/12/10 15:01:59: Ch25:     -0.000004KWh (    0W)
2021/12/10 15:01:59: Ch26:     -0.000124KWh (    0W)
2021/12/10 15:01:59: Ch27:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch28:     -0.000015KWh (    0W)
2021/12/10 15:01:59: Ch29:     -0.000005KWh (    0W)
2021/12/10 15:01:59: Ch30:     -0.000063KWh (    0W)
2021/12/10 15:01:59: Ch31:     -0.000007KWh (    0W)
2021/12/10 15:01:59: Ch32:     -0.004349KWh (    0W)
2021/12/10 15:01:59: p1:               0
2021/12/10 15:01:59: p2:               0
2021/12/10 15:01:59: p3:               0
2021/12/10 15:01:59: p4:               0
2021/12/10 15:01:59: t1:        0.000000
2021/12/10 15:01:59: t2:        0.000000
2021/12/10 15:01:59: t3:        0.000000
2021/12/10 15:01:59: t4:        0.000000
2021/12/10 15:01:59: t5:        0.000000
2021/12/10 15:01:59: t6:        0.000000
2021/12/10 15:01:59: t7:        0.000000
2021/12/10 15:01:59: t8:        0.000000
However when I run it with

Code: Select all

python3 btmon3.py -c config.cfg
to post to MQTT I get the following:

Code: Select all

2021/12/10 15:03:08 btmon: 4.0.0
2021/12/10 15:03:08 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/10 15:03:08 platform: linux
2021/12/10 15:03:08 device type: gem
2021/12/10 15:03:08 device list: ['']
2021/12/10 15:03:08 packet format: gem48ptbin
2021/12/10 15:03:08 schema: counters
2021/12/10 15:03:08 SOCKET: timeout: 60
2021/12/10 15:03:08 SOCKET: server host: 10.0.0.6
2021/12/10 15:03:08 SOCKET: server port: 80
2021/12/10 15:03:08 SOCKET: poll interval: 5
2021/12/10 15:03:08 MQTT: mqtt:127.0.0.1:1883?clientid=btmon-gem1
2021/12/10 15:03:08 MQTT: user: <not-specified>
2021/12/10 15:03:08 MQTT: tls: <not-specified>
2021/12/10 15:03:08 MQTT: topic: /house/energy
2021/12/10 15:03:08 MQTT: qos: 0
2021/12/10 15:03:08 MQTT: retain: False
2021/12/10 15:03:08 MQTT: will: <not-specified>
2021/12/10 15:03:08 MQTT: upload period: 5
2021/12/10 15:03:08 MQTT: map:
2021/12/10 15:03:19 Exception in MQTTProcessor: 'ch1_a'
Any Ideas how to proceed?

thanks
Daniel
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by ben » Fri Dec 10, 2021 10:57 am

deepb wrote:
Fri Dec 10, 2021 9:03 am
Hello,

I am trying to us btmon to post to MQTT.

I got btmon from here: https://github.com/BenK22/mtools/blob/i ... /btmon3.py

My config:

Code: Select all

[source]
device_type = gem
ip_read = true
ip_host = 10.0.0.6
ip_port = 80
ip_mode = client
ip_poll_interval = 5
[mqtt]
mqtt_out = true
mqtt_upload_period = 5
mqtt_host = 127.0.0.1
mqtt_clientid = btmon-gem1
When I start btmon with

Code: Select all

python3 btmon3.py --ip --ip-mode=client --ip-host=10.0.0.6  --ip-port=80 --print --device-type=gem
I get an output that looks alright:

Code: Select all

root@openhab:~/btmon# python3 btmon3.py --ip --ip-mode=client --ip-host=10.0.0.6  --ip-port=80 --print --device-type=gem
2021/12/10 15:01:51 btmon: 4.0.0
2021/12/10 15:01:51 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/10 15:01:51 platform: linux
2021/12/10 15:01:51 device type: gem
2021/12/10 15:01:51 device list: ['']
2021/12/10 15:01:51 packet format: gem48ptbin
2021/12/10 15:01:51 schema: counters
2021/12/10 15:01:51 SOCKET: timeout: 60
2021/12/10 15:01:51 SOCKET: server host: 10.0.0.6
2021/12/10 15:01:51 SOCKET: server port: 80

2021/12/10 15:01:59: Serial: 01011343
2021/12/10 15:01:59: Voltage:  241.80V
2021/12/10 15:01:59: Ch01:   -128.619799KWh (   54W)
2021/12/10 15:01:59: Ch02:   -326.071099KWh (   68W)
2021/12/10 15:01:59: Ch03:   -488.204104KWh (  272W)
2021/12/10 15:01:59: Ch04:      0.328359KWh (    8W)
2021/12/10 15:01:59: Ch05:     -0.002141KWh (    0W)
2021/12/10 15:01:59: Ch06:     -0.002517KWh (    0W)
2021/12/10 15:01:59: Ch07:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch08:     -0.000216KWh (    0W)
2021/12/10 15:01:59: Ch09:   -143.683807KWh (   68W)
2021/12/10 15:01:59: Ch10:   -468.186038KWh (  214W)
2021/12/10 15:01:59: Ch11:    -10.443799KWh (    0W)
2021/12/10 15:01:59: Ch12:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch13:     -0.000006KWh (    0W)
2021/12/10 15:01:59: Ch14:     -0.009339KWh (    0W)
2021/12/10 15:01:59: Ch15:     -0.000004KWh (    0W)
2021/12/10 15:01:59: Ch16:     -0.000006KWh (    0W)
2021/12/10 15:01:59: Ch17:     -0.000004KWh (    0W)
2021/12/10 15:01:59: Ch18:     -0.001485KWh (    0W)
2021/12/10 15:01:59: Ch19:     -0.000005KWh (    0W)
2021/12/10 15:01:59: Ch20:     -0.000061KWh (    0W)
2021/12/10 15:01:59: Ch21:     -0.000010KWh (    0W)
2021/12/10 15:01:59: Ch22:     -0.000063KWh (    0W)
2021/12/10 15:01:59: Ch23:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch24:     -0.000009KWh (    0W)
2021/12/10 15:01:59: Ch25:     -0.000004KWh (    0W)
2021/12/10 15:01:59: Ch26:     -0.000124KWh (    0W)
2021/12/10 15:01:59: Ch27:     -0.000008KWh (    0W)
2021/12/10 15:01:59: Ch28:     -0.000015KWh (    0W)
2021/12/10 15:01:59: Ch29:     -0.000005KWh (    0W)
2021/12/10 15:01:59: Ch30:     -0.000063KWh (    0W)
2021/12/10 15:01:59: Ch31:     -0.000007KWh (    0W)
2021/12/10 15:01:59: Ch32:     -0.004349KWh (    0W)
2021/12/10 15:01:59: p1:               0
2021/12/10 15:01:59: p2:               0
2021/12/10 15:01:59: p3:               0
2021/12/10 15:01:59: p4:               0
2021/12/10 15:01:59: t1:        0.000000
2021/12/10 15:01:59: t2:        0.000000
2021/12/10 15:01:59: t3:        0.000000
2021/12/10 15:01:59: t4:        0.000000
2021/12/10 15:01:59: t5:        0.000000
2021/12/10 15:01:59: t6:        0.000000
2021/12/10 15:01:59: t7:        0.000000
2021/12/10 15:01:59: t8:        0.000000
However when I run it with

Code: Select all

python3 btmon3.py -c config.cfg
to post to MQTT I get the following:

Code: Select all

2021/12/10 15:03:08 btmon: 4.0.0
2021/12/10 15:03:08 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/10 15:03:08 platform: linux
2021/12/10 15:03:08 device type: gem
2021/12/10 15:03:08 device list: ['']
2021/12/10 15:03:08 packet format: gem48ptbin
2021/12/10 15:03:08 schema: counters
2021/12/10 15:03:08 SOCKET: timeout: 60
2021/12/10 15:03:08 SOCKET: server host: 10.0.0.6
2021/12/10 15:03:08 SOCKET: server port: 80
2021/12/10 15:03:08 SOCKET: poll interval: 5
2021/12/10 15:03:08 MQTT: mqtt:127.0.0.1:1883?clientid=btmon-gem1
2021/12/10 15:03:08 MQTT: user: <not-specified>
2021/12/10 15:03:08 MQTT: tls: <not-specified>
2021/12/10 15:03:08 MQTT: topic: /house/energy
2021/12/10 15:03:08 MQTT: qos: 0
2021/12/10 15:03:08 MQTT: retain: False
2021/12/10 15:03:08 MQTT: will: <not-specified>
2021/12/10 15:03:08 MQTT: upload period: 5
2021/12/10 15:03:08 MQTT: map:
2021/12/10 15:03:19 Exception in MQTTProcessor: 'ch1_a'
Any Ideas how to proceed?

thanks
Daniel
I think you need to switch the db_schema, try

db_schema = ecmreadext
Ben
Brultech Research Inc.
E: ben(at)brultech.com
deepb
Posts: 5
Joined: Tue Dec 07, 2021 4:45 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by deepb » Fri Dec 10, 2021 4:43 pm

unfortunately same error.

Code: Select all

root@openhab:~/btmon# python3 btmon3.py -c config.cfg
2021/12/10 22:42:14 btmon: 4.0.0
2021/12/10 22:42:14 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/10 22:42:14 platform: linux
2021/12/10 22:42:14 device type: gem
2021/12/10 22:42:14 device list: ['']
2021/12/10 22:42:14 packet format: gem48ptbin
2021/12/10 22:42:14 schema: ecmreadext
2021/12/10 22:42:14 SOCKET: timeout: 60
2021/12/10 22:42:14 SOCKET: server host: 10.0.0.6
2021/12/10 22:42:14 SOCKET: server port: 80
2021/12/10 22:42:14 SOCKET: poll interval: 5
2021/12/10 22:42:14 MQTT: mqtt:127.0.0.1:1883?clientid=btmon-gem1
2021/12/10 22:42:14 MQTT: user: <not-specified>
2021/12/10 22:42:14 MQTT: tls: <not-specified>
2021/12/10 22:42:14 MQTT: topic: /house/energy
2021/12/10 22:42:14 MQTT: qos: 0
2021/12/10 22:42:14 MQTT: retain: False
2021/12/10 22:42:14 MQTT: will: <not-specified>
2021/12/10 22:42:14 MQTT: upload period: 5
2021/12/10 22:42:14 MQTT: map:
2021/12/10 22:42:29 Exception in MQTTProcessor: 'ch1_a'

note that btmon is still running, but the exception is thrown every few seconds.
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by ben » Mon Dec 13, 2021 11:20 am

deepb wrote:
Fri Dec 10, 2021 4:43 pm
unfortunately same error.

Code: Select all

root@openhab:~/btmon# python3 btmon3.py -c config.cfg
2021/12/10 22:42:14 btmon: 4.0.0
2021/12/10 22:42:14 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/10 22:42:14 platform: linux
2021/12/10 22:42:14 device type: gem
2021/12/10 22:42:14 device list: ['']
2021/12/10 22:42:14 packet format: gem48ptbin
2021/12/10 22:42:14 schema: ecmreadext
2021/12/10 22:42:14 SOCKET: timeout: 60
2021/12/10 22:42:14 SOCKET: server host: 10.0.0.6
2021/12/10 22:42:14 SOCKET: server port: 80
2021/12/10 22:42:14 SOCKET: poll interval: 5
2021/12/10 22:42:14 MQTT: mqtt:127.0.0.1:1883?clientid=btmon-gem1
2021/12/10 22:42:14 MQTT: user: <not-specified>
2021/12/10 22:42:14 MQTT: tls: <not-specified>
2021/12/10 22:42:14 MQTT: topic: /house/energy
2021/12/10 22:42:14 MQTT: qos: 0
2021/12/10 22:42:14 MQTT: retain: False
2021/12/10 22:42:14 MQTT: will: <not-specified>
2021/12/10 22:42:14 MQTT: upload period: 5
2021/12/10 22:42:14 MQTT: map:
2021/12/10 22:42:29 Exception in MQTTProcessor: 'ch1_a'

note that btmon is still running, but the exception is thrown every few seconds.
Can you check the GEM Setup Webpage under Packet Send and make sure "Include Current in Packet" is enabled?
Ben
Brultech Research Inc.
E: ben(at)brultech.com
deepb
Posts: 5
Joined: Tue Dec 07, 2021 4:45 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by deepb » Tue Dec 14, 2021 5:28 am

Hello,

it was off.
I enabled it. Just to be sure i restarted COM and ENG. However I get the same error.

thanks
Daniel
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by ben » Tue Dec 14, 2021 10:46 am

deepb wrote:
Tue Dec 14, 2021 5:28 am
Hello,

it was off.
I enabled it. Just to be sure i restarted COM and ENG. However I get the same error.

thanks
Daniel
Alright, run it with --debug enabled, maybe it'll give some more insight as I'm not sure.
Ben
Brultech Research Inc.
E: ben(at)brultech.com
deepb
Posts: 5
Joined: Tue Dec 07, 2021 4:45 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by deepb » Tue Dec 14, 2021 1:02 pm

well that looks more interesting...

Code: Select all

2021/12/14 19:01:10 btmon: 4.0.0
2021/12/14 19:01:10 python: 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110]
2021/12/14 19:01:10 platform: linux
2021/12/14 19:01:10 device type: gem
2021/12/14 19:01:10 device list: ['']
2021/12/14 19:01:10 packet format: gem48ptbin
2021/12/14 19:01:10 schema: ecmreadext
2021/12/14 19:01:10 buffer size: 120
2021/12/14 19:01:10 SOCKET: timeout: 60
2021/12/14 19:01:10 SOCKET: server host: 10.0.0.6
2021/12/14 19:01:10 SOCKET: server port: 80
2021/12/14 19:01:10 SOCKET: poll interval: 5
2021/12/14 19:01:10 MQTT: mqtt:127.0.0.1:1883?clientid=btmon-gem1
2021/12/14 19:01:10 MQTT: user: <not-specified>
2021/12/14 19:01:10 MQTT: tls: <not-specified>
2021/12/14 19:01:10 MQTT: topic: /house/energy
2021/12/14 19:01:10 MQTT: qos: 0
2021/12/14 19:01:10 MQTT: retain: False
2021/12/14 19:01:10 MQTT: will: <not-specified>
2021/12/14 19:01:10 MQTT: upload period: 5
2021/12/14 19:01:10 MQTT: map:
2021/12/14 19:01:10 packet format is GEM48PTBinaryPacket
2021/12/14 19:01:10 using collector PollingSocketClientCollector
2021/12/14 19:01:10 using 1 processors:
2021/12/14 19:01:10   MQTTProcessor
2021/12/14 19:01:10 setup PollingSocketClientCollector
2021/12/14 19:01:10 setup MQTTProcessor
2021/12/14 19:01:10 SOCKET: waiting for 5 seconds
2021/12/14 19:01:15 opening socket connection to 10.0.0.6:80
2021/12/14 19:01:18 sending request 1 to device
2021/12/14 19:01:18 SOCKET: sending ^^^APISPK
2021/12/14 19:01:18 waiting for data from device
2021/12/14 19:01:18 reading 1 of 1 packets
2021/12/14 19:01:19 adding buffer for 01011343
2021/12/14 19:01:19 buffering packet ts:1639504879 sn:01011343
2021/12/14 19:01:19 closing socket connection
2021/12/14 19:01:19 buffer info:
2021/12/14 19:01:19   01011343:   1 of 120 (1639504879)
2021/12/14 19:01:19 processing with MQTTProcessor
2021/12/14 19:01:19 not enough data for 01011343
2021/12/14 19:01:19 SOCKET: waiting for 5 seconds
2021/12/14 19:01:24 opening socket connection to 10.0.0.6:80
however I get this thrown error:

Code: Select all

Traceback (most recent call last):
  File "/root/btmon/btmon3.py", line 2249, in process
    p.process_compiled(self.packet_collector.packet_buffer)
  File "/root/btmon/btmon3.py", line 2838, in process_compiled
    self.process_calculated(packets)
  File "/root/btmon/btmon3.py", line 4214, in process_calculated
    self._add_msg(p, c, p[c])
KeyError: 'ch1_a'
Traceback (most recent call last):
  File "/root/btmon/btmon3.py", line 2249, in process
    p.process_compiled(self.packet_collector.packet_buffer)
  File "/root/btmon/btmon3.py", line 2838, in process_compiled
    self.process_calculated(packets)
  File "/root/btmon/btmon3.py", line 4214, in process_calculated
    self._add_msg(p, c, p[c])
KeyError: 'ch1_a'
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by ben » Tue Dec 14, 2021 3:38 pm

It looks like

Code: Select all

include_current = true
Needs to be added to your cfg file.
Ben
Brultech Research Inc.
E: ben(at)brultech.com
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by ben » Tue Dec 14, 2021 4:38 pm

Applied a fix to the script itself. The addition I made to include current in MQTT wasn't checking the conditional to see if it should be included.

https://github.com/BenK22/mtools/blob/i ... /btmon3.py
Ben
Brultech Research Inc.
E: ben(at)brultech.com
deepb
Posts: 5
Joined: Tue Dec 07, 2021 4:45 am

Re: btmon not working "Exception in MQTTProcessor: 'ch1_a'"

Post by deepb » Wed Dec 15, 2021 10:42 am

now it works, thanks!
Post Reply