Using Raspberry Pi as a home hub for Apple HomKit setup I'm trying to make my home a bit smarter using HomeKit without actually buying HomeKit accessories. Now I'm using python and the pyhap libary and it is working so far. 

I can control my Raspberry Pi using Apple HomeKit and the Home app. But there's one thing I consider a big disadvantage of HomeKit: it cannot be controlled from outside the Network without an iPad, HomePod or Apple TV working as a home hub.

Question: Can I somehow turn my Raspberry Pi into a home hub so I can control my lights etc from outside my home?
No, that's unfortunately not possible.
The official hubs (such as an iPad or AppleTV) communicates with Apple's servers that then communicate with the Home app in order to provide push notifications and &quot;proxy&quot; functionality.
Creating a non-official hub would require you to be able to communicate with Apple's servers. This is not really possible without violating Apple's terms of services, and it is definitely not easily technically achieving anyways, as it would require reverse engineering the protocol, being able to provide valid certificates, etc.
You can however use your Raspberry Pi to control those non-HomeKit accessories when away from home - but it would require you to make your own client. I.e. it wouldn't be via the Home app, but you would need to create your own app, or host a web app on the Raspberry Pi that is available when away from home.
In addition to the above, there's a further option that might be doable depending on your exact setup. If you setup the Raspberry Pi to provide a network bridge via VPN, you could in theory use VPN software on your iPhone to access your home network as if you were directly connected it. Then HomeKit accessories would be directly accessible. This could be done by for example setting up OpenVPN in tap-mode on the Raspberry Pi and installing the client on the iPhone.