General Homey Script development questions

Hi Robert or others,
I have this script and output, now I want to store the variables in a virtual device and that worked for me with my Qingping

However I am doing something wrong for my Eplucon (Ecoforest) Heatpump, since these variables do not appear in my flow as tags. What should I change?

This is the

// Login and get access token
var result = await fetch("https://portaal.eplucon.nl/api/v2/auth/login", {
  method: 'post',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    username: 'PASSWORD',
    password: 'PASSWORD'
  }),
});

if (!result.ok) throw new Error(result.statusText);

const body = await result.json();
console.log(body)

var access_token = body.access_token;
await tag("eplucon_access_token", access_token);

// Get the current date
const currentDate = new Date();

// Fetch statistics
const urlStats = `https://portaal.eplucon.nl/api/v2/econtrol/modules/1000704/statistics?range=day&day=${currentDate.getDate()}&month=${currentDate.getMonth() + 1}&year=${currentDate.getFullYear()}`;
const optionsStats = {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${access_token}`,
    'Accept': 'application/json'
  }
};

try {
  const responseStats = await fetch(urlStats, optionsStats);
  const dataStats = await responseStats.json();
  
  // Get the latest data point
  const latestDataStats = dataStats.data.data[dataStats.data.data.length - 1];
  
  // Create an object with the desired structure
  const output = {
    Binnentemperatuur: { value: latestDataStats.Binnentemperatuur },
    WW_temperatuur: { value: latestDataStats['WW temperatuur'] },
    Actuele_temp_DG1: { value: latestDataStats['Actuele temp. DG1'] },
    Brine_in_temperatuur: { value: latestDataStats['Brine in temperatuur'] },
    Brine_out_temperatuur: { value: latestDataStats['Brine out temperatuur'] },
    Heating_in_temperatuur: { value: latestDataStats['Heating in temperatuur'] },
    Heating_out_temperatuur: { value: latestDataStats['Heating out temperatuur'] },
    Buitentemp: { value: latestDataStats['Buitentemp.'] },
    Timestamp: { value: latestDataStats.created_at },
  };
  
  // Log the output
  console.log(output);
} catch (error) {
  console.error(error);
}

That result in this output in Homeyscript:

{
login: true,
access_token: ‘XXXXXXXXXXXXXXXXXXXXXX’,
error_code: 200
}
{
Binnentemperatuur: { value: 18.6 },
WW_temperatuur: { value: 47.3 },
Actuele_temp_DG1: { value: 27.1 },
Brine_in_temperatuur: { value: 6.4 },
Brine_out_temperatuur: { value: 6.2 },
Heating_in_temperatuur: { value: 30.3 },
Heating_out_temperatuur: { value: 27.1 },
Buitentemp: { value: 6.1 },
Timestamp: { value: ‘2024-01-22T21:20:00’ }
}

———————————————————
:white_check_mark: Script Success
:leftwards_arrow_with_hook: Returned: undefined