Notifying the police of a lodger's arrival (1920s Germany)

I’m reading Herman Hesse’s 1927 novel Steppenwolf. Early in the story, the narrator describes his aunt taking in a lodger. The narrator is disturbed when he learns:

The only request he had made was that his arrival should not be
notified to the police, as in his poor state of health he found these
formalities and the standing about in official waiting-rooms more than
he could tolerate.

What’s this all about? Apparently German law required you to notify the police if you rent a room to someone? Why? Was this a long standing law in Germany, or was it related to the rising fascism in the pre-Nazi era? Did this happen in other countries? And how much trouble would the aunt be in if the police learned of her lack of notification?

Maybe they needed to know who was living where at any given time?

China definitely has police registration rules.

In the 19th and early/mid 20th C it was pretty much standard in Europe for hotels to maintain guest registers that were an open book to (if not compulsorily copied to) the police. It was a state surveillance tool, basically.

You can read more about it here: https://www.tandfonline.com/doi/full/10.1080/02619288.2025.2591362#abstract

I suspect that taking in a lodger would be in the same category.