Giter Club home page Giter Club logo

rtlamr2mqtt's People

Contributors

allangood avatar anthonypluth avatar bachya avatar csharpen avatar cybergrimes avatar dependabot[bot] avatar ericthomas avatar irakhlin avatar jeffeb3 avatar jefffaer avatar jonbloom avatar justin654 avatar ogreface avatar phidauex avatar prplhaz4 avatar shbatm avatar sritchie avatar taylorcoffelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtlamr2mqtt's Issues

Support other home assistant state_classes

The state_class is currently hardcoded to total_increasing: https://github.com/allangood/rtlamr2mqtt/blob/main/rtlamr2mqtt.py#L183

https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes

measurement
The state represents a measurement in present time, not a historical aggregation such as statistics or a prediction of the future. Examples of what should be classified measurement are: current temperature, humidify or electric power. Examples of what should not be classified as measurement: Forecasted temperature for tomorrow, yesterday's energy consumption or anything else that doesn't include the current measurement. For supported sensors, statistics of hourly min, max and average sensor readings is updated every 5 minutes.

total
The state represents a total amount that can both increase and decrease, e.g. a net energy meter. Statistics of the accumulated growth or decline of the sensor's value since it was first added is updated every 5 minutes. This state class should not be used for sensors where the absolute value is interesting instead of the accumulated growth or decline, for example remaining battery capacity or CPU load; in such cases state class measurement should be used instead.

total_increasing
Similar to total, with the restriction that the state represents a monotonically increasing positive total, e.g. a daily amount of consumed gas, weekly water consumption or lifetime energy consumption. Statistics of the accumulated growth of the sensor's value since it was first added is updated every 5 minutes.

My energy meter is a net meter, and my solar system sometimes makes it go backwards. I think I'd want the state_class for that meter to be total instead of total_increasing.

Allow ability to configure TLS

I notice from here:

publish.single(
topic=topic, payload=payload, qos=qos, retain=retain, hostname=self.d['hostname'], port=self.d['port'],
client_id=self.d['client_id'], keepalive=60, will=will, auth=self.__get_auth(), tls=None
)

...that TLS is always assumed to be excluded. I host my MQTT broker behind TLS and would love to be able to utilize that here.

Readme: all msg types in listen mode

Suggest changing the LISTEN_ONLY sample command to listen for all message types since the sentence above says to use it when you don't know the protocol

docker run --rm -ti -e LISTEN_ONLY=yes -e RTL_MSGTYPE="all" --device=/dev/bus/usb:/dev/bus/usb allangood/rtlamr2mqtt
                                                       ^^^ 

MQTT config not accepting non local server

When I specify the host,port,user,password it still trys to grab the local HASS MQTT Addon which in my case doesnt exist causing it to bomb out

Error
[2022-05-19 11:34:49] RTLAMR2MQTT Starting... [2022-05-19 11:34:49] Fetching default MQTT configuration from http://supervisor/services/mqtt Traceback (most recent call last): File "/usr/bin/rtlamr2mqtt.py", line 286, in load_config resp.raise_for_status() File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://supervisor/services/mqtt During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/bin/rtlamr2mqtt.py", line 372, in <module> config = load_config(sys.argv) File "/usr/bin/rtlamr2mqtt.py", line 297, in load_config except e: NameError: name 'e' is not defined

Config

general:
  sleep_for: 300
  verbosity: debug
  tickle_rtl_tcp: false
  device_id: single
mqtt:
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant
  base_topic: rtlamr
  tls_enabled: false
  tls_ca: /etc/ssl/certs/ca-certificates.crt
  tls_cert: /etc/ssl/my_self_signed_cert.crt
  tls_keyfile: /etc/ssl/my_self_signed_cert_key.key
  tls_insecure: true
  host: 10.2.0.140
  port: 1883
  user: rtl
  password: xxxxxx
custom_parameters:
  rtltcp: '-s 2048000'
  rtlamr: '-unique=true'
