My Highlander did the loose gascap thing to me once! My mechanic plugged in his tester and told me to tighten the cap. Thing is, once I pulled out go a gas station and had completely forgotten to put the cap back on! Guess what? No warning light!
My son got worried and called me when his Honda did the same thing. I asked him if had gotten gas recently. Sure did. Had him just take off the gas cap and put back on firmly. Voila no more light.
I also had a Nissan 4x4 have an O2 sensor light come on. Couldn't get it smogged with that light on. Would have to have taken it into a dealership for XXX 100’s of dollars to be diagnosed/fixed. What made me suspicious that this was a engineered scam for the dealers was the light came on exactly as I registered 30K on the odometer.
I pulled a wiring diagram for the truck and found an access port that could be popped out giving me access to the O2 sensor wiring. Found a small tag on a connector that said “reset alarm at 30K disconnect at 60”. I opened the connector and no more light and the truck smogged and ran A-ok. Just was a design scam built into the truck.