The problem might be caused from a dirty/defective Idle Air Control valve.
The next time the engine’s idling rough at operating temperature, locate the IAC valve on the throttle body, and tap on it with a handle of a screwdriver. If doing this causes the idle speed to change replace the IAC valve.
Tester