As far as I'm aware, though not from first-hand experience, if you have the EDDI plugin installed and enabled, it should automatically execute commands based on ingame events, provided those commands have a specific name:
Whenever EDDI sees a particular event occur it will attempt to run a script. The name of the script depends on the event, but follows the form:
((EDDI <event>))
with the <event> being in lower-case. For example, if you wanted VoiceAttack to run a script every time you docked you would create a script called ((EDDI docked)) (note the lower-case d at the beginning of docked).
"script" in this case refers to a VoiceAttack command.
There is an event listed for "Hardpoints", though I don't see one for "Cargo hatch", so that may not be entirely what you need.
For more detailed information, you may want to contact the developers of EDDI, who are reportedly present on
this Discord.