Calcul on Extended Flow

I have a request to retrieve data, but this data is in W, and I want o display it on Kwh (also /1000)

I create this flow

With this code inside the Execute code :

// My Code
value = parseInt(args[0])
console.log(value);
result = value /1000
console.log(result);
return result;

The result before the execute code is 7809680, when I tried the execution code is ok : 7809 but the result at the end is 7809680.

How I can integrate an operation ?

Watt isnt convertable to kWh without calculating also the timespan.

So 1 Watt / 1000 is 0.001 kilo Watt

But using that 1 W over the period of 10 hour is only only 0.01 kWh

Wher did you put your timespan in your formula?

Beside that your code is not correct,
your flown is also using the [Result] from the Logic card. The Homey script isn’t passing the calcuated value backt to the flow.

Sorry, it’s Wh to kWh (no need time stamp), it’s the direct data from French electriclty counter

1 Like

How I can use the result from the homey script ?

You can use another card that returns the calculated value as a tag you can use in you’re flow.

Or you can use the logic And card to make the calculation:

(I don’t have access to a PC at the moment so I can’t create an example flow, but hopefully this helps.)

1 Like

Thanks a lot; it’s ok