meters:
  - id: 123456789
    protocol: scm+
    name: gas_meter
    format: '####.###'
    unit_of_measurement: m³
    icon: mdi:gas_canister
    device_class: gas`

Can RTLAMR2MQTT run in parallel with RTL_433 with two RTL-SDR sticks on one RPi 4 in Home Assistant?

Hi, I apologize in advance for this perhaps stupid newbie question.
I successfully installed this setup and receive some old thermometers via a generic RTL-SDR stick (https://linux-hardware.org/index.php?id=usb:0bda-2838) on Bus 001 Device 004: ID 0bda:2838 followling these instructions: https://community.home-assistant.io/t/home-assistant-add-on-rtl-433-with-mqtt-auto-discovery/260665 on a Raspberry Pi 4.
Now I added a second generic RTL-SDR stick (https://linux-hardware.org/index.php?id=usb:0bda-2838) on Bus 001 Device 006: ID 0bda:2838 and would like to run rtlamr2mqtt in parallel to the well working rtl_433. Two of my meters are smart: water http://fcc.io/EWQ100W Itron 100WRD Water ERT Type 11 903/927 Mhz and gas http://fcc.io/100GDLAN Itron 100GDLAN Gas ERT Type 12 908/926.8 Mhz and they are also listed here: https://github.com/bemasher/rtlamr.
So far, I am unable to figure out how to "tell" HA, to continue to use this RTL-SDR Bus 001 Device 004: ID 0bda:2838 for the old thermometers etc. via rtl_433 (https://github.com/pbkhrv/rtl_433-hass-addons) and Bus 001 Device 006: ID 0bda:2838 for gas and water via https://github.com/allangood/rtlamr2mqtt.
In the RTLAMR2MQTT configuration file I entered:
general:
usb_reset: '006:001'
I was hoping this would select the 2nd RTL-SDR.
The system log shows this: 22-04-09 11:48:48 WARNING (MainThread) [supervisor.misc.tasks] Watchdog found a problem with 6713e36e_rtlamr2mqtt!
22-04-09 11:48:48 INFO (SyncWorker_6) [supervisor.docker.interface] Cleaning addon_6713e36e_rtlamr2mqtt application
22-04-09 11:48:50 INFO (SyncWorker_6) [supervisor.docker.addon] Starting Docker add-on 6713e36e/aarch64-addon-rtlamr2mqtt with version 1.7.0
The message keeps repeating itself endlessly. Uninstalling and rebuilding have not helped. The reason I plugged in two RTL-SDR sticks was that I was hoping that I can receive two frequency ranges in parallel with two independent hardware devices, since I thought trying it with one stikc would cause conflicts of rtl_433 and rtlamr. But maybe that is wrong?
And, when I type in "rtl_tcp" or "rtlamr" into the SSH sheel inside HA, I don't see anything but an error message.
[core-ssh /]$ rtl_tcp
bash: rtl_tcp: command not found
[core-ssh /]$ rtlamr
bash: rtlamr: command not found
Also, identifying the meters via this command "docker run --rm -ti -e LISTEN_ONLY=yes -e RTL_MSGTYPE="all" --device=/dev/bus/usb:/dev/bus/usb allangood/rtlamr2mqtt" probably requires some adjustments I guess?
I have found some numbers on the smart meters, but to be sure, I would like to use this feature to "discover them".
Any help would be greatly appreciated!

possible documentation issue for docker-compose config

Using the current sample docker-compose.yml file, I get an error:

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.rtlamr.volumes contains an invalid type, it should be an array

I replaced the volumes section with:

    volumes:
      - '/etc/rtlamr2mqtt.yaml:/etc/rtlamr2mqtt.yaml:ro'

to resolve the error. Docker isn't my area of expertise so I might be missing something, but I wanted to report it.

Listen Only Logs spammed

Listen only logs are being spammed with messages like:

ll*, now xxx


ll+, now 360

ll+, now 361

ll+, now 362

ll+, now 363

ll+, now 364

ll+, now 365

ll+, now 366

ll+, now 367

I'm currently logging the output to syslog from this so I can try to identify my "wake only" gas/water meters. This is spamming the logs, making it difficult to sort through.

Additionally I'd like the option to allow it to listen AND log meters being set in the yaml to be sent to home assistant. My power meter is easily identified, but i have yet to see my gas/water. After looking into it I think they only send if the meter is being read, which could only be monthly.

Thanks for the excellent container!

edit: it looks like this is actually caused by not specifying a message type. I added RTL_MSGTYPE=scm and the messages stopped. Is there a way to listen for scm and scm+?

docker container never actually starts, stuck in restarting

After starting the container, it never actually starts:

CONTAINER ID   IMAGE                           COMMAND                  CREATED         STATUS                             PORTS                      NAMES
fa842b59ba88   allangood/rtlamr2mqtt           "/usr/bin/rtlamr2mqt…"   5 minutes ago   Restarting (1) 1 second ago                                   rtlamr2mqtt

dmesg shows

[   25.414327] br-9b530f50f209: port 1(vethd7fc5fc) entered blocking state
[   25.414335] br-9b530f50f209: port 1(vethd7fc5fc) entered disabled state
[   25.416589] device vethd7fc5fc entered promiscuous mode
[   25.424634] br-9b530f50f209: port 1(vethd7fc5fc) entered blocking state
[   25.424640] br-9b530f50f209: port 1(vethd7fc5fc) entered forwarding state
[   25.424692] IPv6: ADDRCONF(NETDEV_CHANGE): br-9b530f50f209: link becomes ready
[   25.434009] br-9b530f50f209: port 1(vethd7fc5fc) entered disabled state
[   25.435772] br-7412938b5455: port 1(vethe665982) entered blocking state
[   25.435777] br-7412938b5455: port 1(vethe665982) entered disabled state
[   25.435925] device vethe665982 entered promiscuous mode
[   25.436137] br-7412938b5455: port 1(vethe665982) entered blocking state
[   25.436141] br-7412938b5455: port 1(vethe665982) entered forwarding state
[   25.445398] br-7412938b5455: port 1(vethe665982) entered disabled state
[   26.091322] cgroup: cgroup: disabling cgroup2 socket matching due to net_prio or net_cls activation
[   26.879720] eth0: renamed from veth9c9fd90
[   26.893545] IPv6: ADDRCONF(NETDEV_CHANGE): vethe665982: link becomes ready
[   26.893623] br-7412938b5455: port 1(vethe665982) entered blocking state
[   26.893628] br-7412938b5455: port 1(vethe665982) entered forwarding state
[   26.893722] IPv6: ADDRCONF(NETDEV_CHANGE): br-7412938b5455: link becomes ready
[   26.960433] eth0: renamed from veth5d407f4
[   26.980259] IPv6: ADDRCONF(NETDEV_CHANGE): vethd7fc5fc: link becomes ready
[   26.980348] br-9b530f50f209: port 1(vethd7fc5fc) entered blocking state
[   26.980352] br-9b530f50f209: port 1(vethd7fc5fc) entered forwarding state
[   27.907908] br-9b530f50f209: port 1(vethd7fc5fc) entered disabled state
[   27.908199] veth5d407f4: renamed from eth0
[   28.003419] br-9b530f50f209: port 1(vethd7fc5fc) entered disabled state
[   28.010869] device vethd7fc5fc left promiscuous mode
[   28.010884] br-9b530f50f209: port 1(vethd7fc5fc) entered disabled state
[   28.163194] br-9b530f50f209: port 1(veth74f3aa0) entered blocking state
[   28.163200] br-9b530f50f209: port 1(veth74f3aa0) entered disabled state
[   28.163388] device veth74f3aa0 entered promiscuous mode
[   28.163652] br-9b530f50f209: port 1(veth74f3aa0) entered blocking state
[   28.163656] br-9b530f50f209: port 1(veth74f3aa0) entered forwarding state
[   28.919834] br-9b530f50f209: port 1(veth74f3aa0) entered disabled state
[   29.500723] eth0: renamed from vethbe5c8c9
[   29.532076] IPv6: ADDRCONF(NETDEV_CHANGE): veth74f3aa0: link becomes ready
[   29.532169] br-9b530f50f209: port 1(veth74f3aa0) entered blocking state
[   29.532172] br-9b530f50f209: port 1(veth74f3aa0) entered forwarding state
[   30.260343] br-9b530f50f209: port 1(veth74f3aa0) entered disabled state
[   30.260492] vethbe5c8c9: renamed from eth0
[   30.336197] br-9b530f50f209: port 1(veth74f3aa0) entered disabled state
[   30.351150] device veth74f3aa0 left promiscuous mode
[   30.351166] br-9b530f50f209: port 1(veth74f3aa0) entered disabled state
[   30.501904] br-9b530f50f209: port 1(veth7761b7d) entered blocking state
[   30.501909] br-9b530f50f209: port 1(veth7761b7d) entered disabled state
[   30.502248] device veth7761b7d entered promiscuous mode
[   30.504985] br-9b530f50f209: port 1(veth7761b7d) entered blocking state
[   30.504992] br-9b530f50f209: port 1(veth7761b7d) entered forwarding state
[   30.935935] br-9b530f50f209: port 1(veth7761b7d) entered disabled state
[   31.627312] eth0: renamed from veth22f25ee
[   31.642134] IPv6: ADDRCONF(NETDEV_CHANGE): veth7761b7d: link becomes ready
[   31.642235] br-9b530f50f209: port 1(veth7761b7d) entered blocking state
[   31.642239] br-9b530f50f209: port 1(veth7761b7d) entered forwarding state
[   32.245137] veth22f25ee: renamed from eth0
[   32.315692] br-9b530f50f209: port 1(veth7761b7d) entered disabled state
[   32.353475] br-9b530f50f209: port 1(veth7761b7d) entered disabled state
[   32.360939] device veth7761b7d left promiscuous mode
[   32.360958] br-9b530f50f209: port 1(veth7761b7d) entered disabled state
[   32.635660] br-9b530f50f209: port 1(vethc75a80d) entered blocking state
[   32.635666] br-9b530f50f209: port 1(vethc75a80d) entered disabled state
[   32.635998] device vethc75a80d entered promiscuous mode
[   32.643163] br-9b530f50f209: port 1(vethc75a80d) entered blocking state
[   32.643169] br-9b530f50f209: port 1(vethc75a80d) entered forwarding state
[   32.966455] br-9b530f50f209: port 1(vethc75a80d) entered disabled state

I'm sure I'm missing something obvious here. This is on an Ubuntu box:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

Using a Nooelec NESDR Mini.

wont start, tons of py errors

The following is just repeated constantly in my logs, and the container won't start properly.
(System ran fine for months, but I turned off the container and let it set for the last few months. Just updated it and tried to bring it back online and experienced this. I tried to scour the old issues for a breadcrumb to have an AHA! moment, but so far no luck)

Traceback (most recent call last):
  File "/usr/bin/rtlamr2mqtt.py", line 255, in <module>
    config = load_config(sys.argv)
  File "/usr/bin/rtlamr2mqtt.py", line 134, in load_config
    return load_yaml_config(config_path)
  File "/usr/bin/rtlamr2mqtt.py", line 144, in load_yaml_config
    return yaml.safe_load(config_file)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 39, in get_single_node
    if not self.check_event(StreamEndEvent):
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 171, in parse_document_start
    raise ParserError(None, None,
yaml.parser.ParserError: expected '<document start>', but found '<block mapping start>'
  in "/usr/bin/rtlamr2mqtt.py", line 29, column 1

Everything looks right, I'm seeing meters in debug, but I'm not getting anything sent to mqtt

Hello,

I'm not sure what's misconfigured, but I'm not getting any meter or autodiscover data sent to my MQTT broker. This is the contents of my mqtt section

mqtt:
  host: 192.168.1.xx   #xx is the number of my hassio VM, running mosquitto
  user: mymqttuser
  #password: "mymqttpassword"
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant

I also put intentionally wrong config info in there, and I didn't get any messages in the logs, either, so I'm not sure is it's managing to connect at all or not.

RuntimeWarning: invalid value encountered in double_scalars

I'm running version 1.5.2 in Home Assistant as an add-on. HA Core: core-2021.11.5

Trying to start RTL_TCP: /usr/bin/rtl_tcp -s 2048000
RTL_TCP started with PID 1020
RTL_TCP is ready to receive connections!
server: 127.0.0.1:1234, host: 127.0.0.1, port: 1234
Attempting to tune rtl_tcp to a different freq to shake things up
Successfully tickled rtl_tcp
Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=r900,scm -format=json -filterid=1563533180,2691258 -unique=true
RTLAMR started with PID 1027
09:56:29.646514 decode.go:45: CenterFreq: 912600155
09:56:29.646945 decode.go:46: SampleRate: 2359296
09:56:29.646982 decode.go:47: DataRate: 32768
09:56:29.647015 decode.go:48: ChipLength: 72
09:56:29.647045 decode.go:49: PreambleSymbols: 32
09:56:29.647072 decode.go:50: PreambleLength: 4608
09:56:29.647098 decode.go:51: PacketSymbols: 116
09:56:29.647124 decode.go:52: PacketLength: 16704
09:56:29.647144 decode.go:59: Protocols: r900,scm
09:56:29.647159 decode.go:60: Preambles: 00000000000000001110010101100100,111110010101001100000
09:56:29.647164 main.go:124: GainCount: 29
{"Time":"2021-12-09T09:56:39.232399254-05:00","Offset":0,"Length":0,"Type":"R900","Message":{"ID":1563533180,"Unkn1":163,"NoUse":32,"BackFlow":0,"Consumption":1554423,"Unkn3":0,"Leak":0,"LeakNow":0}}
Meter "1563533180" - Consumption 0155442.3. Sending value to MQTT.
Predicted reading: 155442.30000000002 - Actual reading: 0155442.3
/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py:3372: RuntimeWarning: Mean of empty slice.
  return _methods._mean(a, axis=axis, dtype=dtype,
/usr/lib/python3/dist-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
Grow rate avg: nan
Distance from prediction: -2.9103830456733704e-11
Threshold for anomaly: nan
Sending message to MQTT:
 > topic => rtlamr/1563533180/state
 > payload => {"Time": "2021-12-09T09:56:39.232399254-05:00", "Offset": 0, "Length": 0, "Type": "R900", "Message": {"ID": 1563533180, "Unkn1": 163, "NoUse": 32, "BackFlow": 0, "Consumption": "0155442.3", "Unkn3": 0, "Leak": 0, "LeakNow": 0, "Predicted": 155442.30000000002, "Anomaly": false}}
 > retain => True

Unknown exception connecting to MQTT broker: tls_set() got an unexpected keyword argument 'tls_insecure'

It looks like this:

self.d['tls'] = { 'ca_certs': tls_ca, 'certfile': tls_cert, 'keyfile': tls_keyfile, 'tls_insecure': tls_insecure }

...causes the exception in the title. I'm guessing this refers to the tls_set method in paho-mqtt, whose definition doesn't include that kwarg:

def tls_set(self, ca_certs=None, certfile=None, keyfile=None, cert_reqs=None, tls_version=None, ciphers=None, keyfile_password=None):

It looks like paho-mqtt will set insecure TLS if you pass ssl.CERT_NONE to its cert_reqs param: https://github.com/eclipse/paho.mqtt.python/blob/9782ab81fe7ee3a05e74c7f3e1d03d5611ea4be4/src/paho/mqtt/client.py#L813-L819

Add-on support for arm64

HA says the add-on is not compatible with my processor. I see that the Docker image build includes arm64, should the add-on config's arch be updated to include arm64 as well? Or is there a reason that it wouldn't actually be suported?

Having issues with invalid symbollength

I am trying to get this docker running and am having a few issues.

  1. When I add the extra parameter -e LISTEN_ONLY=yes my docker container doesn't start. Prior to you recent revisions, I was able to get this to work in the old syntax.
  2. See log below. Getting an invalid symbollength. Without being able to get the container to listen only mode I can't give you an example of the output my SDR is receiving.

I have also attached a copy of my .yaml file for config settings.

rtlamr2mqtt.txt

Thanks,
Dan

RTLAMR started with PID 13 today at 11:19:33 AM 11:19:33.312989 flags.go:106: Environment variable "RTLAMR_VERSION" failed to override flag "version" with value "v0.9.1": "strconv.ParseBool: parsing \"v0.9.1\": invalid syntax" today at 11:19:33 AM 11:19:33.313075 flags.go:124: invalid symbollength today at 11:19:33 AM Sleep_for defined, time to sleep! today at 11:19:33 AM Terminating all subprocess... today at 11:19:33 AM Signal caught, exiting! today at 11:19:33 AM Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source today at 11:19:33 AM to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...). today at 11:19:33 AM bye! today at 11:19:33 AM RTL_TCP terminated. today at 11:19:33 AM RTLAMR terminated. today at 11:19:33 AM Sleeping for 300 seconds, see you later... today at 11:24:33 AM Sending message to MQTT: today at 11:24:33 AM > hostname => 192.168.10.50 today at 11:24:33 AM > port => 11883 today at 11:24:33 AM > username => seaverd today at 11:24:33 AM > password => *** REDACTED *** today at 11:24:33 AM > topic => rtlamr/status today at 11:24:33 AM > payload => online today at 11:24:33 AM > qos => 0 today at 11:24:33 AM > retain => True today at 11:24:33 AM RTL_TCP started with PID 17 today at 11:24:33 AM Found 1 device(s): today at 11:24:33 AM 0: Realtek, RTL2838UHIDIR, SN: 00000001 today at 11:24:33 AM today at 11:24:33 AM Using device 0: Generic RTL2832U OEM today at 11:24:33 AM Found Rafael Micro R820T tuner today at 11:24:33 AM [R82XX] PLL not locked! today at 11:24:34 AM Tuned to 100000000 Hz. today at 11:24:34 AM listening... today at 11:24:35 AM RTLAMR started with PID 22 today at 11:24:35 AM 11:24:35.489213 flags.go:106: Environment variable "RTLAMR_VERSION" failed to override flag "version" with value "v0.9.1": "strconv.ParseBool: parsing \"v0.9.1\": invalid syntax" today at 11:24:35 AM 11:24:35.489294 flags.go:124: invalid symbollength today at 11:24:35 AM Sleep_for defined, time to sleep! today at 11:24:35 AM Terminating all subprocess... today at 11:24:35 AM Signal caught, exiting! today at 11:24:35 AM Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source today at 11:24:35 AM to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...). today at 11:24:35 AM bye! today at 11:24:35 AM RTL_TCP terminated. today at 11:24:35 AM RTLAMR terminated. today at 11:24:35 AM Sleeping for 300 seconds, see you later...

example in readme not working

docker run --rm -ti -e LISTEN_ONLY=yes -e RTL_MSGTYPE="all" --device=/dev/bus/usb:/dev/bus/usb allangood/rtlamr2mqtt
Traceback (most recent call last):
File "/usr/bin/rtlamr2mqtt.py", line 38, in
log_message('Starting in LISTEN ONLY Mode...')
NameError: name 'log_message' is not defined

main.go:90: Error connecting to spectrum server: dial tcp 127.0.0.1:1234: connect: connection refused

Any time I have to restart or stop/start the home assistant add-on I get a connection refused error.

Default config other then listen mode set to true

restarting host computer will allow it to come back up

I think it is because there are two PIDs and restart only kills one of them.

[2022-06-09 11:41:25] Using "/data/options.json" config file
[2022-06-09 11:41:25] Fetching default MQTT configuration from http://supervisor/services/mqtt
[2022-06-09 11:41:25] Starting in LISTEN ONLY Mode...
[2022-06-09 11:41:25] Using "/data/options.json" config file
[2022-06-09 11:41:25] Fetching default MQTT configuration from http://supervisor/services/mqtt
[2022-06-09 11:41:25] Configured MQTT sender:
[2022-06-09 11:41:25] > hostname => core-mosquitto
[2022-06-09 11:41:25] > port => 1883
[2022-06-09 11:41:25] > username => addons
[2022-06-09 11:41:25] > client_id => rtlamr2mqtt
[2022-06-09 11:41:25] > base_topic => rtlamr
[2022-06-09 11:41:25] > availability_topic => rtlamr/status
[2022-06-09 11:41:25] > tls => None
[2022-06-09 11:41:25] Starting rtl_tcp with /usr/bin/rtl_tcp
[2022-06-09 11:41:27] Starting rtlamr with ['/usr/bin/rtlamr', '-msgtype=all', '-format=json']
[2022-06-09 11:41:27] You should see all utility meters after this line:
[2022-06-09 11:41:27] 11:41:27.829757 main.go:90: Error connecting to spectrum server: dial tcp 127.0.0.1:1234: connect: connection refused
[2022-06-09 11:41:27] rcvr.Connect
[2022-06-09 11:41:27] main.(*Receiver).NewReceiver
[2022-06-09 11:41:27] /go/pkg/mod/github.com/bemasher/[email protected]/main.go:90
[2022-06-09 11:41:27] main.main
[2022-06-09 11:41:27] /go/pkg/mod/github.com/bemasher/[email protected]/main.go:313
[2022-06-09 11:41:27] runtime.main
[2022-06-09 11:41:27] /usr/local/go/src/runtime/proc.go:250
[2022-06-09 11:41:27] runtime.goexit
[2022-06-09 11:41:27] /usr/local/go/src/runtime/asm_amd64.s:1571

NameError: name 'tls' is not defined

I just installed the add-on in my Home Assistant OS instance and I'm getting this error:

[2022-04-06 17:49:53] Fetching default MQTT configuration from http://supervisor/services/mqtt
Traceback (most recent call last):
  File "/usr/bin/rtlamr2mqtt.py", line 327, in <module>
    mqtt_sender = MqttSender(host, port, user, password, tls)
NameError: name 'tls' is not defined

I don't believe it's related to mqtt since the Mosquitto add-on has been working fine for months.
It could be related to the most recent update (1.7.0) and it's just a coincidence that I installed this add-on for the first time.
It could also be related to me not having the tls_cert and tls_keyfile files.

Here's my Configuration (almost default):

general:
  sleep_for: 300
  verbosity: debug
  tickle_rtl_tcp: false
  usb_reset: '005:002'
mqtt:
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant
  tls_ca: /etc/ssl/certs/ca-certificates.crt
  tls_cert: /etc/ssl/my_self_signed_cert.crt
  tls_keyfile: /etc/ssl/my_self_signed_cert_key.key
  tls_insecure: true
custom_parameters:
  rtltcp: '-s 2048000'
  rtlamr: '-unique=true'
meters:
  - id: 1042xxxx
    protocol: scm
    name: gas_meter
    format: '####.###'
    unit_of_measurement: m³
    icon: mdi:gas_canister
    device_class: gas

Possibly a separate issue, but when I try to remove tls_cert or tls_keyfile when I restart the add-on those lines come back. Also, when I try to get rid of custom_parameters, I get an error preventing me from saving.

I'm happy to help diagnose and to provide whatever's needed to figure this out.

configuration option to specify the spectrum (tcp) server address

When rtlamr runs within the container, it looks for the tcp server at 127.0.0.1:1234. Would it be possible to add a configuration option in the yaml to allow setting a custom address? I have a non-Dockerized instance of rtl_tcp but this is the perfect bridge to Home Assistant so I hope I can get them to talk to each other. Thanks!

HA addon - didn't save the config?

I had a working config - and accidently uninstalled the addon.
When I went to reset it up - it doesn't appear to create the rtlamr2mqtt.yaml

Where do I put the rtlamr2mqtt.yaml ?

[2022-05-16 16:34:06] RTLAMR2MQTT Starting...
[2022-05-16 16:34:06] Configuration file cannot be found at "/etc/rtlamr2mqtt.yaml"

image

image

rtlamr not killed, running constantly

This is with Docker Desktop on Mac OS. Logs output:

`
Sending message to MQTT:

