Re: Problem with this sketch

With your code in the IDE, press ctrl-T to use the autoformat tool that will try to indent the code for better reading and not be like a trick maze for the eyes and mind to solve while trying to see what is wrong with the logic itself. It should help you see easier.

I don't know why you use fsm.h. I can only guess it is for timers? But I don't know what it does and don't want to dig to find out.

I see the condition if temp1 > 22 that turns pins 4 and 8 off but I'm not entirely sure what else must be true or false for that condition to even run. It looks like it should at a quick glance but if it's not then something is stopping it or something else is turning those pins back on perhaps very quickly.

Sometimes drawing diagrams on paper can help organize your view. Drawing a map of what you actually have may show you where the missing or extra or wrong part(s) is.