[How To] Use HomeyScript to update your free hostname at No-IP.com

Are you also sick of the e-mails from no-ip.com every 4th week to renew your free hostname?
There is a simple script you can make and then run however you want from a flow.

Requierments
HomeyScript App for Homey | Homey

Steps

  1. Install linked app above
  2. visit https://my.homey.app/ from your computer
  3. Click on HomeyScript icon to the left (highlighted in blue)
    homey-script
  4. Click on “+ New HomeyScript”
    New
  5. Name the script to your liking
  6. Paste this code:
const username = 'your_noip_username';
const password = 'your_noip_password';
const hostname = 'your_noip_hostname';

// Base64 encoding function
function base64encode(str) {
    return Buffer.from(str).toString('base64');
}

function updateDDNS() {
    const url = `https://dynupdate.no-ip.com/nic/update?hostname=${hostname}`;
    const auth = 'Basic ' + base64encode(username + ':' + password);

    fetch(url, {
        method: 'GET',
        headers: {
            'Authorization': auth
        }
    })
    .then(response => {
        console.log(`statusCode: ${response.status}`);
        return response.text();
    })
    .then(data => {
        console.log('response:', data);
    })
    .catch(error => {
        console.error('Error:', error);
    });
}

// Call the function to update DDNS
updateDDNS();

  1. Replace 'your_noip_username' , 'your_noip_password' , and 'your_noip_hostname' with your actual No-IP credentials and hostname.
  2. Save the script and test. You can log in to no-ip.com and check when your last renewal was, it should be the same timestamp as you ran the script test.
  3. Create a flow to runt the script as you like, I set up mine to run every two weeks:
    flow

This can be combined with other flows or advanced flows to runt when your external IP change or similar.

Hope this will help somebody :slightly_smiling_face:

2 Likes

Very interesting :+1:

Thank you very much👍🏼