runnane / node-red-contrib-easee

Node-Red module for streaming Easee charger data.
Apache License 2.0
7 stars 4 forks source link

Dynamic Currents always 0 after changing by predefined command and usage msg.payload.body #17

Closed Realf0rce closed 1 month ago

Realf0rce commented 5 months ago

If i use an inject node as it is used in the examples for input for setting the dynamicCurrents.

The currents are always set to 0, regardless of the transmitted value. I am not sure how the values have to be transferred to the REST node. I tried it with the following parameters in the msg.payload.body, Type String: { "phase1": 16.2, "phase2": 15.9, "phase3": 0.5, "timeToLive": 1 } Type Object: { "phase1": 16.2, "phase2": 15.9, "phase3": 0.5, "timeToLive": 1 }

but no success.

nordlings commented 5 months ago

This is how I define my payload in a function node and this works. I use 2min TTL, and I control the charger once every minute.

let l1 = ...;
let l2 = ...;
let l3 = ...;
msg.payload = {
    "path": "/sites/xxxxx/circuits/yyyyy/dynamicCurrent",
        "body": {
            "phase1": l1,
            "phase2": l2,
            "phase3": l3,
            "timeToLive": 2
    }
}

Message is then passed on and injected to a "easee REST Client" node.

nordlings commented 5 months ago

Hey, you're welcome :) But I think you might be right that the examples found in the docs are not 100% correct. I had to try a few things before I figured it out...

Den mån 11 mars 2024 kl 23:05 skrev Rea1force @.***>:

Hello Nordlinge Thanks for the clarification. It works fine for me too.

— Reply to this email directly, view it on GitHub https://github.com/runnane/node-red-contrib-easee/issues/17#issuecomment-1989526989, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASVME7L4VEJI6VPCXFL7Z5TYXYTDDAVCNFSM6AAAAABEQDUPZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBZGUZDMOJYHE . You are receiving this because you commented.Message ID: @.***>

Rea1force commented 5 months ago

Hi, thanks for the quick support. The code for dynamic loading is easy if you write the syntax in a function and have seen it once. Unfortunately I can't rewrite the code for normal commands like pause_charging or resume_charging. I have not quite understood something. if I create the following function

msg.payload = {
    "path": "/chargers/XXXXX/commands/pause_charging",
}
return msg;

I get the following error message

"/chargers/XXXXX/commands/pause_charging GET failed: Error: REST Command failed (405: Method Not Allowed), check console for errors."

Normally I can familiarise myself with syntax relatively well, but here I somehow have no access. :-(

Surprisingly, the command for "start_charging" does not work with the predefined commands in the example and stop, pause and resume.

Have a nice evening

nordlings commented 5 months ago

Hey, cut from my function nodes and directly sent to the "easee REST Client" node.

pause charging msg.payload = { 'path' : '/chargers/xxxx/commands/pause_charging', 'body': {} }; return msg;

resume charging msg.payload = { 'path' : '/chargers/xxxx/commands/pause_charging', 'body': {} }; return msg;

Start- and stop charging has not used so far, and I honestly don't completely understand how those works.

I also fetch the "state" in my control loop (once every minute) to get all the recent values utilized by the the charging control program [total power, output phase, charger mode id, led mode id, error code, fatal error code, smart charging, WIFIRSSI, lifetime energy] instead of running individual get-messages. msg.payload = { 'path' : '/chargers/xxxx/state' }; return msg;

For subscription of all other signals from the charger I use the "easee Charger Streaming Client" node and and captures all messages from "4. ProductUpdate messages" (4th pin out).

Only issue I have right now is when sending new schedule to the charger (basic_charge_plan) I would like to "delete" the old first, but last time I checked, the "delete" message was not available in the node-red implementation of "easee REST Client" node.

Rea1force commented 5 months ago

Works fine, Thanks

Rea1force commented 6 days ago

Unfortunately, this solution with the function no longer works since the last update to version 0.6.1. The Rest API no longer recognises that there is a body and only executes the GET function.

With the update to 0.6.1, there shall be a POST command in the msg.payload. Therefore, the function for dynamic current control now looks like this.

let l1 = ...; let l2 = ...; let l3 = ...; msg.payload = { method: 'POST', “path": ‘/sites/xxxxx/circuits/yyyyy/dynamicCurrent’, “body": { “phase1": l1, “phase2": l2, “phase3": l3, “timeToLive": 2 } }

runnane commented 1 day ago

Hi Yeah, i see that this is a breaking change. I've added a workaround, verified that this works again:

{
    "path": "/sites/yyy/circuits/xxx/dynamicCurrent",
    "body": {
        "phase1": 32,
        "phase2": 32,
        "phase3": 32
    }
}