# Update nightlight shift dimming scenes

        nightshift_scenes =   { scene.name : scene for scene in bridge.scenes if 'nightshift' in scene.name.lower()}

        for scene_object in nightshift_scenes.values():
            log.info('updating lightlight scenes: %s' % scene_object.name)
            bridge.set_scene_lights(scene_object,{'ct':mired,
                                                  'on':True,
                                                  'transitiontime':TRANSITION_TIME,
                                                  'bri':int(brightness * 255)})


        # Update just the temperature of lights that are on
        if SHIFT_ALL_LIGHTS:
            active_lights = { light.light_id : light for light in bridge.lights if light.on }
            bridge.set_light(active_lights.keys(), {'ct':mired} , transitiontime=TRANSITION_TIME)

        if TWEAK_MOTION_DIM:
            motion_dim = [ r for r in  bridge.rules if (".dim" in r.name and "MotionSensor" in r.name)]
            for m in motion_dim:
                dim_actions = [ k for k,a in enumerate(m.actions) if  'bri_inc' in a['body'].keys() ]
                for k in dim_actions:
                    m.actions[k]['body']['transitiontime'] = TRANSITION_TIME
                bridge.set_rule(m.rule_id, {'actions':m.actions})

        last_period = period

    sleep(SLEEP_TIME)