allangood / rtlamr2mqtt

Docker container to send rtlamr readings to a mqtt broker
MIT License
292 stars 47 forks source link

rtlarm2mqtt container seems not to start rtl_tcp #196

Closed prometheanfire closed 1 year ago

prometheanfire commented 1 year ago

If I sign into the container and start it manually rtlamr will connect.

I'm using the container in a k8s cluster with the following helm config

image:
  repository: allangood/rtlamr2mqtt
  pullPolicy: IfNotPresent
  tag: sha-b6ce7b8
persistence:
  config:
    type: configMap
    enabled: true
    mountPath: /etc/rtlamr2mqtt.yaml
    subPath: rtlamr2mqtt.yaml
    name: rtlamr2mqtt-config
  usb:
    enabled: true
    type: hostPath
    hostPath: /dev/bus/usb
  data:
    enabled: true
    retain: true
    mountPath: /var/lib/rtlamr2mqtt
    storageClass: freenas-iscsi-retain-csi
    accessMode: ReadWriteOnce
    size: 5Gi
# needed so that rtlsdr can actually talk to the usb device
securityContext:
  privileged: true
# needed to assign to node with the usb device to use
affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
        - matchExpressions:
          - key: rtlamr2mqtt
            operator: In
            values:
              - 'true'
service:
  main:
    enabled: false
configMaps:
  config:
    enabled: true
    data:
      rtlamr2mqtt.yaml: |-
        general:
          sleep_for: 30
          verbosity: debug
        mqtt:
          ha_autodiscovery: true
          ha_autodiscovery_topic: homeassistant
          base_topic: rtlamr
          host: mosquitto.home-assistant.svc
          port: 1883
          user: mqtt
        meters:
         foo: bar
         baz: buz

and here is the debug log, it's not showing it starting rtl_tcp like I'd expect from https://github.com/allangood/rtlamr2mqtt/blob/main/rtlamr2mqtt-addon/rtlamr2mqtt.py#L382

[2023-04-21 15:03:23] RTLAMR2MQTT Starting...
[2023-04-21 15:03:23] Using "/etc/rtlamr2mqtt.yaml" config file
[2023-04-21 15:03:23] Using an external RTL_TCP session at local
[2023-04-21 15:03:23] Configured MQTT sender:
[2023-04-21 15:03:23]  > hostname => mosquitto.home-assistant.svc
[2023-04-21 15:03:23]  > port => 1883
[2023-04-21 15:03:23]  > username => mqtt
[2023-04-21 15:03:23]  > client_id => rtlamr2mqtt
[2023-04-21 15:03:23]  > base_topic => rtlamr
[2023-04-21 15:03:23]  > availability_topic => rtlamr/status
[2023-04-21 15:03:23]  > tls => None
[2023-04-21 15:03:23] Sending message to MQTT:
[2023-04-21 15:03:23]  > topic => rtlamr/status
[2023-04-21 15:03:23]  > payload => online
[2023-04-21 15:03:23]  > retain => True
[2023-04-21 15:03:23] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=r900,idm,scm -format=json -filterid=1,2,3 -unique=true
[2023-04-21 15:03:23] RTLAMR started with PID 8
[2023-04-21 15:03:23] 15:03:23.067775 main.go:90: Error connecting to spectrum server: dial tcp 127.0.0.1:1234: connect: connection refused
[2023-04-21 15:03:23] rcvr.Connect
[2023-04-21 15:03:23] main.(*Receiver).NewReceiver
[2023-04-21 15:03:23]   /go/pkg/mod/github.com/bemasher/rtlamr@v0.9.3/main.go:90
[2023-04-21 15:03:23] main.main
[2023-04-21 15:03:23]   /go/pkg/mod/github.com/bemasher/rtlamr@v0.9.3/main.go:313
[2023-04-21 15:03:23] runtime.main
[2023-04-21 15:03:23]   /usr/local/go/src/runtime/proc.go:250
[2023-04-21 15:03:23] runtime.goexit
[2023-04-21 15:03:23]   /usr/local/go/src/runtime/asm_arm64.s:1172
[2023-04-21 15:03:23] Sleep_for defined, time to sleep!
[2023-04-21 15:03:23] Terminating all subprocess...
[2023-04-21 15:03:23] Kill process called.
[2023-04-21 15:03:23] Killing RTLAMR...
[2023-04-21 15:03:23] Killed in the first attempt.
[2023-04-21 15:03:23] Sleeping for 30 seconds, see you later...

again, if I shell into the container and manually run rtl_tcp it'll connect and work fine (connects after waking up from sleep). I have a rtl_433 container with another of the same usb stick that works fine. I also have it connected to a external powered usb hub, just in case.

prometheanfire commented 1 year ago

as with most things, after submitting the bug I find the issue.

adding rtltcp_server: '127.0.0.1:1234' to the general section of the config seems to be necessary to when running within the container.