rkokkelk / nl.xseth.wallbox

GNU General Public License v3.0
2 stars 3 forks source link

Green/ECO mode #35

Open terryhendrix1990 opened 5 months ago

terryhendrix1990 commented 5 months ago

Hi there. I've recently purchased a wallbox pulsar plus with Green/ECO charging modes. Since your app does not support it yet, i did some digging into the API's of wallbox, and reverse engineered how to switch to charging mode.

I've implemented it in Homeyscript for now, but I wanted to share my script with you, so that maybe it can be added to this app.


if(args[0] !== "green" && args[0] !== "eco" && args[0] !== "full") {
  throw new Error("Incorrect charging mode "+args[0])
}

const authResult = await fetch('https://api.wall-box.com/auth/token/user', {
    method: 'POST',
    headers: {
        'Authorization': 'Basic <base-64-ed-username-and-pass>',
    }
}).then(r => r.json())

await fetch('https://api.wall-box.com/chargers/config/<my-secret-charger-id>', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer ' + authResult.jwt,
    },
    body: JSON.stringify({
      ecosmart: {
        "enabled": args[0] === "green" || args[0] === "eco",
        "mode": args[0] === "green" ? 1 : 0,
        "percentage": 100
      }
    })
}).then(r => r.json());

For the percentage argument: this is not exposed in the app, the default of 100% was there already. Since my solar panels are not installed yet I've not figured out what it does yet. I assume its so you can say: 50% of my green charging should come solar energy. (But it could be something completely different.)

Maybe, when i find time i can implement it myself. (I dont have such time often however)