Check if CC assigned as automation

Could we have a function to test if a CC number has been assigned as an automation control. I would like this so that I can have MIDI automation on custom panels and trigger a repaint only when those CCs are used. It would be even better if we could query a particular control for its automation CC number, if any.