HomeyScript infinite loop

Your best chance is to write an app for this, because flows will either be too limiting or simply too slow to pull this off (and even with a custom app I doubt that Homey will be able to do this).

To control devices from other apps (like the Hue bulbs) you also need to use the Web API (aka as homey-api) in your app.