allangood / rtlamr2mqtt

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

Reset of USB devices when waking up after sleep, causing other add-on to terminate #195

Closed pbear7656977 closed 1 year ago

pbear7656977 commented 1 year ago

Starting around 12pm 18Apr2023, found that rtl-433 add-on stopped running, once looking at logs found that issue was could no longer find device (logs pasted below). I had this issue in the past where the two add-ons were trying to use same SDR, so I went in and changed serial numbers of radios, then defined within each add-on configuration to use a specific radio. This resolved issue in past and had not had any issues until the other day. I was able to go in and reset yesterday and get both add-ons running. Came home today and saw this is has repeated itself again, with rtlamr2mqtt resetting USB device after waking from sleep, which in turn causes rtl-433 to shut down.

Below are the logs from the add-on. Confirmed updated to latest version of 2.3.3. Have had both this and pbkhrv/rtl_433-hass-addons without issue up to this point after assigning devices to use for each add-on. I am running 2 separate radios under rlt-433 and then one under rtlamr2mqtt.

Logs from rtlamr2mqtt: [2023-04-20 19:09:28] Sleep_for defined, time to sleep! [2023-04-20 19:09:28] Terminating all subprocess... [2023-04-20 19:09:28] Kill process called. [2023-04-20 19:09:28] Killing RTL_TCP... [2023-04-20 19:09:33] Killed. [2023-04-20 19:09:33] Killing RTLAMR... [2023-04-20 19:09:33] Killed in the first attempt. [2023-04-20 19:09:33] Sleeping for 300 seconds, see you later... [2023-04-20 19:14:33] Reseting USB device: /dev/bus/usb/001/011 [2023-04-20 19:14:33] Reset sucessful. [2023-04-20 19:14:33] Sending message to MQTT: [2023-04-20 19:14:33] > topic => rtlamr/status [2023-04-20 19:14:33] > payload => online [2023-04-20 19:14:33] > retain => True [2023-04-20 19:14:33] Trying to start RTL_TCP: /usr/bin/rtl_tcp -d 2 -s 2048000 [2023-04-20 19:14:33] RTL_TCP started with PID 4949 [2023-04-20 19:14:38] RTL_TCP is ready to receive connections! [2023-04-20 19:14:38] Trying to start RTLAMR: /usr/bin/rtlamr -msgtype=scm,idm,r900 -format=json -filterid=50015247,14064432,700962376 -unique=true -symbollength=32 [2023-04-20 19:14:38] RTLAMR started with PID 4956

Logs from rtl-433 [alarm] cb transfer status: 1, canceling... [alarm] [alarm] LIBUSB_ERROR_NOT_FOUND: Entity not found! [alarm] Check your RTL-SDR dongle, USB cables, and power supply. [alarm] [alarm] WARNING: async read failed (-5). [alarm] [alarm] Library error -5, exiting... s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

rtlamr2mqtt config file (except for meter information) general: sleep_for: 300 verbosity: debug listen_only: false tickle_rtl_tcp: false device_id: 0bda:2838 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: port: user: password: custom_parameters: rtltcp: "-s 2048000" rtlamr: "-unique=true -symbollength=32"

rtl-433 config files (have two radios running so reference within file editor I have the following two config files located within /config/rtl_433/: sainlogic.conf.template and alarm.conf.template):

rtl-433 configuration tab options: rtl_433_conf_file: "" retain: true

sainlogic.conf.template YAML: device 0 output mqtt://[ip]:[port],user=[user],pass={password],retain=true,devices=rtl_433/74930c0d-rtl433/devices[/model][/subtype][/id],events=rtl_433/74930c0d-rtl433/events[/id],states=rtl_433/74930c0d-rtl433/states output json frequency 433.92M protocol 153 gain 28 gain 28 convert si report_meta newmodel report_meta time:tz:local verbose 2

alarm.conf.template YAML: device 1 output mqtt://[ip]:[port],user=[user],pass=[password],retain=true,devices=rtl_433/74930c0d-rtl433/devices[/model][/subtype][/id],events=rtl_433/74930c0d-rtl433/events[/id],states=rtl_433/74930c0d-rtl433/states output json frequency 319.508M protocol 100 gain 28 convert si report_meta newmodel report_meta time:tz:local verbose 2