hostname => 192.168.0.6
port => 1883
username => homeassistant
password => *** REDACTED ***
topic => rtlamr/56341459/state
payload => 00501905
retain => True
Sleep_for defined, time to sleep!
Terminating all subprocess...
Sleeping for 300 seconds, see you later...
`

In fact, the rtlamr process stays alive, constantly using 30% CPU. The script does in fact run every 300 seconds and send the new meter reading to the MQTT server, though. Would try to find a fix myself but unfortunately I know nothing about Docker. Thanks!

Extend for multiple items in FILTER_ID

Thank you for publishing this. Works great for a single meter, but in the no good deed goes unpunished category; any interest in working with multiple meters?

Would mean changing the mqtt publish to use fld 3 instead of the static name.

Probably not your use case, so feel free to close and tell me to go away.

Cheers and thanks.

Receiver context cancelled: i/o timeout

Using HA Supervised on Ubuntu. rtlamr2mqtt version 1.5.2. I tried "rebuiding" the addon without success. This used to work. Maybe a HA Core update broke it? I'm running core-2021.12.3.

Trying to start RTL_TCP: /usr/bin/rtl_tcp -s 2048000
RTL_TCP started with PID 73365
RTL_TCP is ready to receive connections!
server: 127.0.0.1:1234, host: 127.0.0.1, port: 1234
Attempting to tune rtl_tcp to a different freq to shake things up
Successfully tickled rtl_tcp
Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=r900,scm -format=json -filterid=1563533180,2691258 -unique=true
RTLAMR started with PID 73372
09:55:55.988557 decode.go:45: CenterFreq: 912600155
09:55:55.989476 decode.go:46: SampleRate: 2359296
09:55:55.989493 decode.go:47: DataRate: 32768
09:55:55.989496 decode.go:48: ChipLength: 72
09:55:55.989498 decode.go:49: PreambleSymbols: 32
09:55:55.989500 decode.go:50: PreambleLength: 4608
09:55:55.989502 decode.go:51: PacketSymbols: 116
09:55:55.989504 decode.go:52: PacketLength: 16704
09:55:55.989509 decode.go:59: Protocols: r900,scm
09:55:55.989512 decode.go:60: Preambles: 00000000000000001110010101100100,111110010101001100000
09:55:55.989515 main.go:124: GainCount: 29
09:56:00.990892 main.go:343: Receiver context cancelled.
09:56:00.991080 main.go:320: read tcp 127.0.0.1:38638->127.0.0.1:1234: i/o timeout
io.ReadFull
main.(*Receiver).Run.func2
	/go/pkg/mod/github.com/bemasher/[email protected]/main.go:181
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1581
Sleep_for defined, time to sleep!
Terminating all subprocess...
Kill process called.
Killing RTL_TCP...
Killed.
Killing RTLAMR...
Killed in the first attempt.

Configuration:

general:
  sleep_for: 60
  verbosity: debug
mqtt:
  host: core-mosquitto
  port: 1883
  user: ITS_A_ME_MARIO
  password: PASSWORD
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant
custom_parameters:
  rtltcp: '-s 2048000'
  rtlamr: '-unique=true'
meters:
  - id: 1563533180
    protocol: r900
    name: water_meter
    format: '#######.#'
    unit_of_measurement: ft³
    icon: mdi:water-pump
  - id: 2691258
    protocol: scm
    name: gas_meter
    format: '####.##'
    unit_of_measurement: ft³
    icon: mdi:gas-cylinder

Software gets stuck until restart

Is there anything that can be done to prevent the container from being stuck and not processing anything until I restart? Here is an example of my log:

You can see march 2nd it stopped updating, and something is not running. Then I just restarted it and it continues on again until it gets stuck. Usually lasts a few hours to a day before it is stuck like this.

Let me know what info you need from me.

[2022-03-02 02:40:54] {"Time":"2022-03-02T02:40:54.85853604Z","Offset":0,"Length":0,"Type":"SCM+","Message":{"FrameSync":5795,"ProtocolID":30,"EndpointType":171,"EndpointID":12345,"Consumption":189410,"Tamper":18688,"PacketCRC":39682}}
[2022-03-02 02:40:54] Meter "12345" - Consumption 189410. Sending value to MQTT.
[2022-03-02 02:40:54] Predicted reading: 189333.7495830916 - Actual reading: 189410
[2022-03-02 02:40:54] Grow rate avg: 39.44736842105263
[2022-03-02 02:40:54] Possible anomaly detected!
[2022-03-02 02:40:54] Distance from prediction: 76.25041690841317
[2022-03-02 02:40:54] Threshold for anomaly: 189373.19695151263
[2022-03-02 02:40:54] Sending message to MQTT:
[2022-03-02 02:40:54]  > topic => rtlamr/12345/attributes
[2022-03-02 02:40:54]  > payload => {"Message Type": "SCM+", "Predicted": 189333.7495830916, "Anomaly": true, "FrameSync": 5795, "ProtocolID": 30, "EndpointType": 171, "EndpointID": 12345, "Consumption": 189410, "Tamper": 18688, "PacketCRC": 39682}
[2022-03-02 02:40:54]  > retain => True
[2022-03-02 02:40:54] Sending message to MQTT:
[2022-03-02 02:40:54]  > topic => rtlamr/12345/state
[2022-03-02 02:40:54]  > payload => 189410
[2022-03-02 02:40:54]  > retain => True
[2022-03-02 02:40:54] Sleep_for defined, time to sleep!
[2022-03-02 02:40:54] Terminating all subprocess...
[2022-03-02 02:40:54] Kill process called.
[2022-03-02 02:40:54] Killing RTL_TCP...
[2022-03-02 02:40:59] Killed.
[2022-03-02 02:40:59] Killing RTLAMR...
[2022-03-02 02:40:59] Killed in the first attempt.
[2022-03-02 02:40:59] Sleeping for 300 seconds, see you later...
[2022-03-02 02:46:00] Sending message to MQTT:
[2022-03-02 02:46:00]  > topic => rtlamr/status
[2022-03-02 02:46:00]  > payload => online
[2022-03-02 02:46:00]  > retain => True
[2022-03-02 02:46:00] Trying to start RTL_TCP: /usr/bin/rtl_tcp -s 2048000
[2022-03-02 02:46:00] RTL_TCP started with PID 1569
[2022-03-02 02:46:05] RTL_TCP is ready to receive connections!
[2022-03-02 02:46:05] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm+ -format=json -filterid=12345 -unique=true -symbollength=32
[2022-03-02 02:46:05] RTLAMR started with PID 1574
[2022-03-02 02:46:05] 02:46:05.104925 decode.go:45: CenterFreq: 912600155
[2022-03-02 02:46:05] 02:46:05.105145 decode.go:46: SampleRate: 1048576
[2022-03-02 02:46:05] 02:46:05.105158 decode.go:47: DataRate: 32768
[2022-03-02 02:46:05] 02:46:05.105168 decode.go:48: ChipLength: 32
[2022-03-02 02:46:05] 02:46:05.105179 decode.go:49: PreambleSymbols: 16
[2022-03-02 02:46:05] 02:46:05.105189 decode.go:50: PreambleLength: 1024
[2022-03-02 02:46:05] 02:46:05.105199 decode.go:51: PacketSymbols: 128
[2022-03-02 02:46:05] 02:46:05.105209 decode.go:52: PacketLength: 8192
[2022-03-02 02:46:05] 02:46:05.105222 decode.go:59: Protocols: scm+
[2022-03-02 02:46:05] 02:46:05.105233 decode.go:60: Preambles: 0001011010100011
**[2022-03-02 02:46:05] 02:46:05.105244 main.go:124: GainCount: 29
[2022-03-05 00:57:05] Shutdown detected, killing process.**
[2022-03-05 00:57:05] Killing RTL_TCP...
[2022-03-05 00:57:10] Killed.
[2022-03-05 00:57:10] Killing RTLAMR...
[2022-03-05 00:57:10] Killed in the first attempt.
[2022-03-05 00:57:10] Graceful shutdown.
[2022-03-05 00:57:10] Sending message to MQTT:
[2022-03-05 00:57:10]  > topic => rtlamr/status
[2022-03-05 00:57:10]  > payload => offline
[2022-03-05 00:57:10]  > retain => True
[2022-03-05 00:57:14] Configured MQTT sender:
[2022-03-05 00:57:14]  > hostname => 10.150.1.231
[2022-03-05 00:57:14]  > port => 8045
[2022-03-05 00:57:14]  > username => None
[2022-03-05 00:57:14]  > client_id => rtlamr2mqtt
[2022-03-05 00:57:14] Sending message to MQTT:
[2022-03-05 00:57:14]  > topic => rtlamr/status
[2022-03-05 00:57:14]  > payload => online
[2022-03-05 00:57:14]  > retain => True
[2022-03-05 00:57:14] Trying to start RTL_TCP: /usr/bin/rtl_tcp -s 2048000
[2022-03-05 00:57:14] RTL_TCP started with PID 8
[2022-03-05 00:57:19] RTL_TCP is ready to receive connections!
[2022-03-05 00:57:19] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm+ -format=json -filterid=12345 -unique=true -symbollength=32
[2022-03-05 00:57:19] RTLAMR started with PID 13
[2022-03-05 00:57:19] 00:57:19.161118 decode.go:45: CenterFreq: 912600155
[2022-03-05 00:57:19] 00:57:19.162200 decode.go:46: SampleRate: 1048576
[2022-03-05 00:57:19] 00:57:19.162658 decode.go:47: DataRate: 32768
[2022-03-05 00:57:19] 00:57:19.162974 decode.go:48: ChipLength: 32
[2022-03-05 00:57:19] 00:57:19.162999 decode.go:49: PreambleSymbols: 16
[2022-03-05 00:57:19] 00:57:19.163014 decode.go:50: PreambleLength: 1024
[2022-03-05 00:57:19] 00:57:19.163025 decode.go:51: PacketSymbols: 128
[2022-03-05 00:57:19] 00:57:19.163037 decode.go:52: PacketLength: 8192
[2022-03-05 00:57:19] 00:57:19.163052 decode.go:59: Protocols: scm+
[2022-03-05 00:57:19] 00:57:19.163063 decode.go:60: Preambles: 0001011010100011
[2022-03-05 00:57:19] 00:57:19.163075 main.go:124: GainCount: 29

Automatically determine mqtt host, port, username, password with supervisor API

https://developers.home-assistant.io/docs/add-ons/communication#services-api
https://developers.home-assistant.io/docs/api/supervisor/endpoints/#service

The home assistant supervisor exposes an API that exposes the mqtt broker's connection options. It's probably nice to keep the option open for advanced users to override these options if they want to send the mqtt messages somewhere else, but I think it makes sense for these connection options to be the default

Traceback error in logs

I am getting the following error in my logs:

today at 1:22:04 PM Traceback (most recent call last):
today at 1:22:04 PM File "/usr/bin/rtlamr2mqtt.py", line 52, in
today at 1:22:04 PM for amrline in rtlamr.stdout:
today at 1:22:04 PM File "/usr/bin/rtlamr2mqtt.py", line 14, in shutdown
today at 1:22:04 PM mqtt_client.connect(host=mqtt_host, port=mqtt_port)
today at 1:22:04 PM NameError: name 'mqtt_client' is not defined
today at 1:22:04 PM Container stopped
today at 1:24:33 PM Container started
today at 1:22:04 PM NameError: name 'mqtt_client' is not defined
today at 1:24:33 PM Starting in DEBUG Mode...
today at 1:24:33 PM listening...
today at 1:24:35 PM {"Time":"2021-09-12T13:24:35.859423012-04:00","Offset":0,"Length":0,"Message":{"ID":37004912,"Type":4,"TamperPhy":0,"TamperEnc":1,"Consumption":48607,"ChecksumVal":13903}}

Home Assistant Add-On

Would you open to making your project installable as a Home Assistant Add-On? The amount of work to do so is pretty minimal and if I can get a better understanding of your use-case, I think I can put this together in a way that works with your existing workflow.

Crashing after scm+ messages come in

I ran this for months without any problems, and starting today after running for a short period whenever an scm+ message comes in, it looks like rtlamr is crashing as see:

comm recv bye
worker cond timeout
all threads dead..
listening...
Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source
to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).

It never comes back. It runs very stably as well until the scm+ message comes in. Some history here too, my gas meter was replaced today with an scm+ model, hence trying this out today. I went into the container manually and ran the script in /usr/bin/rtlamr2mqtt.py , but can't see where it's crashing, but betting on the decode of the scm+ traffic as dies as soon as a messages comes in.

Thank you for the hard work!

Add on stalls

Add on seems to just sort of stop. I will try and explain as best as i can. The logs do not show any errors, they simply start up as normal, grab one reading per meter defined (2 meters total for me) then sleep for the defined time... Then simply stop. The add on is still enabled. I rolled back a version or two and this continued. The issue started around 24 ish hours ago.

I am typing on my cell here so formatting may be off. The logs below stop at 7:06 but the time now is 7:26. The difference is only 20 minutes in this case as i restarted the add on recently but this spanned to 7 hours overnight with no new lines of log.

general:
  sleep_for: 300
  verbosity: debug
  listen_only: false
  tickle_rtl_tcp: true
  device_id: 0bda:2838
  usb_reset: '001:002'
mqtt:
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant
  base_topic: rtlamr
  tls_enabled: false
  tls_ca: /etc/ssl/certs/ca-certificates.crt
  tls_cert: /etc/ssl/my_self_signed_cert.crt
  tls_keyfile: /etc/ssl/my_self_signed_cert_key.key
  tls_insecure: true
  host: core-mosquitto
  port: 1883
  user: homeassistant
  password: *********
custom_parameters:
  rtltcp: '-s 2048000'
  rtlamr: '-unique=true'
meters:
  - id: 1552820016
    protocol: scm+
    name: production_meter
    format: '#####.##'
    unit_of_measurement: kWh
    icon: mdi:transmission-tower-export
  - id: 1552820019
    protocol: scm+
    name: consumption_meter
    format: '#####.##'
    unit_of_measurement: kWh
    icon: mdi:transmission-tower-import

[```
2022-06-10 06:57:54] > username => homeassistant
[2022-06-10 06:57:54] > client_id => rtlamr2mqtt
[2022-06-10 06:57:54] > base_topic => rtlamr
[2022-06-10 06:57:54] > availability_topic => rtlamr/status
[2022-06-10 06:57:54] > tls => None
[2022-06-10 06:57:54] Reseting USB device: /dev/bus/usb/001/002
[2022-06-10 06:57:55] Reset sucessful.
[2022-06-10 06:57:55] Sending message to MQTT:
[2022-06-10 06:57:55] > topic => rtlamr/status
[2022-06-10 06:57:55] > payload => online
[2022-06-10 06:57:55] > retain => True
[2022-06-10 06:57:55] Trying to start RTL_TCP: /usr/bin/rtl_tcp -d 0 -s 2048000
[2022-06-10 06:57:55] RTL_TCP started with PID 10
[2022-06-10 06:58:00] RTL_TCP is ready to receive connections!
[2022-06-10 06:58:00] Attempting to tune rtl_tcp to a different freq to shake things up
[2022-06-10 06:58:00] server: 127.0.0.1:1234, host: 127.0.0.1, port: 1234
[2022-06-10 06:58:00] Successfully tickled rtl_tcp
[2022-06-10 06:58:00] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm+,scm+ -format=json -filterid=1552820016,1552820019 -unique=true
[2022-06-10 06:58:00] RTLAMR started with PID 17
[2022-06-10 06:58:00] 06:58:00.491878 decode.go:45: CenterFreq: 912600155
[2022-06-10 06:58:00] 06:58:00.492280 decode.go:46: SampleRate: 2359296
[2022-06-10 06:58:00] 06:58:00.492305 decode.go:47: DataRate: 32768
[2022-06-10 06:58:00] 06:58:00.492317 decode.go:48: ChipLength: 72
[2022-06-10 06:58:00] 06:58:00.492327 decode.go:49: PreambleSymbols: 16
[2022-06-10 06:58:00] 06:58:00.492337 decode.go:50: PreambleLength: 2304
[2022-06-10 06:58:00] 06:58:00.492347 decode.go:51: PacketSymbols: 128
[2022-06-10 06:58:00] 06:58:00.492357 decode.go:52: PacketLength: 18432
[2022-06-10 06:58:00] 06:58:00.492370 decode.go:59: Protocols: scm+
[2022-06-10 06:58:00] 06:58:00.492381 decode.go:60: Preambles: 0001011010100011
[2022-06-10 06:58:00] 06:58:00.492392 main.go:124: GainCount: 29
[2022-06-10 06:58:38] {"Time":"2022-06-10T06:58:38.396545658-03:00","Offset":0,"Length":0,"Type":"SCM+","Message":{"FrameSync":5795,"ProtocolID":30,"EndpointType":7,"EndpointID":1552820019,"Consumption":656813,"Tamper":0,"PacketCRC":32787}}
[2022-06-10 06:58:38] Meter "1552820019" - Consumption 06568.13. Sending value to MQTT.
[2022-06-10 06:58:38] Sending MQTT autodiscovery payload to Home Assistant...
[2022-06-10 06:58:38] Sending message to MQTT:
[2022-06-10 06:58:38] > topic => homeassistant/sensor/rtlamr/consumption_meter/config
[2022-06-10 06:58:38] > payload => {"name": "consumption_meter", "unique_id": "1552820019", "unit_of_measurement": "kWh", "icon": "mdi:transmission-tower-import", "availability_topic": "rtlamr/status", "state_class": "total_increasing", "state_topic": "rtlamr/1552820019/state", "json_attributes_topic": "rtlamr/1552820019/attributes"}
[2022-06-10 06:58:38] > qos => 1
[2022-06-10 06:58:38] > retain => True
[2022-06-10 06:58:38] Sending message to MQTT:
[2022-06-10 06:58:38] > topic => rtlamr/1552820019/attributes
[2022-06-10 06:58:38] > payload => {"Message Type": "SCM+", "FrameSync": 5795, "ProtocolID": 30, "EndpointType": 7, "EndpointID": 1552820019, "Consumption": 656813, "Tamper": 0, "PacketCRC": 32787}
[2022-06-10 06:58:38] > retain => True
[2022-06-10 06:58:38] Sending message to MQTT:
[2022-06-10 06:58:38] > topic => rtlamr/1552820019/state
[2022-06-10 06:58:38] > payload => 06568.13
[2022-06-10 06:58:38] > retain => True
[2022-06-10 07:01:38] {"Time":"2022-06-10T07:01:38.515777393-03:00","Offset":0,"Length":0,"Type":"SCM+","Message":{"FrameSync":5795,"ProtocolID":30,"EndpointType":7,"EndpointID":1552820019,"Consumption":656814,"Tamper":0,"PacketCRC":55619}}
[2022-06-10 07:01:38] Meter "1552820019" - Consumption 06568.14. Sending value to MQTT.
[2022-06-10 07:01:38] Sending message to MQTT:
[2022-06-10 07:01:38] > topic => rtlamr/1552820019/attributes
[2022-06-10 07:01:38] > payload => {"Message Type": "SCM+", "FrameSync": 5795, "ProtocolID": 30, "EndpointType": 7, "EndpointID": 1552820019, "Consumption": 656814, "Tamper": 0, "PacketCRC": 55619}
[2022-06-10 07:01:38] > retain => True
[2022-06-10 07:01:38] Sending message to MQTT:
[2022-06-10 07:01:38] > topic => rtlamr/1552820019/state
[2022-06-10 07:01:38] > payload => 06568.14
[2022-06-10 07:01:38] > retain => True
[2022-06-10 07:01:50] {"Time":"2022-06-10T07:01:50.038929825-03:00","Offset":0,"Length":0,"Type":"SCM+","Message":{"FrameSync":5795,"ProtocolID":30,"EndpointType":7,"EndpointID":1552820016,"Consumption":432586,"Tamper":0,"PacketCRC":17644}}
[2022-06-10 07:01:50] Meter "1552820016" - Consumption 04325.86. Sending value to MQTT.
[2022-06-10 07:01:50] Sending MQTT autodiscovery payload to Home Assistant...
[2022-06-10 07:01:50] Sending message to MQTT:
[2022-06-10 07:01:50] > topic => homeassistant/sensor/rtlamr/production_meter/config
[2022-06-10 07:01:50] > payload => {"name": "production_meter", "unique_id": "1552820016", "unit_of_measurement": "kWh", "icon": "mdi:transmission-tower-export", "availability_topic": "rtlamr/status", "state_class": "total_increasing", "state_topic": "rtlamr/1552820016/state", "json_attributes_topic": "rtlamr/1552820016/attributes"}
[2022-06-10 07:01:50] > qos => 1
[2022-06-10 07:01:50] > retain => True
[2022-06-10 07:01:50] Sending message to MQTT:
[2022-06-10 07:01:50] > topic => rtlamr/1552820016/attributes
[2022-06-10 07:01:50] > payload => {"Message Type": "SCM+", "FrameSync": 5795, "ProtocolID": 30, "EndpointType": 7, "EndpointID": 1552820016, "Consumption": 432586, "Tamper": 0, "PacketCRC": 17644}
[2022-06-10 07:01:50] > retain => True
[2022-06-10 07:01:50] Sending message to MQTT:
[2022-06-10 07:01:50] > topic => rtlamr/1552820016/state
[2022-06-10 07:01:50] > payload => 04325.86
[2022-06-10 07:01:50] > retain => True
[2022-06-10 07:01:50] Sleep_for defined, time to sleep!
[2022-06-10 07:01:50] Terminating all subprocess...
[2022-06-10 07:01:50] Kill process called.
[2022-06-10 07:01:50] Killing RTLAMR...
[2022-06-10 07:01:50] Killed in the first attempt.
[2022-06-10 07:01:50] Sleeping for 300 seconds, see you later...
[2022-06-10 07:06:50] Reseting USB device: /dev/bus/usb/001/002
[2022-06-10 07:06:50] Reset sucessful.
[2022-06-10 07:06:50] Sending message to MQTT:
[2022-06-10 07:06:50] > topic => rtlamr/status
[2022-06-10 07:06:50] > payload => online
[2022-06-10 07:06:50] > retain => True
[2022-06-10 07:06:51] Attempting to tune rtl_tcp to a different freq to shake things up
[2022-06-10 07:06:51] server: 127.0.0.1:1234, host: 127.0.0.1, port: 1234
[2022-06-10 07:06:51] Successfully tickled rtl_tcp
[2022-06-10 07:06:51] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm+,scm+ -format=json -filterid=1552820016,1552820019 -unique=true
[2022-06-10 07:06:51] RTLAMR started with PID 29
[2022-06-10 07:06:51] 07:06:51.902553 decode.go:45: CenterFreq: 912600155
[2022-06-10 07:06:51] 07:06:51.902754 decode.go:46: SampleRate: 2359296
[2022-06-10 07:06:51] 07:06:51.902765 decode.go:47: DataRate: 32768
[2022-06-10 07:06:51] 07:06:51.902772 decode.go:48: ChipLength: 72
[2022-06-10 07:06:51] 07:06:51.902777 decode.go:49: PreambleSymbols: 16
[2022-06-10 07:06:51] 07:06:51.902783 decode.go:50: PreambleLength: 2304
[2022-06-10 07:06:51] 07:06:51.902788 decode.go:51: PacketSymbols: 128
[2022-06-10 07:06:51] 07:06:51.902794 decode.go:52: PacketLength: 18432
[2022-06-10 07:06:51] 07:06:51.902801 decode.go:59: Protocols: scm+
[2022-06-10 07:06:51] 07:06:51.902807 decode.go:60: Preambles: 0001011010100011
[2022-06-10 07:06:51] 07:06:51.902813 main.go:124: GainCount: 29

