Rfxtrx unable to add device

I’m trying to add rfxtrx devices. When I add the rfxtrx integration, all goes well. When I press a button on a remote control or activate a motion sensor the device shows up under entities. When I restart Home Assistant the state of all rfxtrx devices is “unavailable”. I added following code to configuration.yaml:

rfxtrx:
  device: /dev/ttyUSB0
  automatic_add: true

When I add a device to the configuration.yaml, the validation is successful but the device is still unavailable. Following code is in my configuration.yaml:

rfxtrx:
  device: /dev/ttyUSB0
  automatic_add: true
  devices:
   ac_127d800_2:

Logging says:
Error setting up entry RFXTRX for rfxtrx

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 219, in async_setup
result = await component.async_setup_entry( # type: ignore
File “/usr/src/homeassistant/homeassistant/components/rfxtrx/init.py”, line 160, in async_setup_entry
await hass.async_add_executor_job(setup_internal, hass, entry.data)
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/rfxtrx/init.py”, line 179, in setup_internal
event.device, data_bits=event_config.get(CONF_DATA_BITS)
AttributeError: ‘NoneType’ object has no attribute ‘device’

Is the anyone who knows what I’m doing wrong?

Please show your config as code with the </> button, to check if the number of spaces are correct.

The ID number after devices: seems not correct to me, normally, these numbers are longer. Try adding it again via automatic_add and look in your logs in stead of under states to find the correct ID number. Enable logging if you don’t see anything.

If you have kaku or coco devices, you can also try with the learning mode as described here.

Thank you very much Ernst. I enabled logging and found the right ID.