Adding network to rfxtrx component

I would like to try and add network support to rfxtrx. But i’m going to need some pointers because i never use Python. Any pointers are welcome. Please!

I already use components rflink and dsmr via network using ser2net running on a Pi. These works fine out of the box using the host: in yaml config, because they already have this network support.

I intend do detect the host: value and replace the serial connect with compatible network connect logic. I developed software with this approach before but never in Python.

In this thread i wil post my progress, and i hope you can chime in with suggestions. I’m going to need some for sure…

So. Ofcourse i took a look at the HA rfxtrx code, on how/where to throw in network support and gauge viability.

    # Try to load the RFXtrx module.
    import RFXtrx as rfxtrxmod

    device = config[DOMAIN][ATTR_DEVICE]
    debug = config[DOMAIN][ATTR_DEBUG]
    dummy_connection = config[DOMAIN][ATTR_DUMMY]

    if dummy_connection:
        rfx_object = rfxtrxmod.Connect(
            device, None, debug=debug,
            transport_protocol=rfxtrxmod.DummyTransport2)
    else:
rfx_object = rfxtrxmod.Connect(device, None, debug=debug)

Source: https://github.com/home-assistant/home-assistant/blob/5be695c49c99d9d1bcce5b5fc7601d8c1a1a6a1e/homeassistant/components/rfxtrx/init.py#L99-L111

First problem for me (as a Python noob) is the import RFXtrx. I found /requirements_all.txt which contains:

# homeassistant.components.rfxtrx
pyRFXtrx==0.23

So i guess its this python package that HA uses here:

And i found a PySerialTransport class in the linked repository. I suppose thats where i should create a network alternative?

So i created an issue there to ask the author if im on the right track:

1 Like

I made some code and made two PR’s:

Feedback very welcome.

Any info on this?
I really want to implent rfxtrx with ser2net :slight_smile: