Not quite what i was after. This is how i currently do it, but its way too slow and sluggish.
import requests import time colors = {'white':'{"on":true,"bri":255,"sat":0,"hue":0}', 'blue':'{"on":true,"bri":255,"sat":255,"hue":46920}', 'red':'{"on":true,"bri":255,"sat":255,"hue":0}', 'yellow':'{"on":true,"bri":255,"sat":255,"hue":12750}'} hour = time.localtime().tm_hour time_colors = {(0,2):'red', (2,7):'blue', (7, 20):'white', (20,24):'yellow'} color_schema = {hour:color for hours, color in time_colors.items() for hour in range(hours[0], hours[1])} color = colors[color_schema[hour]] headers = { 'Accept': 'application/json', } requests.put('http://192.168.1.47/api/xxxxxxxxxxxxxxxxxxx/lights/2/state', headers=headers, data=color)