Help with template fan direction not working

These two posts might be enough to get you started.

I forked an updated your gist here. You might need to tweak master_fan_set_percentage a bit.