Cheap water leak detector (based on PT-2262) not recognized as such

I’ve some cheap leak detectors that are recognized as PT-2262, but considered as switches and binary sensors.
However, it seems that when the devices report a leak, they are using the command 0x9 (and only this one), which is not recognized by default, since it is logged as:

Receive RFXCOM event: {'packet_type': 19, 'sub_type': 0, 'type_string': 'PT2262', 'id_string': 'f40699', 'data': '09130002f40699017570', 'values': {'Command': 'Unknown command (0xf40699)', 'Rssi numeric': 7}}

(ID is really f4069 I think, and 9 is the command)

I tried many things, including configuration (in configuration.yaml, at top level) such as:

rfxtrx:
  devices:
    09130002f40699017570:
      name: leak_test1
      data_bits: 4
      command_on: 9
      device_class: moisture
      off_delay:
        seconds: 5

which seemed the closest to everything I read on the subject, but this doesn’t seem to have any effect. I tried to also add “device: /path/to/my/usb/device” (with the correct path obviously). I tried removing first the existing device, then enabling the auto add, and triggering the device. I tried many combination of the configuration (without the name, without the off_delay, …) I tried other format which seems deprecated (using “platform: rfxtrix”) such as:

binary_sensor:
  platform: rfxtrx
  automatic_add: true
  devices:
    09130008f40699017770:
      name: leak_test1
      command_on: 9
      data_bits: 4

I tried so many things, searched through the web everywhere, it’s embarrassing…

I’ve added the integration of RTXtrx directly from the UI. Is that why I can’t combine it with a setup in configuration.yaml?

Any help would be much appreciated.

Oh well, I guess I tried to make it more difficult than necessary. I got lost in the various documentation for older versions and for newer versions of Home Assistant.

It works now. Everything can be setup using just the UI.

For anyone in the same situation, here is the procedure:

  1. Go to Settings, then Devices & Services
  2. Assuming you have the RFXTRX integration already set up, click Configure
  3. In the popup that open, enter the message sent by the device (the hexadecimal series, that starts with 09) into the “Enter event code to add” field, then click Submit. You can find the message by enabling logging for RFXTRX (or globally) then triggering manually the device and look at what get logged. In my case, the device was sending “09130002f40699017570”. This is obviously different for every device.
  4. In the next popup, you will be able to give some info about how the device should be handled by Home Assistant. In the case of the cheap leak detector I got, the command is 9 (this come from the 14th digit of the message, the last nine in “f40699” in my example above), and the off delay was set to just 1 (you probably want more, if you want it to stay in the On state for longer than 1s).