Peblar charger

Is there anyone that managed to add a Peblar charger to Homey, and to read/set charging currents?

Connection to Peblar is possible using both REST API and MODBUS:
Peblar | Developer Information

Using a GET request to the API, I’m able to read the charging current

However I’m not able to set the charging current. According to the API documentation, setting the charging current should be done using a PATCH request. I don’t see how to do a PATCH request in Homey logic, only GET, POST, PUT and DELETE requests seems to be possible.

I tried the MODBUS option as well, but I didn’t get that working.

Anyone an idea?

For an answer you need to see that JSON file if you get one.

{
“CurrentPhase1” : 6104,
“CurrentPhase2” : 0,
“CurrentPhase3” : 0,
“EnergySession” : 2234,
“EnergyTotal” : 2207781,
“PowerPhase1” : 1422,
“PowerPhase2” : 0,
“PowerPhase3” : 0,
“PowerTotal” : 1422,
“VoltagePhase1” : 233,
“VoltagePhase2” : null,
“VoltagePhase3” : null
}

is an example of output after the GET request. So I can read that information and get the CurrentPhase1. That’s no problem.
My question was more: how can I change the charging current. According to the API documentation, that should be done with a PATCH request, and that is what I don’t know how to do

Do you already know what a Patch request is?

No :blush:

You see , there is your problem :grinning:. Just google and you will know if it is possible to make a patch request using available cards.

There can be more path data before that example of output.

I did google but didn’t find an answer, that’s why I started this new topic…
As indicated in my first post, in Homey logic, there is no such thing as PATCH request

Just try Patch Request and you will find tons of documents, i.g.

I know, but how to do it in Homey in (advanced) flows…

I don’t think you want help with your implementation, but help with everything.
I cannot help you with that.

Put your http(s) in.
Leave the rest blank.

Pls create a feature request at Athom support to add the PATCH option.

There are several HTTP methods like GET, POST, PUT , see HTTP Methods GET vs POST

So PATCH is another method. I don’t think you can use the Card GET, as it will send a request using the text GET which you cannot replace by the text PATCH. So you will need some card to send a “raw request” allowing this. For example sending an request in a Telnet session allows you this.

I have not tried it but I think it is possible using HomeyScript

Homeyscript will indeed be the solution to set the charging current. This homeyscript gives me at least a good response:

`const response = await fetch("http://<local ip>/api/wlac/v1/evinterface",{
        headers: {
            Accept: "application/json",
            "Content-Type": "application/json","Authorization":"<authorization code>"
        },
        method: "PATCH",

        body: JSON.stringify({ChargeCurrentLimit: 14000})
    })
const data = await response.json();
log(data);
`

Many thanks for the suggestions & help!

2 Likes

Hi trying, to achieve the same ; but I’m a real newbe in homey script… is there a way you can share the full code ?

In your flow, add a HomeyScript flowcard to execute a script using a logic variable:
image

Click on // My Code to add the script. And on My Arg to add at which mA value you want to charge.

In the example below, the homey logic variable “Pblar_max-mA” contains the value of mA at which I want to charge.
image

The script itself is then like this:

// Set max mA
limit=parseInt(args[0]);
//const response = await fetch
await fetch(“http://[your local IP address]/api/wlac/v1/evinterface”,{
headers: {
Accept: “application/json”,
“Content-Type”: “application/json”,“Authorization”:“[your authorization code]”
},
method: “PATCH”,

    body: JSON.stringify({ChargeCurrentLimit: limit})
})

Adjust in the above script your local IP address and authorization code (which you obtain from the Peblar local web interface)

(Please note that this defines the maximum current at which the Peblar can charge. If there are other limits that apply, the actual current used might be lower, eg if you use solar charging or if there is a household limit set)

ok thx. a pitty that the API has so limited capabilties vs the home assistant integration…

Next to changing the max current, you can also write a script to change number of phases to 1 phase. Those are indeed limited changes you can make to the charger via the API. But you can also read some data from the charger. See the API documentation
https://developer.peblar.com/

My understanding is that home assistant is using the same API, so normally whatever is possible with home assistant you should be able to do with homey as well, but you would need to spend some time in creating flows and scripts…