Hi @enricosx, welcome to the Cayenne Community.
Custom Widgets / Custom Code support in Cayenne is currently only supported for Arduino at this time, but adding support for Raspberry Pi is one of the highest priority items on our Cayenne Roadmap, so we should have this feature sooner than later.
In the meantime, you should be able to accomplish this using our new MQTT API which you can read about in the linked thread. There are some links in that thread to our documentation to get you started, and feel free to use the community here as a resource if you have questions about it or get stuck.