Rfxtrx.send service lost after restart

Hi,

I’m having problems with a RFXCOM especially the rfxtrx.send service. When I add it to my configuration and restart the RFXCOM is added as an integration and work as excepted so the hardware is found and is working.
But after a restart without changing anything the integration is still there but the rfxtrx.send service is not there anymore and there is an error in the logfile, but I can’t figure out whats the problem and Google couldn’t help me either.

I’ve had the same problem on two different systems / installs

  • Home Assistant 0.114.4 in the VM for a NUC
  • Home Assistant 0.114.4 running on a Synology (fredrike package)

Besides trying different installs I repeatedly start from scratch but always the same problem. Tried the device path as /dev/ttyUSB1 but same problem on both systems. Google and the search function did not come up with a sollution.

In short:

  • adding rfxtrx to the configuration, restart and the service is available.
  • restart without changing anything: rfxtrx.send service did not start
  • removing integration and restart: rfxtrx.send service is working again.
#configuration.yaml
rfxtrx:
  device: /dev/serial/by-id/usb-RFXCOM_RFXtrx433_07VX4SH1-if00-port0
  debug: true

Error log:

2020-09-07 10:59:09 ERROR (Thread-3) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 826, in _connect
    self._status = self.send_get_status()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 888, in send_get_status
    return self.transport.receive_blocking()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 661, in receive_blocking
    return self.parse(pkt)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 593, in parse
    pkt = lowlevel.parse(data)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/lowlevel.py", line 94, in parse
    pkt.load_receive(data)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/lowlevel.py", line 1445, in load_receive
    self.seqnbr = data[3]
IndexError: bytearray index out of range

Is there any more info in the log? Just before line 661 in __init__.py it should write debug info. Do you see something formatted like below?

Which firmware version do you use and what is the exact device type you are using?