MQTT Sensor Unavailable

Recently my meter in mqtt has been unavailable. It may be related to issue #71

I'm using 1.5.5 in HA. My sensor is showing up as unavailable. I see two topic published from the rtlamr2mqrt logs. I used the mqtt integration to manually subscribe to these topics and here is what I get back.
topic: homeassistant/sensor/rtlamr/gas_meter/config

{
    "name": "gas_meter",
    "unique_id": "2691258",
    "unit_of_measurement": "ft³",
    "icon": "mdi:gas-cylinder",
    "device_class": null,
    "availability_topic": "rtlamr/status",
    "state_class": "total_increasing",
    "state_topic": "rtlamr/2691258/state",
    "value_template": "{{ value_json.Message.Consumption | float }}",
    "json_attributes_topic": "rtlamr/2691258/state",
    "json_attributes_template": "{{ value_json.Message | tojson }}"
}

topic: rtlamr/2691258/state and I get the following results:

{
    "Time": "2022-01-16T20:48:29.30570082-05:00",
    "Offset": 0,
    "Length": 0,
    "Type": "SCM",
    "Message": {
        "ID": 2691258,
        "Type": 12,
        "TamperPhy": 3,
        "TamperEnc": 0,
        "Consumption": "3035.54",
        "ChecksumVal": 41625,
        "Predicted": 3035.5398942749307,
        "Anomaly": false
    }
}

