i have exactly the same setup and its fine and in my opinion also safe
the only weak point could be if your habitual residence is still in
germany, as for example you spend 5 months in germany, 3 months in
spain, 3 months in cyppern and 2 months in italy and therefore mainly in germany...
There is no such rule. The German tax code defines as habitual abode as spending time in Germany "not only temporarily". There is no reference to how much time you spend in other countries.
Spending 5 months in Germany and 5.5 months in Spain doesn't automatically mean you can't have habitual abode in Germany. This gives the tax authority a lot of room of interpretation. The only fixed rule is that if you spend 183+ days in Germany, you definitely have habitual abode. Anything below that is open to interpretation. Even if your total time in the country is low, but you are a citizen, you have friends and family there, you visit frequently or for several weeks at a time, it is likely that they will not see your stays as "only temporary in nature".
Again, imagine a
self-employed German citizen living in Germany, where they spend 5 months per year, and having a vacation home in Spain, where they spend 5.5 months per year. This person would clearly be considered tax resident in Germany due to having a home available to them - their permanent home is in Germany, there is only a vacation property in Spain.
Now swap out the home in Germany with hotel stays. Would this person really no longer be considered tax resident in Germany? Probably not.
They would look at all your ties, they could even look at memberships, newspaper subscriptions, where you go to the dentist and have your hair cut etc.
Habitual abode is about much more than the number of days you spend in a country, and they can also count days where you weren't in the country.
5 months is really pushing it, asking for trouble, especially if you don't spend 183+ days in any other country.