[TUTORIAL] Advanced Virtual Device for Eplucon/ Ecoforest TH Touch Heatpump

Introduction:
This guide provides step-by-step instructions on how to create a virtual device in Homey Pro to read values from the Eplucon Ecoforest Heatpump. This process involves using the “Device Capabilities” app to simulate a virtual app that communicates with your heat pump.

Preparation:

Step 1: Accessing Device Capabilities

  • After installing, open the Homey Pro app on your smartphone or tablet.
  • Navigate to “Apps” and select the “Device Capabilities” app.

Step 2: Creating a Virtual Device

Step 3: Configuring Device Settings

  • Define the capabilities your virtual device will have
  • See screenshot below which fields I created (and matches my script)
  • You could also import this String in the app”
[tef:AVD:"H4sIAAAAAAACA42WbY+qOBSA/8qkX3VWgfKa3A+AOjKjTry+hs1mUvCgVShayqDezH/fuDszknuVwBeSnvac5zk0pb/QCt5pCF6YMmShPs48+//HtSV5fJ5p3aEz6S0byyQX3Z4akdbIn/SCthc6Bz7uHjZ21E/Pfnr+eZwn4UCOzmwRBM5xq796RZx2oJsNowYMYza2PTfQtU44/Dl4gsYgVPVJj9mZv0xyrTHEstvzl+mKdHtPpj5+lc+rl3l3gh3/hGeG8fzsqgfPXYCIqT3ypb0/mK69gx+fp9usN4tZIgbO7iA1tLnpTbBa8CALXnYJvEzsrUKX7qh9HBfqarwNnpYjXVFs5zTQyGo2m7VaZDDuL1vP3TxqOcE237Xez5k2phse6z5f5mCHUrSAjrroP2n9uXMyzN0xxbjd8YvTdLGhnHEnT1ShN4rFrAjgMFt3bdv+8QM1UZhnIk0u/c2Q9eujiVJO15SR2FshC2GCsQy4/QhgRI8Yh8YjMTX5EZMoUHRiSpKCURNlIARl60sGBAz4+vT2TuIc3i5pBWECWU3E8iQA/hpN4Sh6FOJVhqz2dXj03/srIJUiTprGQNiNNU4uRHor4JIEOLkRGNCsXDyMM2ShVGyAo69J0ogkgCzkUMaACUj2wInI89KMCewJJwJcsicBjamgkCErInEG1zmbtLAv2RMgWc7h7TsTh2smlwMR0IvTwiX8AiV4Dr9Fp2R9c9xjGV1vxG+L5E/8BeFJQQTwh1sKcg0FuZaCXKkg31GQqxSUry/AU/ZA2XcppQa0UgtaqYRW7kArVdC4DJ1T8V0L16DGtahxJTW+Q61+gs2BF4QnlK3LPVVr0Km16NRKOvUeXWVPq4Lan17ltms1xLRaYlqlmHZHTKti1782S07F7TNGr4Gv18LXK/H1O/h6Fb7xie/OH1Y8332XMmpAG39A7zlkWZnYqCQ27hAblcRDypDV/ku9DpAjsuTrgHndTgHP6VXKrCFllqQE8Ld9WpT+KGalj3nHx6z06UBIE3L5fUkfzc9bUunkF7BPk/1Ddx/nl6tTExFk/f3Px7+CkMFCUAkAAA==":/tef]

Step 4: Establishing Communication with Eplucon Portal API

  • Use the same credentials as you use for the portal Eplucon portaal
  • Install Homeyscript in Homey
  • use this script to fetch your Module ID (one time). You need to ensure that the module ID in the URL of the below below script (modules/1000704) is applied and corresponds to your actual heat pump module.
// 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: 'USERNAME',
    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);

// Fetch account info
var accountInfo = await fetch("https://portaal.eplucon.nl/api/v2/account/info", {
  method: 'get',
  headers: {
    'Authorization': `Bearer ${access_token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
});

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

const accountInfoBody = await accountInfo.json();
console.log(accountInfoBody);

// Fetch list of accounts modules
var modules = await fetch("https://portaal.eplucon.nl/api/v2/econtrol/modules", {
  method: 'get',
  headers: {
    'Authorization': `Bearer ${access_token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
});

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

const modulesBody = await modules.json();
console.log(modulesBody);
  • Use this script to fetch the variables from Eplucon on a continuous base, only amend
    USERNAME
    PASSWORD
    MODULEID in the url (modules/1000704)
// 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: 'USERNAME',
    password: 'PASSWORD'
  }),
});

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