My config file:

general:
  sleep_for: 60
  verbosity: debug
  tickle_rtl_tcp: false
  debug: true
mqtt:
  host: core-mosquitto
  port: 1883
  user: USERNAME
  password: PASSWORD
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant
custom_parameters:
  rtltcp: '-s 2048000'
  rtlamr: '-unique=true'
meters:
  - id: 2691258
    protocol: scm
    name: gas_meter
    format: '####.##'
    unit_of_measurement: ft³
    icon: mdi:gas-cylinder

Do I now need to add the mqtt topic to configuration.yaml? ha_autodiscovery is enabled so I didn't think it was necessary.

Edit: The issue might also be that the MQTT integration is looking for status messages on topic homeassistant/status instead of rtlarm/status
image

No data or "meters" showing up in HA

After setting up the Home Assistant add-on and configuring it as shows in the docs, I am not getting a sensor in HA. In Mosquitto I listened for "rtlamr/status" and got "online", but I'm not getting anything when I listen for "rtlamr/gas_meter/state".

Here is my config:

general:
  sleep_for: 300
  verbosity: debug
  tickle_rtl_tcp: true
  device_id: 0bda:2838
mqtt:
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant
  tls_enabled: false
  tls_ca: /etc/ssl/certs/ca-certificates.crt
  tls_cert: /etc/ssl/my_self_signed_cert.crt
  tls_keyfile: /etc/ssl/my_self_signed_cert_key.key
  tls_insecure: true
  host: <HA Blue internal IP Address)
  port: 1883
  user: mqtt-user
  password: <redacted>
custom_parameters:
  rtltcp: '-s 2048000'
  rtlamr: '-unique=true'
meters:
  - id: 265087065 #not sure if this should have the 2 at the beginning or not, but I tried both ways.
    protocol: scm
    name: gas_meter
    format: '####.###'
    unit_of_measurement: ft³
    icon: mdi:gas_canister
    device_class: gas
    state_class: total_increasing

Here is my log for the add-on:

[2022-05-12 11:54:48] RTLAMR2MQTT Starting...

[2022-05-12 11:54:48] RTL SDR Device 0bda:2838 found on USB port 001:005 - Index: 0

[2022-05-12 11:54:48] Configured MQTT sender:

[2022-05-12 11:54:48]  > hostname => <HA Blue Internal IP Address

[2022-05-12 11:54:48]  > port => 1883

[2022-05-12 11:54:48]  > username => mqtt-user

[2022-05-12 11:54:48]  > client_id => rtlamr2mqtt

[2022-05-12 11:54:48]  > tls => None

[2022-05-12 11:54:48] Reseting USB device: /dev/bus/usb/001/005

[2022-05-12 11:54:49] Reset sucessful.

[2022-05-12 11:54:49] Sending message to MQTT:

[2022-05-12 11:54:49]  > topic => rtlamr/status

