"The server always asks for new location data, every 30 seconds, even when no one is listening."
...
"Our task is to pause the timer when there are no websocket connections and start the timer when a client connects."
That sounds like asking for trouble. Maybe there's something I am not understanding, but why not have the timer run continuously and have the timer action check whether it needs to request location data?
Yes, that will cause the process to wake up every 30 seconds even if there is no action, but unless circumstances are very special that won't be a significant problem.