Skip to content
Advertisement

Hardcode RF Codes in rpi-rf_send script + python raspberry pi

I’d like to hardcode the RF Code in the rpi-rf_send.py send script so I can repeatedly activate the same device automatically.

I’ve reviewed all of the documentation and I cannot find any clear method to do that.

Docs:

https://pypi.org/project/rpi-rf/

https://github.com/milaq/rpi-rf

It works well when passing the arguments directly from the terminal in this format:

JavaScript

But what I need to do is hard code those arg variables into the script and I cannot find any direction on how to do that.

Here is the code:

JavaScript

I’ve tried experimenting with the variables in rfdevice.tx_code by passing the arguments directly but still get errors. I’ve tried:

JavaScript

The trace returns this:

JavaScript

Secondly:

JavaScript

Which returns an “invalid syntax” error…

Do any of you kind souls have any idea which variable I need to edit to hard code the RF Code to replicate “python3 send.py -p 174 -t 1 123456”?

Thanks in advance.

Advertisement

Answer

Ok, figured it out… well at least a work around. Instead of trying to change the variables within the send.py script, you can use the subprocess library to execute the script when required and pass the arguments to it.

Simply by adding:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement