Help\how to create an app

Hello @Jeroen_Tebbens
Here you go (replace ip-address with your inverter)

// Script die voor zonnepanelen het huidige vermogen en opgewekte energie (huidige dag) ophaalt uit de SF-WR-4200 omvormer

// ophalen huidige vermogen
let url = "http://<replace inverter ip>/gen.measurements.table.js";
const response_p = await fetch(url, {
  "headers": {
  },
  "method": "GET",
})
const content_p = await response_p.text();
const start_p = content_p.indexOf('P AC') + 27;
const tmpFromStart_p = content_p.substring(start_p);
const end_p = tmpFromStart_p.indexOf('<');
const tmpDone_p = tmpFromStart_p.substring(0, end_p);
const dataInt_p = parseInt(tmpDone_p, 10);
const power = Number.isNaN(dataInt_p) ? 0 : dataInt_p;
console.log("Power: "+power);

// ophalen opgewekte vermogen
url = "http://<replace inverter ip>/gen.yield.day.chart.js";
const response_e = await fetch(url, {
  "headers": {
        'content-type': 'text/plain'
  },
  "method": "GET",
});
const content_e = await response_e.text();
const start_e = content_e.indexOf('labelValueId') + 29;
const tmpFromStart_e = content_e.substring(start_e);
const end_e = tmpFromStart_e.indexOf('Wh') - 1;
const tmpDone_e = tmpFromStart_e.substring(0, end_e);
//const dataInt_e = Math.round(parseFloat(tmpDone_e) * 1000);
const dataInt_e = parseFloat(tmpDone_e);
const energy = Number.isNaN(dataInt_e) ? 0 : dataInt_e;
console.log("Energy: " + energy);

//await setTagValue("SF-WR-4200_Vermogen", {type: "number", title: "SF-WR-4200 Vermogen"}, power ); 
//await setTagValue("SF-WR-4200_Energie", {type: "number", title: "SF-WR-4200 Energie"}, energy );


return power;

if script is working for you, uncomment the last 2 lines to create script tag’s to be used in homey flow’s etc. Or change this to anything else of your liking to fill other variables, or (virtual device) capabilities etc.
Have fun!

1 Like