Creating a Custom sensor that stores the current target temp attribute of my AC/Heater

I am trying to create a custom sensor that reads and stores the current Target Temperature that my thermostat is set so I can use that value in an automation later. is this something that can be done?

Template Sensors