DynDNS (with Infomaniak) Automation

Hi all!

I would like to create a script or automation to update the DynDNS record for my domain i have with Infomaniak.

For that i would like to run an update via REST in one of these conditions:
either all 10 Minutes OR if the external IP of my router changes (thats a DECO M9 from TP_Link that is available as a device in homeassistant).

Can i somehow use this command within an automation?:

rest_command:
  ddns_infomaniak:
    url: "https://infomaniak.com/nic/update?hostname={{ hostname }}&myip={{ ip }}"
    method: post
    username: !secret infomaniak_ddns_login
    password: !secret infomaniak_ddns_password

==================================================

My Router has a sensor: “sensor.m9plus_external_ip” that might be usable to trigger the script / automation?

Thank you for input!