I use Home Assistant with MQTT for collecting data from sensors via rtl_433.
This shell script does the trick:
MQTT_HOST="localhost"
MQTT_TOPIC="home/something"
PREV_LINE=""
# Start the listener and enter an endless loop
rtl_433 -g 40 -F json | while read LINE
do
# Log the raw data to file, so we can debug them if needed
echo $LINE >> rtl.log
# Skip duplicate lines
if [ "$LINE" != "$PREV_LINE" ]; then
# Extract the ID of the sensor
ID=`echo $LINE | jq .id | tr -d '"'`
# Send the entire JSON message to MQTT
mosquitto_pub -h $MQTT_HOST -t $MQTT_TOPIC/$ID -m "$LINE"
fi
# Set the previous line
PREV_LINE="$LINE"
done &
It uses jq to extract info from the json message that rtl_433 receives, and mqtt publishes that. But depending on your specific requirements and setup, you may not need that part.
For your question: you want to send codes, not just receive them?
If you use Home Assistant, it has this integration built in, as RF Switch:
https://home-assistant.io/components/switch.rpi_rf/ If you don't want to use Home Assistant, you can use the rpi-rf module
https://pypi.python.org/pypi/rpi-rfIn both cases, you need to get a pair of cheap transmitters/receivers and a Raspberry Pi.