Subtract two time sensors to get duration (in min), then %

What have you tried?

Community Guidelines #9: Show your Work

Since this is your first Template sensor, you probably want to start out using the Template Helper which is done completely in the GUI.