Homeyscript feeding Solar Panel API to Virtual Device sensors?

I’m new to Homey but I’m using the self-hosted server and I have a weird Solar Panel inverter (Renac) that only some very old Github API resources mentioned, some for Home Assistant which I don’t use.

But I used those as a starting point and then through trial and error and the web interface was able to kind of reverse engineer a Homeyscript to spit out the information I need. Once logged into the API it needs to fetch the Station List, then the Device List and then the Inverter Data. Eventually I have this that creates the actual output and it works when running the Homeyscript itself:

const output = {
  station: {
    id: stationId,
    name: station.station_name,
    day_kwh: station.day_energy,
    total_kwh: station.sum_energy
  },
  inverter: {
    sn: inverterSN,
    model: device.MODEL_NAME,
    status: device.STATUS
  },
  live: {
    power_w: live.output_power,
    day_kwh: live.day_energy,
    total_kwh: live.sum_energy,
    temp_c: live.temp,
    alarm: live.alarm,
    pv: {
      pv1: { vol: live.pv1_vol, cur: live.pv1_cur, power: live.pv1_power },
      pv2: { vol: live.pv2_vol, cur: live.pv2_cur, power: live.pv2_power },
      pv3: { vol: live.pv3_vol, cur: live.pv3_cur, power: live.pv3_power },
      pv4: { vol: live.pv4_vol, cur: live.pv4_cur, power: live.pv4_power }
    },
    grid: {
      r: { vol: live.r_vol, cur: live.r_cur, power: live.r_power, freq: live.r_fre },
      s: { vol: live.s_vol, cur: live.s_cur, power: live.s_power, freq: live.s_fre },
      t: { vol: live.t_vol, cur: live.t_cur, power: live.t_power, freq: live.t_fre }
    }
  }
};

With this I get all the power, current, voltage, and day energy, total kwh and so on.

Now I want to feed this into the Virtual Device I have created and it shows all the Energy, Voltage, Temp and so on on the card, but it doesn’t update. Of course I need a Flow. So I have set up a Flow to run the Homeyscript and set the sensor value to its output, but they all fail.

I’ve tried this in Homeyscript and they all return Not setable:

const d = await Homey.devices.getDevice({ id: "<id>" });
console.log(d.capabilities);
  'measure_voltage',
  'measure_temperature',
  'alarm_generic',
  'measure_current',
  'measure_power',
  'meter_power'

The same with:

const deviceId = "<id>";

await Homey.devices.setCapabilityValue({
  deviceId,
  capabilityId: "meter_power", // or whatever I target here
  value: 123
});

return "OK";

When searching for it, I found no solutions apart from the fact that Homey sensors within Virtual Devices are indeed not setable by users, and as such not by flows.

I’ve seen an app called Device Capabilities but I cannot figure out how to use that or where to start and because I don’t even know that’s the way to go, it’s not something to just try either.

Can someone point me in the right direction? The API works, I just need to find a way how I can set the values of my Virtual Device so it can display the current live power being generated, the sum of the day and optionally the rest.

Write the values to Homeyscript tags, these tags become available in flows. Then you ate able to feed the virtual device with the values from these tags.