You're on the right track. Off the top of my head, で denotes action at a location, can also be used to connect multiple clauses in a sentence, means of an action, and also cause of effect. に on the other hand is used for direction of a subject, existence of a subject, or action at an event. For the most part it should be relatively easy to distinguish when to use the two.
action at a location 公園で遊んだ (I played at the park)
connect multiple clauses in a sentence うどんは日本の名物で美味しい。(Udon is popular Japanese product and is delicious)
means of an action 車で学校へ行く。 (I go to school by car)
cause of effect 大雪で行かなかった。 (I didn't go because of\due to heavy snow)
direction of a subject デパートに行った。(I went to the department store)
existence of a subject 家にいる。(I'm at home)
action at an event 試合に勝って勝負に負けた。(I won the match but lost the contest. Similar to saying winning a battle but losing the war)
The last example uses に twice to emphasize how you would use it in an action. It would sound weird to insert で instead of に because the action happened at an event and not a location.