Save sensor state to a file?

I have an alarm panel integrated with HA but the alarm status sensor loses its value if I reboot HA.
Is it possible to write the state of that sensor to a file and then if a restart is triggered in HA (check uptime value perhaps) then read the value from a file, otherwise it just gets sets normally?

Or maybe there is a smarter solution for my problem?