Hardware information for radios: BUSNUM: '001' DEVNAME: /dev/bus/usb/001/035 DEVNUM: '035' DEVPATH: /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7.4 DEVTYPE: usb_device DRIVER: usb ID_BUS: usb ID_FOR_SEAT: usb-pci-0000_00_14_0-usb-0_7_4 ID_MODEL: RTL2838UHIDIR ID_MODEL_ENC: RTL2838UHIDIR ID_MODEL_ID: '2838' ID_PATH: pci-0000:00:14.0-usb-0:7.4 ID_PATH_TAG: pci-0000_00_14_0-usb-0_7_4 ID_REVISION: '0100' ID_SERIAL: Realtek_RTL2838UHIDIR_00000001 ID_SERIAL_SHORT: '00000001' ID_USB_INTERFACES: ':ffffff:' ID_USB_MODEL: RTL2838UHIDIR ID_USB_MODEL_ENC: RTL2838UHIDIR ID_USB_MODEL_ID: '2838' ID_USB_REVISION: '0100' ID_USB_SERIAL: Realtek_RTL2838UHIDIR_00000001 ID_USB_SERIAL_SHORT: '00000001' ID_USB_VENDOR: Realtek ID_USB_VENDOR_ENC: Realtek ID_USB_VENDOR_ID: 0bda ID_VENDOR: Realtek ID_VENDOR_ENC: Realtek ID_VENDOR_ID: 0bda MAJOR: '189' MINOR: '34' PRODUCT: bda/2838/100 SUBSYSTEM: usb TAGS: ':seat:' TYPE: 0/0/0 USEC_INITIALIZED: '85780982467'

BUSNUM: '001' DEVNAME: /dev/bus/usb/001/009 DEVNUM: '009' DEVPATH: /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7.2 DEVTYPE: usb_device DRIVER: usb ID_BUS: usb ID_FOR_SEAT: usb-pci-0000_00_14_0-usb-0_7_2 ID_MODEL: RTL2838UHIDIR ID_MODEL_ENC: RTL2838UHIDIR ID_MODEL_ID: '2838' ID_PATH: pci-0000:00:14.0-usb-0:7.2 ID_PATH_TAG: pci-0000_00_14_0-usb-0_7_2 ID_REVISION: '0100' ID_SERIAL: Realtek_RTL2838UHIDIR_00000002 ID_SERIAL_SHORT: '00000002' ID_USB_INTERFACES: ':ffffff:' ID_USB_MODEL: RTL2838UHIDIR ID_USB_MODEL_ENC: RTL2838UHIDIR ID_USB_MODEL_ID: '2838' ID_USB_REVISION: '0100' ID_USB_SERIAL: Realtek_RTL2838UHIDIR_00000002 ID_USB_SERIAL_SHORT: '00000002' ID_USB_VENDOR: Realtek ID_USB_VENDOR_ENC: Realtek ID_USB_VENDOR_ID: 0bda ID_VENDOR: Realtek ID_VENDOR_ENC: Realtek ID_VENDOR_ID: 0bda MAJOR: '189' MINOR: '8' PRODUCT: bda/2838/100 SUBSYSTEM: usb TAGS: ':seat:' TYPE: 0/0/0 USEC_INITIALIZED: '2646343'

BUSNUM: '001' DEVNAME: /dev/bus/usb/001/011 DEVNUM: '011' DEVPATH: /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7.1/1-7.1.3 DEVTYPE: usb_device DRIVER: usb ID_BUS: usb ID_FOR_SEAT: usb-pci-0000_00_14_0-usb-0_7_1_3 ID_MODEL: RTL2838UHIDIR ID_MODEL_ENC: RTL2838UHIDIR ID_MODEL_ID: '2838' ID_PATH: pci-0000:00:14.0-usb-0:7.1.3 ID_PATH_TAG: pci-0000_00_14_0-usb-0_7_1_3 ID_REVISION: '0100' ID_SERIAL: Realtek_RTL2838UHIDIR_00000003 ID_SERIAL_SHORT: '00000003' ID_USB_INTERFACES: ':ffffff:' ID_USB_MODEL: RTL2838UHIDIR ID_USB_MODEL_ENC: RTL2838UHIDIR ID_USB_MODEL_ID: '2838' ID_USB_REVISION: '0100' ID_USB_SERIAL: Realtek_RTL2838UHIDIR_00000003 ID_USB_SERIAL_SHORT: '00000003' ID_USB_VENDOR: Realtek ID_USB_VENDOR_ENC: Realtek ID_USB_VENDOR_ID: 0bda ID_VENDOR: Realtek ID_VENDOR_ENC: Realtek ID_VENDOR_ID: 0bda MAJOR: '189' MINOR: '10' PRODUCT: bda/2838/100 SUBSYSTEM: usb TAGS: ':seat:' TYPE: 0/0/0 USEC_INITIALIZED: '3137709'

pbear7656977 commented 1 year ago

for additional information, the three radios are plugged into a powered usb hub as I was having issues with powering all three on RPi4 (have now changed over to x86 desktop running HA OS but use same setup for radios). Also noticed that above for TAGS: a seat is displayed but actually says seat in hardware information.

pbear7656977 commented 1 year ago

I was able to fix the issue. After some more digging and reading, I took a chance and added the following under general section of configuration:

usb_device: 'multiple'

Now the usb device reset only occurs for the specific radio and not all.