[2022-05-12 11:54:49]  > payload => online

[2022-05-12 11:54:49]  > retain => True

[2022-05-12 11:54:49] Trying to start RTL_TCP: /usr/bin/rtl_tcp -d 0 -s 2048000

[2022-05-12 11:54:49] RTL_TCP started with PID 10

[2022-05-12 11:54:54] RTL_TCP is ready to receive connections!

[2022-05-12 11:54:54] server: 127.0.0.1:1234, host: 127.0.0.1, port: 1234

[2022-05-12 11:54:54] Attempting to tune rtl_tcp to a different freq to shake things up

[2022-05-12 11:54:54] Successfully tickled rtl_tcp

[2022-05-12 11:54:54] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm -format=json -filterid=265087065 -unique=true

[2022-05-12 11:54:54] RTLAMR started with PID 17

[2022-05-12 11:54:54] 11:54:54.519576 decode.go:45: CenterFreq: 912600155

[2022-05-12 11:54:54] 11:54:54.519848 decode.go:46: SampleRate: 2359296

[2022-05-12 11:54:54] 11:54:54.519858 decode.go:47: DataRate: 32768

[2022-05-12 11:54:54] 11:54:54.519864 decode.go:48: ChipLength: 72

[2022-05-12 11:54:54] 11:54:54.519869 decode.go:49: PreambleSymbols: 21

[2022-05-12 11:54:54] 11:54:54.519874 decode.go:50: PreambleLength: 3024

[2022-05-12 11:54:54] 11:54:54.519879 decode.go:51: PacketSymbols: 96

[2022-05-12 11:54:54] 11:54:54.519884 decode.go:52: PacketLength: 13824

[2022-05-12 11:54:54] 11:54:54.519893 decode.go:59: Protocols: scm

[2022-05-12 11:54:54] 11:54:54.519899 decode.go:60: Preambles: 111110010101001100000

[2022-05-12 11:54:54] 11:54:54.519904 main.go:124: GainCount: 29

state class exceeding 255 chars

So over night my gas sensor stopped working and my HomeAssistant logs began to fill with a repeated error:

2022-02-09 15:03:16 ERROR (MainThread) [homeassistant.util.logging] Exception in message_received when handling msg on 'rtlamr/98546445/state': '{"Time": "2022-02-09T23:03:16.552376855Z", "Offset": 0, "Length": 0, "Type": "SCM+", "Message": {"FrameSync": 5795, "ProtocolID": 30, "EndpointType": 156, "EndpointID": 98546445, "Consumption": "60090", "Tamper": 3592, "PacketCRC": 29813, "Predicted": 60110.93482659571, "Anomaly": false}}'
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.gas. State max length is 255 characters.

I'm not sure what changed to suddenly upset the state class limit, if it was my update to 2022.2.x or something else, but now my gas meter is no longer reporting any info, as it's state class has ~280 some odd characters in it.

Am I doing something wrong that's causing too much information to be dumped into the state, or was there a change in 2022.2.X that made it more sensitive to the output from rtlamr2mqtt that's making the data in mqtt no longer valid to parse? (I did see there was a lot of MQTT work in 2022.2.1 through 4 so maybe that had something to do with this?)

Edit: It does seem the comment threads in Home Assistant are reporting a plethora of MQTT pains for users, so I'm leaning towards this not being something I am doing wrong, and I might need to just sit tight.

Breaking change from new update

Helloe there, i updated today and immediately ran into trouble. Im unable to remove the USB part of the config.

[2022-04-12 18:56:37] Configured MQTT sender:
[2022-04-12 18:56:37] > hostname => core-mosquitto
[2022-04-12 18:56:37] > port => 1883
[2022-04-12 18:56:37] > username => homeassistant
[2022-04-12 18:56:37] > client_id => rtlamr2mqtt
[2022-04-12 18:56:37] > tls => None
[2022-04-12 18:56:37] Reseting USB device: /dev/bus/usb/005/002
Traceback (most recent call last):
File "/usr/bin/rtlamr2mqtt.py", line 403, in
reset_usb_device(usb_reset)
File "/usr/bin/rtlamr2mqtt.py", line 34, in reset_usb_device
fd = open(filename, "wb")
FileNotFoundError: [Errno 2] No such file or directory: '/dev/bus/usb/005/002'

NumPy error after recent Docker update

I can't pinpoint exactly when this started, but updating Docker is the only thing I can think of that's changed.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/usr/lib/python3/dist-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/usr/lib/python3/dist-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libblas.so.3: cannot open shared object file: No such file or director
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/bin/rtlamr2mqtt.py", line 18, in <module>
    import numpy as np
  File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
    https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
  * The Python version is: Python3.9 from "/usr/bin/python3"
  * The NumPy version is: "1.19.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libblas.so.3: cannot open shared object file: No such file or directory

I removed the container and the image and pulled a new image without resolution.

Thanks,
LB

Meter readings are off by 10x since upgrade from 1.3.3

I am using the rtlamr2mqtt add-on and missed that there have been a bunch of updates since 1.3.3. I upgraded today and now my gas meter is off by a factor of 10. My gas meter reports in 10's of ft³ which I set format: '#######0' to account for this. After upgrading my gas meter readings are 1/10 of what they should be.

My config: https://gist.github.com/drmulligan/b9c648e0be2048977e9480719c498cd0

Logs: https://gist.github.com/drmulligan/e372d3758112dc7e17bb767a83a2fe20

In the case logged above the consumption should be 8293150 ft³ but it's being reported as 829315 ft³.

Mismatched Paren

This has been going strong for me for many months, still love the work. Latest update caused a little hiccup.

From the logs:

