Relay and temperature sensor

Badiou:
I thought I could find a function for the hysterisis but none. However, I guess I can make one enough simple but wouldn't the problem be the same, if I set a new threshold, wouldn't I encounteer the same problem?

No; hysteresis gives you a 'dead band' so that the output has to drop by a small amount before the heater will come back on.

The behaviour you're simulating is the same as an old fashioned, cheap, simple, reliable bimetallic thermostatic switch; have you considered just using one of those?