ragingcomputer / amridm2mqtt

runs rtlamr to read IDM power meter data and send to MQTT broker
MIT License
76 stars 43 forks source link

Docker instance never connects to MQTT server #6

Closed danmandle closed 3 years ago

danmandle commented 3 years ago

I have my docker run as follows:

docker run -it --name amridm2mqtt \
--privileged \
-v /dev/bus/usb:/dev/bus/usb \
-e WATCHED_METERS=60162325 \
-e READINGS_PER_HOUR=60 \
-e MQTT_HOST=10.0.0.25 \
amridm2mqtt

When running that command, the following data is shown:

14:44:17.667417 decode.go:45: CenterFreq: 912600155
14:44:17.668354 decode.go:46: SampleRate: 2359296
14:44:17.668505 decode.go:47: DataRate: 32768
14:44:17.668680 decode.go:48: ChipLength: 72
14:44:17.669938 decode.go:49: PreambleSymbols: 32
14:44:17.670049 decode.go:50: PreambleLength: 4608
14:44:17.670100 decode.go:51: PacketSymbols: 736
14:44:17.670146 decode.go:52: PacketLength: 105984
14:44:17.670206 decode.go:59: Protocols: idm
14:44:17.670252 decode.go:60: Preambles: 01010101010101010001011010100011
14:44:17.671150 main.go:119: GainCount: 29

And nothing past there. When I check my MQTT logs, this client doesn't even connect. This is running on a Raspberry Pi 3.

When I follow the run instructions from https://github.com/bemasher/rtlamr, I can see readings coming in.

danmandle commented 3 years ago

Ok, some interesting findings...

pi@raspberrypi:~/go/bin $ ./rtlamr
16:02:29.780260 decode.go:45: CenterFreq: 912600155
16:02:29.790580 decode.go:46: SampleRate: 2359296
16:02:29.791686 decode.go:47: DataRate: 32768
16:02:29.791810 decode.go:48: ChipLength: 72
16:02:29.791874 decode.go:49: PreambleSymbols: 21
16:02:29.791934 decode.go:50: PreambleLength: 3024
16:02:29.791986 decode.go:51: PacketSymbols: 96
16:02:29.792043 decode.go:52: PacketLength: 13824
16:02:29.792116 decode.go:59: Protocols: scm
16:02:29.792168 decode.go:60: Preambles: 111110010101001100000
16:02:29.792273 main.go:119: GainCount: 29
{Time:2020-09-02T16:02:33.944 SCM:{ID:60159221 Type: 4 Tamper:{Phy:00 Enc:01} Consumption:   62640 CRC:0x1B8C}}
{Time:2020-09-02T16:02:40.726 SCM:{ID:60159221 Type: 4 Tamper:{Phy:00 Enc:01} Consumption:   62640 CRC:0x1B8C}}
{Time:2020-09-02T16:02:42.555 SCM:{ID:60159221 Type: 4 Tamper:{Phy:00 Enc:01} Consumption:   62640 CRC:0x1B8C}}

Note that when running rtlamr directly, the Protocols output is SCM.

ragingcomputer commented 3 years ago

Output from rtlamr is SCM unless you specify IDM. I'm pretty sure script is running with command line flags to switch msgtype to IDM 'rtlamr -msgtype=idm -format=csv'

I didn't write settings_docker.py and I'm still running my instance with a venv, so I'm not super familiar... but I think the next thing to try is putting " quotes around the environment variable MQTT_HOST like MQTT_HOST="10.0.0.25"

The other thing is to verify that your MQTT server accepts unauthenticated connections.

danmandle commented 3 years ago

I tired with and without quotes for the MQTT server and have also confirmed that the server does not require creds. I'm going to try another approach. Thanks