Queue and set HVAC settings

I’m working on a project with a script that iterates over several climate-type devices and sets their temperature and mode based on various factors (schedules, boolean toggles, outside temperature, etc.).

The way I have it set up right now, the script sets a “base state” from a combination of the current temperature and whether my wife and I are at home. It then sets a secondary state based on, for instance, if it’s when the baby is at home with the babysitter based on a boolean toggle or a schedule.

Where this gets annoying is that the HVAC units can potentially get set a couple times as the script runs, first by setting the base state and then by a secondary mode. For example, the nursery unit defaults to being off if we’re shown as being away as the base state, but it gets turned on if babysitter mode is on. It’s not the end of the world, but it seems inefficient and can get a bit annoying since our units beep when the settings get changed (not what you want if they change while the baby is napping!).

What I’d like to do that seems like it should be doable is to have the settings somehow queued up, and then to push them to the actual devices at the end of the script. My initial thought was to set up helpers for temperature and mode for each device that get updated during the script and then at the end the set_temperature service is called using those values, but I’m wondering if there’s a cleaner way to do that.

TIA for any suggestions!