File "/usr/bin/rtlamr2mqtt.py", line 86
config['meters'][idx]['name'] = str(meter.get('name', 'meter_{}'.format(meter['id']))
^
SyntaxError: '(' was never closed

Adding one trailing paren seems to fix it all up.

v1.7.1

I don't think #105 is fixed yet for add-on users since that bug fix was never pushed to the docker repo. Would it be possible to push the bug fix?

rtlamr2mqtt not working after most recent updates

I am getting the errors below when attempting to run the most recent docker for rtlamr2mqtt. Everything was working fine before the most recent updates.

Any suggestions?

Thanks,
Dan

`Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/numpy/core/init.py", line 22, in
from . import multiarray
File "/usr/lib/python3/dist-packages/numpy/core/multiarray.py", line 12, in
from . import overrides
File "/usr/lib/python3/dist-packages/numpy/core/overrides.py", line 7, in
from numpy.core._multiarray_umath import (
ImportError: libblas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/rtlamr2mqtt.py", line 18, in
import numpy as np
File "/usr/lib/python3/dist-packages/numpy/init.py", line 140, in
from . import core
File "/usr/lib/python3/dist-packages/numpy/core/init.py", line 48, in
raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for

many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.9 from "/usr/bin/python3"

  • The NumPy version is: "1.19.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libblas.so.3: cannot open shared object file: No such file or directory`

external_rtl_tcp is not defined

Looks like with the newest patch, if you don't have the custom section defined, you can't even start.


rtlamr2mqtt | Traceback (most recent call last):
rtlamr2mqtt |   File "/usr/bin/rtlamr2mqtt.py", line 209, in <module>
rtlamr2mqtt |     if not external_rtl_tcp and ('rtltcp' not in locals() or rtltcp.poll() is not None):
rtlamr2mqtt | NameError: name 'external_rtl_tcp' is not defined

Unknown exception connecting to MQTT broker: [Errno 2] No such file or directory

First, thanks for your work on this project. I've been running rtlamr on my Linux server for a while and have finally gotten to a point where I wanted to switch it over to Docker. This project looks like it fits my needs perfectly!

As noted above, I am getting an error when trying to use the docker container. Here's the logs:

[2022-04-08 12:35:24] Sending message to MQTT:,
[2022-04-08 12:35:24]  > topic => rtlamr/status,
[2022-04-08 12:35:24]  > payload => offline,
[2022-04-08 12:35:24]  > retain => True,
[2022-04-08 12:35:24] Unknown exception connecting to MQTT broker: [Errno 2] No such file or directory,
[2022-04-08 12:35:25] Configured MQTT sender:,
[2022-04-08 12:35:25]  > hostname => 192.168.0.25,
[2022-04-08 12:35:25]  > port => 1883,
[2022-04-08 12:35:25]  > username => hass,
[2022-04-08 12:35:25]  > client_id => rtlamr2mqtt,
[2022-04-08 12:35:25]  > tls => {'ca_certs': '/etc/ssl/certs/ca-certificates.crt', 'certfile': '/etc/ssl/my_self_signed_cert.crt', 'insecure': True, 'keyfile': '/etc/ssl/my_self_signed_cert_key.key', 'tls_version': None, 'ciphers': None},
[2022-04-08 12:35:25] Sending message to MQTT:,
[2022-04-08 12:35:25]  > topic => rtlamr/status,
[2022-04-08 12:35:25]  > payload => online,
[2022-04-08 12:35:25]  > retain => True,
[2022-04-08 12:35:25] Unknown exception connecting to MQTT broker: [Errno 2] No such file or directory,
[2022-04-08 12:35:25] Trying to start RTL_TCP: /usr/bin/rtl_tcp -s 14448385,
[2022-04-08 12:35:25] RTL_TCP started with PID 7,
[2022-04-08 12:35:30] RTL_TCP is ready to receive connections!,
[2022-04-08 12:35:30] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm+ -format=json -filterid=14448385 -unique=true -symbollength=32,
[2022-04-08 12:35:30] RTLAMR started with PID 13,
[2022-04-08 12:35:30] 12:35:30.626183 decode.go:45: CenterFreq: 912600155,
[2022-04-08 12:35:30] 12:35:30.626264 decode.go:46: SampleRate: 1048576,
[2022-04-08 12:35:30] 12:35:30.626271 decode.go:47: DataRate: 32768,
[2022-04-08 12:35:30] 12:35:30.626276 decode.go:48: ChipLength: 32,
[2022-04-08 12:35:30] 12:35:30.626545 decode.go:49: PreambleSymbols: 16,
[2022-04-08 12:35:30] 12:35:30.626553 decode.go:50: PreambleLength: 1024,
[2022-04-08 12:35:30] 12:35:30.626557 decode.go:51: PacketSymbols: 128,
[2022-04-08 12:35:30] 12:35:30.626562 decode.go:52: PacketLength: 8192,
[2022-04-08 12:35:30] 12:35:30.626568 decode.go:59: Protocols: scm+,
[2022-04-08 12:35:30] 12:35:30.626572 decode.go:60: Preambles: 0001011010100011,
[2022-04-08 12:35:30] 12:35:30.626577 main.go:124: GainCount: 29,
[2022-04-08 12:46:38] Shutdown detected, killing process.,
[2022-04-08 12:46:38] Killing RTL_TCP...,
[2022-04-08 12:46:43] Killed.,
[2022-04-08 12:46:43] Killing RTLAMR...,
[2022-04-08 12:46:43] Killed in the first attempt.,
[2022-04-08 12:46:43] Graceful shutdown.,

and here's my rtlamr2mqtt.yaml file:

general:
  sleep_for: 0
  verbosity: debug
  tickle_rtl_tcp: false
  usb_reset: '002:004'

mqtt:
  host: 192.168.0.25
  # Path to CA certificate to use. Mandatory
  tls_ca: '/etc/ssl/certs/ca-certificates.crt'
  # Path to certificate file to use. Optional
  tls_cert: '/etc/ssl/my_self_signed_cert.crt'
  # TLS insecure: defaults to False
  tls_insecure: true
  # Certificate key file to use. Optional
  tls_keyfile: '/etc/ssl/my_self_signed_cert_key.key'
  user: 'hass'
  password: 'XXXXXXXXXXX'
  ha_autodiscovery: true
  ha_autodiscovery_topic: homeassistant

custom_parameters:
  rtltcp: "-s 14448385"
  rtlamr: "-unique=true -symbollength=32"

meters:
  - id: 14448385
    protocol: scm+
    name: test_meter
    format: "######.###"
    unit_of_measurement: "\u33A5"
    icon: mdi:gauge
    device_class: energy

and finally, my docker-compose entries:

  rtlamr:
    container_name: rtlamr2mqtt
    image: allangood/rtlamr2mqtt
    restart: unless-stopped
    depends_on:
      - rtl433
    devices:
      - /dev/bus/usb
    volumes:
      - /sharedfolders/appdata/rtlamr2mqtt/rtlamr2mqtt.yaml:/etc/rtlamr2mqtt.yaml:ro
      - /sharedfolders/appdata/rtlamr2mqtt/data:/var/lib/rtlamr2mqtt

It appears that the container is reading the config correctly but I'm not sure why it's having a hard time connecting to the MQTT broker. I'm using it successfully with a handful of other containers. This is, however, the first time I've tried using a user for connecting as my broker accepts anonymous connections.

Any help in troubleshooting this is most appreciated!

Docker build failure

WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv WARNING: You are using pip version 21.1.2; however, version 21.2.4 is available. You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command. Connecting to github.com (140.82.114.4:443) wget: server returned error: HTTP/1.1 404 Not Found The command '/bin/sh -c apk update && apk add rtl-sdr && pip3 install -r /tmp/requirements.txt && chmod 755 /usr/bin/rtlamr2mqtt.py && case ${TARGETPLATFORM} in "linux/amd64") ARCH=amd64 ;; "linux/arm64") ARCH=arm64 ;; "linux/arm/v7") ARCH=arm ;; "linux/arm/v6") ARCH=arm ;; "linux/386") ARCH=i386 ;; esac && wget https://github.com/bemasher/rtlamr/releases/download/${RTLAMR_VERSION}/rtlamr_linux_${ARCH}.tar.gz && tar zxvf rtlamr_linux_${ARCH}.tar.gz && chmod 755 rtlamr && mv rtlamr /usr/bin && rm -f /tmp/*' returned a non-zero code: 1

rtlamr failing to get any data from rtl_tcp

At some point today (~4 hours ago), rtlamr2mqtt stopped publishing updates for my electric meter. This is the pattern I'm seeing in the logs:

[2022-02-09 18:24:32] Trying to start RTL_TCP: /usr/bin/rtl_tcp -s 2048000
[2022-02-09 18:24:32] RTL_TCP started with PID 9
[2022-02-09 18:24:37] RTL_TCP is ready to receive connections!
[2022-02-09 18:24:37] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm+ -format=json -filterid=1552644360 -unique=true
[2022-02-09 18:24:37] RTLAMR started with PID 14
[2022-02-09 18:24:37] 18:24:37.077545 decode.go:45: CenterFreq: 912600155
[2022-02-09 18:24:37] 18:24:37.078061 decode.go:46: SampleRate: 2359296
[2022-02-09 18:24:37] 18:24:37.078082 decode.go:47: DataRate: 32768
[2022-02-09 18:24:37] 18:24:37.078093 decode.go:48: ChipLength: 72
[2022-02-09 18:24:37] 18:24:37.078104 decode.go:49: PreambleSymbols: 16
[2022-02-09 18:24:37] 18:24:37.078114 decode.go:50: PreambleLength: 2304
[2022-02-09 18:24:37] 18:24:37.078124 decode.go:51: PacketSymbols: 128
[2022-02-09 18:24:37] 18:24:37.078134 decode.go:52: PacketLength: 18432
[2022-02-09 18:24:37] 18:24:37.078151 decode.go:59: Protocols: scm+
[2022-02-09 18:24:37] 18:24:37.078161 decode.go:60: Preambles: 0001011010100011
[2022-02-09 18:24:37] 18:24:37.078172 main.go:124: GainCount: 29
[2022-02-09 18:24:42] 18:24:42.083166 main.go:343: Receiver context cancelled.
[2022-02-09 18:24:42] 18:24:42.085118 main.go:320: read tcp 127.0.0.1:40362->127.0.0.1:1234: i/o timeout
[2022-02-09 18:24:42] io.ReadFull
[2022-02-09 18:24:42] main.(*Receiver).Run.func2
[2022-02-09 18:24:42] 	/go/pkg/mod/github.com/bemasher/[email protected]/main.go:181
[2022-02-09 18:24:42] runtime.goexit
[2022-02-09 18:24:42] 	/usr/local/go/src/runtime/asm_arm64.s:1133

There's a 5 second deadline being added here: https://github.com/bemasher/rtlamr/blob/master/main.go#L174
And then the error's coming from just a couple lines further down: https://github.com/bemasher/rtlamr/blob/master/main.go#L181

'formatted_reading' or 'formated_reading'

Hello,

After the recent update 1.4.0 I am receiving the below error message when messages are sent from my water and gas meter. No information is forwarded to the MQTT broker.
Reviewing rtlamr2mqtt.py it appears two different spellings ('formatted_reading' and 'formated_reading') have been used in the code. Any suggestion for how to correct this?
Awesome product by the way. Thank you.


{"Time":"2021-11-26T15:57:04.648837908Z","Offset":0,"Length":0,"Type":"R900","Message":{"ID":XXXXXXXXX,"Unkn1":131,"NoUse":32,"BackFlow":0,"Consumption":1135248,"Unkn3":0,"Leak":1,"LeakNow":0}}
Meter "XXXXXXXXX" - Consumption 113524.8. Sending value to MQTT.
Traceback (most recent call last):
File "/usr/bin/rtlamr2mqtt.py", line 384, in
msg_payload = formatted_reading
NameError: name 'formatted_reading' is not defined. Did you mean: 'formated_reading'?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.