MQTT retain value

I have setup hass agent a service for windows which runs on my laptop. This service exposes sensors to home assistant. What I want is to retain the value of sensors when I turn off the laptop rather than showing unavailable.

think easiest is to craft a template around that, detect unavailable determine last value. Shouldnt be that hard.