If WIFI is an option, this can be done with Tasmota with MOES UFO-R6:
https://templates.blakadder.com/moes_UFO-R6.html
This can be configured as shown by @Teki:
https://forum.ewelink.cc/t/add-on-guide-mqtt2cube-tasmota-sync-your-tasmota-devices-to-cube/19413