Huh, that's a pretty great idea/workflow! I'm still figuring out HA's scripting. I find the JSON based DSL to be pretty awkward so far, so I haven't experimented with it much.
I felt that way too and didn’t like the point and click interface of nodered. Instead, I’m using appdaemon which lets me write all automations using actual code (python) along with the VSCode plugin for HASSOS (not my editor of choice but it’s the only available one)