just to inform you that I created a web app to control Bticino MyHome from a Raspberry Pi, which I called "Grasshopper".
I truly believe this is not only an innovation for the Bticino community as such (this because, prior to Grasshopper, no opensource - responsive design - web application existed to control Bticino Myhome up till now)
but you will find that ALL THE CODE IS READABLE in notepad (or notepad++

In Grasshopper V3, a python-based script continuously monitors the Bticino Gateway for events and logs these in a MySQL DB table. My front-end AJAX script checks for updates in the table and shows this in the frontend.
Just an idea, if you customise this monitor, you could make this manage a variety of scenarios.
If you choose to test Grasshopper, I would very much value your feedback, either in this forum, on youtube or on Sourceforge.
Enjoy!
https://www.youtube.com/watch?v=m28dntzFcyc
https://sourceforge.net/projects/grasshopperwebapp