I'm curious what the end gcode you had before it starting acting up was? So it homed fine when you had a G28, but doesn't with the new script? I doubt you have a hardware problem, my guess as to what is going on is based on the gcode commands you are sending.
G28 will home X Y AND Z, the order is typically X, then Y, then Z... but that could be different based on your firmware. Z could also home to 0,0 or to 150,150 or whatever else you designated it in the firmware.
G0 Z1 will move the system to Z=1mm under normal/absolute positioning. If you want to move it up 1mm, then you need to switch to relative positioning first, otherwise it'll just drive straight down into your print, which will try to fight back but will ultimately get melted. To convert to relative positioning, use G91.
I think what you'll need in your end gcode is below:
G91 ;switch to relative positioning
G0 Z1 ;move up 1mm
G28 X Y ;home X and Y only
G90 ;switch back to absolute positioning