Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Activer power calculation #35

Open
azertylr opened this issue Dec 12, 2024 · 0 comments
Open

[Feature request] Activer power calculation #35

azertylr opened this issue Dec 12, 2024 · 0 comments

Comments

@azertylr
Copy link

Hello,

I've been using this awesome lib for years!
I'm using the active power (because it is what is billed) and the difference between apparent power and active power can be high at low load (which is, most of the time!)

So far I am doing the calculation outside the lib in arduino (custom code) or in Node-Red.

I don't know if it's better to calculate the active power in this library or outside, like in Tasmota (refering for example to arendst/Tasmota#19756)

The code follows the increment of EAST and calculate the active power. It is averaging over the last 1 minute but it can be lower, especially at high load. It can (with interval=0), calculates the active power, everytime EAST increases.

This is for example a Node-Red function that takes for input EAST (in Standard mode), and outputs active power minutely.

    let now = Date.now();
    let interval = (1000 * 60); 
    let wh = msg.payload;

    let lastSend = context.get("last_send");
    let lastWh = context.get("last_wh");
    let lastEAST = context.get("last_EAST");
    context.set("last_EAST", wh);

    if (lastSend === undefined || lastWh === undefined || lastEAST === undefined) {
        context.set("last_send", now);
        context.set("last_wh", wh);
        context.set("last_EAST", wh);
    }
    else if (now - lastSend >= interval && wh > lastWh && wh > lastEAST) {
        context.set("last_send", now);
        context.set("last_wh", wh);
        let Pactive = 3600000 * (wh - lastWh) / (now - lastSend)
        return { topic: "teleinfo/Pactive", payload: Math.round(Pactive) };
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant