Disable Recorder and Influxdb programmatically, vía Automation, Script or AppDaemon

Hi.

I need to start HAss with Recorder and Influxdb configured, enabled and working.
Later, when some condition meets, I would like to be able to disable them programmatically.
And after some point, reenable it.

Is it possible?

Or the only way is to modify via script or AppDaemon the Cfg YML and then call homeassistant.restart?

Thanks!