const body = await result.json();
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: parseFloat(latestDataStats.Binnentemperatuur) },
    WW_temperatuur: { value: parseFloat(latestDataStats['WW temperatuur']) },
    Actuele_temp_DG1: { value: parseFloat(latestDataStats['Actuele temp. DG1']) },
    Brine_in_temperatuur: { value: parseFloat(latestDataStats['Brine in temperatuur']) },
    Brine_out_temperatuur: { value: parseFloat(latestDataStats['Brine out temperatuur']) },
    Heating_in_temperatuur: { value: parseFloat(latestDataStats['Heating in temperatuur']) },
    Heating_out_temperatuur: { value: parseFloat(latestDataStats['Heating out temperatuur']) },
    Buitentemp: { value: parseFloat(latestDataStats['Buitentemp.']) },
    Timestamp: { value: latestDataStats.created_at },
    // Added values
    Cv_druk: { value: parseFloat(latestDataStats['Cv druk']) },
    Actueel_verbruik: { value: parseFloat(latestDataStats['Actueel verbruik']) },
  };
  
  // Create tags from the output object
  for (let key in output) {
    await tag(key, output[key].value);
  }
  
  // Return the output
  return output;
} catch (error) {
  console.error(error);
}
  • If you want more values, you might consider to ask ChatGPT to extend the script in the same manner for these variables:

Binnentemperatuur":20.5,“WW”:1,“Ingestelde temp. WW”:45,“Aanvoer setpoint verwarming”:21,“Aanvoer setpoint koeling”:15,“Ingestelde temp.”:20,“Brine in temperatuur”:2,“Brine druk”:1.9,“Brine out temperatuur”:-0.3,“Heating out temperatuur”:34.2,“Cv druk”:1.8,“Heating in temperatuur”:29.4,“Verdamping temperatuuur”:-3,“Condensatie temp.”:34.5,“Inverter temp.”:4,“Compressor toerental”:179.5,“Zuig gas temperatuur”:2.5,“Compressorzuigdruk”:6.3,“Pers gas temperatuur”:61.2,“Compressorafvoerdruk”:20.1,“Oververhitting”:5.4,“Positie expansie ventiel”:41,“Buitentemp.”:4.5,“WW temperatuur”:48.4,“Actueel verbruik”:0,“Totaal import energie”:0,“Totaal export energie”:0,“Act. vent. toerental”:25,“Actuele temp. DG1”:34.2,“Actuele temp. SG2”:0,“Actuele temp. SG3”:-999.9,“Actuele temp. SG4”:-999.9,“Setpoint verwarming DG1”:31.6,“Setpoint verwarming SG2”:0,“Setpoint verwarming SG3”:0,“Setpoint verwarming SG4”:0,“Setpoint koeling DG1”:18,“Setpoint koeling SG2”:10,“Setpoint koeling SG3”:10,“Setpoint koeling SG4”:10,“Positie ventiel SG2”:100,“Positie ventiel SG3”:100,“Positie ventiel SG4”:100,“created_at”:"2024-03-24T00:00:00

Step 5: Create a flow to fetch the data

Step 6: The fun part

  • In Insights you can track performance of the values.
  • I use it to compare “graaddagen” with the performance of the pump
  • I use it to prevent the CV Druk will be below 1,2 then refill and warning below 0,8 unstable situation, and 0,5 Heatpump stops operating
  • I want to use to also track Energy consumption, but need to install first the energy meter in the fuse box… That will also make the connection between solar panels and optimize the heat pump energy usage

Your help is highly appreciated
In essence, your expertise can elevate this guide to the next level. I welcome your feedback and any additional insights or flows you’ve crafted. Let’s collaborate to optimize our use of the Eplucon Ecoforest Heatpump in the smartest ways possible. Share your thoughts and findings here. Thank you for contributing to this innovative journey.

1 Like

Reserved

Blockquote @Theo_Hendriks : Hi Wout, is this read only or are you also able use Homey to change settings of the Heatpump, like On/OFF, setting temprature of te Boiler, or adjusting the weekly schedule for heating and tap water to match the de day low prices. I currently use smart plugs to switch my Techcontrollers, which manage the underfloor heating distributors, on or off depending on the heat demand and actual electricity price.

Indeed this is a read only virtual device. But from the API documentation and after a conversation with Eplucon you also should be able to “write” settings. I did not implement this since I lack the knowledge to do so, but MAINLY because I do not change the settings that often. The API is very complete in changing settings.

