RFXtrx devices with rotating code

Hi

I have a couple of 433 Security Alarm devices that i am trying to use but they have a rotating code in the middle, I wondered if there is a way to use regex for the devices. so to illustrate below i effectively want to do the following as i like the idea of the codes rotating, I know these devices use to work ing Demoticz but i don’t want to run that again. or an additional powered device

  - platform: rfxtrx
    automatic_add: True
    devices:
     ......
      077500<regex>990580:
        name: Office PIR
        device_class: motion

When i track it in the RFXmngr i can see in the small tests that i have done that the first 6 and last stay the same but are unique per device, what i don’t want is lots of 1-time devices. below is output from the test the front and last have been changed to avoid publically exposing my devices.

All help greatly appreciated.
Mo

------------------------------------------------
17/03/2020 09:07:23:927= 077500**2600**990580
Packettype    = Chime
subtype       = Byron SX
Sequence nbr  = 38
ID            = 0095 decimal:149
Sound         = SX21 Tubular 3 notes
Signal level  = 8  -56dBm
------------------------------------------------
17/03/2020 09:14:32:565= 077500**2700**990580
Packettype    = Chime
subtype       = Byron SX
Sequence nbr  = 39
ID            = 0095 decimal:149
Sound         = SX21 Tubular 3 notes
Signal level  = 7  -64dBm
------------------------------------------------
17/03/2020 09:14:37:052= 077500**2800**990580
Packettype    = Chime
subtype       = Byron SX
Sequence nbr  = 40
ID            = 0095 decimal:149
Sound         = SX21 Tubular 3 notes
Signal level  = 8  -56dBm
------------------------------------------------
17/03/2020 09:14:38:472= 077500**2900**990580
Packettype    = Chime
subtype       = Byron SX
Sequence nbr  = 41
ID            = 0095 decimal:149
Sound         = SX21 Tubular 3 notes
Signal level  = 8  -56dBm

There is no way to have variables in the config like that.

This is something the RFXtrx device implementation has to handle. As you can see, the ‘device id’ is actually just a bunch of information. Some of it is static, some of it changes.

Take a look at this post:

As you can see, the rfxtrx433 cover follows that decoding scheme.

Actually, looking at the RFXTRX integration, it is doing a mask to extract the various devices.

def get_pt2262_deviceid(device_id, nb_data_bits):
    """Extract and return the address bits from a Lighting4/PT2262 packet."""
    if nb_data_bits is None:
        return

    try:
        data = bytearray.fromhex(device_id)
    except ValueError:
        return None
    mask = 0xFF & ~((1 << nb_data_bits) - 1)

The interesting this is, the mask is defined by CONF_DATA_BITS. So, lets look at the RFXTRX binary sensor documentation…

https://www.home-assistant.io/integrations/binary_sensor.rfxtrx/#options-for-pt-2262-devices-under-the-lighting4-protocol

Reading that, a few things.

The automatic_add option makes the RFXtrx binary sensor integration calculate and display the configuration options for you in the Home Assistant logs:

INFO (Thread-6) [homeassistant.components.rfxtrx] rfxtrx: found possible device 226707 for 22670e with the following configuration:
data_bits=4
command_on=0xe
command_off=0x7
INFO (Thread-6) [homeassistant.components.binary_sensor.rfxtrx] Found possible matching deviceid 22670e.

This automatic guess should work most of the time but there is no guarantee on that. You should activate it only when you want to configure your new devices and leave it off otherwise.

Turn this on only when adding new devices. Then check the logs. It should hopefully figure out how many data bits you need to set. Then set these data_bits and turn off the automatic_add.

This device might not be supported yet. It’s hard to tell exactly what is going on without ever having use an rfxtrx device. But, you might have to add support for this device type into the code. Well, not YOU (unless you want to)…but it might require a feature request.

TLDR:

What is in the HomeAssistant logs? You might have to up the log level to INFO for RFXTRX to see this if it doesn’t show up. I’m not sure what the default log level even is if you don’t have the logger integration added. Add this to your configuration.yaml

logger:
  default: warn
  logs:
    homeassistant.components.rfxtrx: info
1 Like

Thanks for the quick reply, thats a shame, thanks for the reply.

I’m not sure about me editing the code yet as i am still trying to get my first attempt working with Hass, but will raise a Feature request.

Thanks once again.
Mo