I solved this in home assistant by adding sensors to my doors inside the apartment.
For example if the living room doors are closed, and after that there's movement inside, the room is marked as "occupied". It works really well.
Same could be achieved with straight line movement sensors on the door frames, if you're someone who keeps the doors open all the time.
And speaking of open source, my whole smart home setup (from sensors, lights, heating, etc) works offline and using open source software and protocols even if hardware isn't open source itself. Which I found to be a good tradeoff.