Flow notification is always giving me the time in UTC

Any help would be appreciated as this is making my shit itch tonight.

I have made a script that tells me the cheap window each day for my immersion heater.

It outputs in UK 24hr but when I use a notification homey sends it in UTC 12hr.

I have re made the variable multiple times, moved my location around and rebooted homey. But it always outputs the notification in UTC and I can not seem to solve it. Anyone any idea how to change it.

Screenshot of the script output and homey notification attached

The variable is a text variable and this is the script I’m using

// ================== CONFIG ==================

const productCode = ‘AGILE-24-10-01’;

const tariffCode  = ‘E-1R-AGILE-24-10-01-A’;

const lookAheadHours = 24;

const immersionPowerKW = 3.0;

let windowHours = 2;

const DEVICE_NAME = ‘Immersion Heater’;

// ================== UK TIME FORMAT ==================

function formatUK24(date) {

return new Intl.DateTimeFormat(‘en-GB’, {

timeZone: 'Europe/London',

hour: '2-digit',

minute: '2-digit',

hour12: false

}).format(new Date(date));

}

async function run() {

try {

// ================= LOAD SETTINGS =================

try {

const v = await Homey.variables.get(‘Immersion_Window_Hours’);

  windowHours = parseFloat(v) || windowHours;

} catch (e) {}

const now = new Date();

const nowTime = now.getTime();

const url =

`https://api.octopus.energy/v1/products/${productCode}/electricity-tariffs/${tariffCode}/standard-unit-rates/\` +

`?period_from=${now.toISOString()}&period_to=${new Date(now.getTime() + lookAheadHours * 3600 * 1000).toISOString()}`;

// ================= FETCH DATA =================

const response = await fetch(url);

if (!response.ok) throw new Error(`API Error: ${response.status}`);

const data = await response.json();

if (!data.results?.length) {

  log('⚠️ No tariff data returned');

return;

}

let rates = data.results

  .map(r => ({

from: new Date(r.valid_from),

    to: new Date(r.valid_to),

    price: Number(r.value_inc_vat)

  }))

  .sort((a, b) => a.from - b.from);

const slotsNeeded = Math.round(windowHours / 0.5);

let cheapestTotal = Infinity;

let bestIndex = 0;

for (let i = 0; i <= rates.length - slotsNeeded; i++) {

let sum = 0;

for (let j = 0; j < slotsNeeded; j++) {

    sum += rates\[i + j\].price;

  }

if (sum < cheapestTotal) {

    cheapestTotal = sum;

    bestIndex = i;

  }

}

const start = rates[bestIndex].from;

const end = rates[bestIndex + slotsNeeded - 1].to;

const startTime = start.getTime();

const endTime = end.getTime();

// ================= CALCULATIONS =================

const avgRate = cheapestTotal / slotsNeeded; // p/kWh

const energyKWh = immersionPowerKW * windowHours;

const costGBP = (energyKWh * avgRate) / 100;

const shouldBeOn = nowTime >= startTime && nowTime < endTime;

// ================= LOG OUTPUT =================

log(\`🔥 CHEAP WINDOW FOUND\`);

log(\`Start: ${formatUK24(start)}\`);

log(\`End: ${formatUK24(end)}\`);

log(\`Avg price: ${avgRate.toFixed(2)} p/kWh\`);

log(\`Energy: ${energyKWh.toFixed(2)} kWh\`);

log(\`Cost: £${costGBP.toFixed(2)}\`);

log(\`State: ${shouldBeOn ? 'ON' : 'OFF'}\`);

// ================= SAFE NOTIFICATION (NO TIME PATTERN) =================

const variables = await Homey.logic.getVariables();

const notifyVar = Object.values(variables)

  .find(v => v.name === 'Immersion_Notify');

if (notifyVar) {

const message =

`🔥 Immersion Window\n` +

`Start time ${formatUK24(start)}\n` +

`End time ${formatUK24(end)}\n` +

`Avg rate ${avgRate.toFixed(2)} p/kWh\n` +

`Energy ${energyKWh.toFixed(2)} kWh\n` +

`Cost £${costGBP.toFixed(2)}`;

await Homey.logic.updateVariable({

    id: notifyVar.id,

    variable: {

      value: String(message)

    }

  });



}

// ================= DEVICE CONTROL =================

const devices = await Homey.devices.getDevices();

const heater = Object.values(devices).find(d => d.name === DEVICE_NAME);

if (!heater) {

  log('❌ Immersion heater not found');

return;

}

const currentState = heater.capabilitiesObj.onoff.value;

if (shouldBeOn && !currentState) {

await heater.setCapabilityValue(‘onoff’, true);

  log('🔥 IMMERSION ON');

}

if (!shouldBeOn && currentState) {

await heater.setCapabilityValue(‘onoff’, false);

  log('❄️ IMMERSION OFF');

}

} catch (err) {

log(\`❌ Error: ${err.message}\`);

}

}

await run();

Thanks in advance

Do you check on readability of your posted code? It’s a pretty messy now:

I’ve sorted that, thought I’d clicked the icon to wrap it properly