Fix if your RFXtrx switches break from 0.61

I put this in the blog thread for 0.62, but posting it here for a bit more visibility in the hopes that it helps anyone with the same problem.

My rfxtrx switches broke when I upgraded from 0.60. The entities weren’t created and I got errors in the logs:

2018-01-27 16:35:28 ERROR (Thread-17) [homeassistant.components.rfxtrx] Invalid device: 7100a0041010000
2018-01-27 16:35:28 ERROR (Thread-17) [homeassistant.components.rfxtrx] Invalid device: 7100a0041020000
2018-01-27 16:35:28 ERROR (Thread-17) [homeassistant.components.rfxtrx] Invalid device: 7100a0041030000

It turned out the issue was that they were 15 digit device IDs, and therefore not valid hex numbers.

All I had to do was change my configuration to add a leading zero. I.e. instead of:

      name: "rfxswitch1"

I needed:

      name: "rfxswitch1"

The switches functioned perfectly after this change.

Looking at the code, I think this is down to the removal of the “_valid_device” function that fixed it for you - it contained the lines:

    key = str(key)
    if not len(key) % 2 == 0:
        key = '0' + key

So 0.61 was a breaking change for me, but the solution is a simple config fix - pad the device ID with a leading zero if it’s not an even length.

1 Like