Regarding “daily low prices” you can change that in the Eplucon portal (i did also):

For the PV Output and steering hot water / boiler I am working on to have a energy meter in the Fuze box.

1 Like

In a few months I will have a complete Eplucon installation and definitely will try this out!

1 Like

Looking forward to get more inspiration from others…

Wout, thank you, I’ll see if it works. Super

1 Like

Wout, you spoke to Eplucon. Is it an idea to share this topic with them as bot Eplucon and Homey are Dutch?

Maybe interesting for both?

I am about to do that, however their intent and feedback was, communication is via the contractor.

Let’s see if they see the added value. Are you satisfied with your system?

Ik ben aan het proberen om mijn ecoforest toe te voegen. Top dat je deze handleiding gemaakt hebt :smiley: !

Ik krijg alleen een foutmelding in de homescript;

———————————————————
❌ Script Error
⚠️ Error: Not Found
    at Eplucon Stats.js:14:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HomeyScriptApp.runScript (/app/app.js:502:22)
    at async Object.runScript (/app/api.js:30:22)

Enig idee hoe dit kan? Daarnaast kan ik lastig zien hoe je flow in elkaar zit. Wat is de reden van de vraagtekens in de “Dan” kaarten?

1 Like

Flow:

Script error:

I forgot to mention that you also need to amend the Module ID in the url, in order to fetch your module ID, run the below script in Homeyscript:

// 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: 'USERNAME',
    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);

// Fetch account info
var accountInfo = await fetch("https://portaal.eplucon.nl/api/v2/account/info", {
  method: 'get',
  headers: {
    'Authorization': `Bearer ${access_token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
});

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

const accountInfoBody = await accountInfo.json();
console.log(accountInfoBody);

// Fetch list of accounts modules
var modules = await fetch("https://portaal.eplucon.nl/api/v2/econtrol/modules", {
  method: 'get',
  headers: {
    'Authorization': `Bearer ${access_token}`,
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
});

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

const modulesBody = await modules.json();
console.log(modulesBody);

Then you need to Ensure that the module ID in the URL of the initial script (modules/1000704) is correct and corresponds to your actual heat pump module.

Thanks for the quick reply :smiley: . I tried the homey script for the module ID, but this also generates a fault message. Sorry to bother you; am I doing something wrong?

———————————————————
❌ Script Error
⚠️ Error: Not Found
    at Eplucon get.js:14:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HomeyScriptApp.runScript (/app/app.js:502:22)
    at async Object.runScript (/app/api.js:30:22)

No worries, happy to see I can improve the tutorial with your trials…

I can check the error tomorrow OR I can help you with a how to script approach:

I used Chatgpt with this instruction:

  • Context Description:

This script is designed to fetch data from a specified API endpoint, extract a particular value from the API response, and use that value to create a tag in your system.

The script sends a request to the API endpoint and expects the API to respond with a text response. The script then processes this response to extract the required data. This extracted data is then used to create a tag in your system.

If the tag creation is successful, the script returns a success message indicating the name of the tag and the value used. If an error occurs during the tag creation or during the fetch request to the API, the script returns an error message detailing the error.

This script is designed to be run in a Homeyscript environment and assumes that a tag function is available in your environment for tag creation.
*

Then you share the script and the error in the same prompt… And ask Chatgpt to rewrite the script…

I tried, but ChatGPT only comes so far, it suggest I check the API data because there would be a problem there. I checked the API, and even when I fill in my username and password on the API site itself, it cannot connect. Maybe the API is not up and running yet? Is your system working?

Hi @flowerpiece I will have a look at this in the weekend, for me it is working all, and to help others, I wrote this tutorial…

I tried to solve this for you, did you copy paste the right script, because it gives an error on row 14 in the JS.

Maybe -if you open for that- I can try it with your credentials, which you send via DM… let me know if you are open to that…

Yeah I double checked the script, and I copied the exact same script. The installer was here last week for maintenance, and updated the TH touch to the newest version (1.14 if I recall correctly), but also still the same error.

If I go to https://portaal.eplucon.nl/api/v2/auth/login link, it gives me an 404 error. Do you get the same?

yes, since via browser you cannot access the API… Can you share a screenshot of the script setup?

Okay, I made 2 screenshots (wouldn’t fit on 1 screen). Second picture also shows the output of the script.


Ben je hier nog mee verder gekomen?