if self.debug:
  print("RFXTRX: Recv: " +
    ".join("0x{0:02x}".format(x) for x in pkt))
return self.parse(pkt)

I deleted the log and restart HA but the lines aren’t in the log. Below is the whole log after restarting. There is more than last time.

I’m using a RFXCOM RFXtrx433E / Hardware version 1.3 / EXT firmware 1025 connected to a USB3 hub on a USB3 port.

2020-09-08 08:31:16 ERROR (Thread-4) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 825, in _connect
    self.transport.reset()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 678, in reset
    self.send(b'\x0D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 674, in send
    self.serial.write(pkt)
AttributeError: 'NoneType' object has no attribute 'write'
2020-09-08 08:31:16 ERROR (Thread-3) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 825, in _connect
    self.transport.reset()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 678, in reset
    self.send(b'\x0D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 674, in send
    self.serial.write(pkt)
AttributeError: 'NoneType' object has no attribute 'write'
2020-09-08 08:31:17 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry RFXTRX for rfxtrx
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 309, in async_unload
    result = await component.async_unload_entry(  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/rfxtrx/__init__.py", line 202, in async_unload_entry
    await hass.async_add_executor_job(rfx_object.close_connection)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 854, in close_connection
    self.transport.close()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 685, in close
    self.serial.close()
AttributeError: 'NoneType' object has no attribute 'close'

Maybe this has something to do with a recent update of HA?
I just got my rfxtrx433e delivered and set it up through the configuration.yaml, in my case /dev/ttyUSB0

My log also shows:

2020-09-09 20:20:40 ERROR (Thread-3) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 835, in _connect
    self.send_start()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 882, in send_start
    return self.transport.receive_blocking()
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 661, in receive_blocking
    return self.parse(pkt)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/__init__.py", line 593, in parse
    pkt = lowlevel.parse(data)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/lowlevel.py", line 94, in parse
    pkt.load_receive(data)
  File "/usr/local/lib/python3.8/site-packages/RFXtrx/lowlevel.py", line 1444, in load_receive
    self.subtype = data[2]
IndexError: bytearray index out of range

(Just pasting it in case there IS a difference which I do not see.)
In my case it does not even connect when starting op HA, this immediately shows up in my log. I have

automatic_add: true

But nothing shows up within devices/entities (which I guess is logical).
Additional information: running HA within Docker on a Raspberry PI 4 with Raspberry Pi OS 64bit.

After restarting a few times I once got a different message:

serial.serialutil.SerialException: Attempting to use a port that is not open

But that’s not showing up anymore…

Edit:
Some extra information: just tried it outside the docker container with some python scripts and the transceiver is working correctly (yay), it receives the signals just fine.

In my case after deleting the integration in de GUI and a restart I can use the service until the first restart.

Mine is also working correctly with a Pyhton script.

Yes I see what you mean now. It was working for a while just now and was able to control my lights through HA, but after restarting (restarting HA through server controls, restarting docker container or reboot whole server) the results are highly unstable.

I think something goes wrong with unloading ha and releasing the serial connection. You could report an issue to Github, it gets better exposure there.

As RobBie1221 advised (thanks!) I started a report issue on Github, see https://github.com/home-assistant/core/issues/39968

Maybe you can post you’re hardware and software information so there is more info for the developper?

RobBie1221 found the issue (see https://github.com/home-assistant/core/issues/39968)

The workaround (until 0.115.2)

  1. Delete the integration through UI
  2. Restart HA
  3. Remove rfxtrx from configuration.yaml
  4. Restart HA

It’s more a workaround. The fix for underlying issue is tagged to go into 0.115.2

Hi RobBie1221,

i run into the problem decribed in this thread and i tried using your workaround but no luck!

So delete the RFXCOM integration via UI
Than restart HA
Then remove the rfxcom integration from configuation.yaml
And restart HA

After tis sequence i have RFXCOM integration in the UI and the logfile keeps on showing the below

2020-09-29 13:28:37 ERROR (Thread-5) [root] Uncaught thread exception
Traceback (most recent call last):
File “/usr/local/lib/python3.8/threading.py”, line 932, in _bootstrap_inner
self.run()
File “/usr/local/lib/python3.8/threading.py”, line 870, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/lib/python3.8/site-packages/RFXtrx/init.py”, line 825, in _connect
self.transport.reset()
File “/usr/local/lib/python3.8/site-packages/RFXtrx/init.py”, line 678, in reset
self.send(b’\x0D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’)
File “/usr/local/lib/python3.8/site-packages/RFXtrx/init.py”, line 674, in send
self.serial.write(pkt)
AttributeError: ‘NoneType’ object has no attribute ‘write’

Do you have any idea how to fix this? I am strugling to get HA running togehter with my klikaanklikuit devices.

Best regards,
Marcel

Which version are you running? Did it work before for you? This error could also mean port or host is wrongly configured.

Hi Rob,

I run the latest version and no it didn’t work for me in the first place i started with homeassistant a little more than a month ago so i am rather new to this platform.

I am sure the RFXcom is correctly connected and installed on the synology nas. I installed the USB driver and i acn see the device ttyUSB0. I also see that the RFXcom does trigger signals when i use my current remote to actvate switches and lights. But the RFXcom integration of homeassistant is not picking anything up!

Any idea or sugestion what i could do to check a little further? Or would it be an idea to move into another direction for example install node-red as an add-on? Node-red is also able to work with a RFXcom integration.

I also see that the RFXcom does trigger signals when i use my current remote to actvate switches and lights

How do you see that? Are you perhaps trying the access the RFXcom device with Home Assistant and another tool in parallel?

Are you running Home Assistant inside docker on your NAS?

when i trigger a signal on my remote control i can see the led on the RFXcom device firing up for a short moment (orange)

Yes i am running Home Assistant inside docker on my NAS!

Do you pass USB devices from host to container?

Rob, you’re the man! That was my issue! Just made sure that i pass on the USB device and now when i trigger my remote control a new entity is there in the RFXcom integration!

Many thanks for your help!

Marcel