goecharger / go-eController-API

API specification for go-eController
9 stars 1 forks source link

Suggestion: Allow Input for Battery and Custom Sensors via API #7

Open SvenAbels opened 10 months ago

SvenAbels commented 10 months ago

Hi,

the go-e Controller is an absolutely fantastic device. I would like to suggest a feature which would make it even more valuable for all PV users: The go-e Controller can only measure AC batteries. However, most solar power batteries are DC batteries and integrated into the inverter setup. However, most of them have an API or are integratable into systems such as HomeAssistant.

I would like to suggest to extend the go-e Controller API to allow users to push the battery state of their DC battery using either the http API or the MQTT interface. This would allow the visualisation of batteries on the device display and in the app. (In principle this delivery of data could also be provided for other custom categories.)

0xFEEDC0DE64 commented 9 months ago

could you try setting the api key "ids" (inverter data setter) every 5 seconds to an json object? the values are in Watt.

ids={pakku:0}

more discussions on this api key: https://github.com/goecharger/go-eCharger-API-v2/discussions/110

SvenAbels commented 9 months ago

@0xFEEDC0DE64 I tried that but the response from the goe-controller is null. When sending it to the charger instead of the controller, then the response is

{
  "ids": true
}

I used the following URL to test it: http://charger-ip/api/set?ids={pakku:5}

However, the controller still shows the battery as greyed out in the app. When lookingg at the /api/status of the charger, then pakku is also still null. So I assume that this did not work.

SvenAbels commented 9 months ago

@0xFEEDC0DE64 Did you see my message?

ai91 commented 8 months ago

@0xFEEDC0DE64 Hello Daniel,

I have pretty same question. I read german discussion on link above, but it's still not clear to me how to update battery value and what sign it's updated.

What did I do: wrote to MQTT topic %charger_topic%/ids/set a json string {"pakku":42}. Immediately got confirmation on topic %charger_topic%/ids/result with message success. Though I'm getting same confirmation with any random keys in this json. I've tried to write pakku, pAkku. Unfortunately I don't see any signs the value has been really accepted. I was expecting to see updated akku value on %charger_topic%/ccd topic, or in go-e controller/charger interface on mobile app. Unfortunately nothing happens. 2023-12-28 23_17_31-MQTT Explorer3 (not sure why github renders broken attachments, here is a picture on dropbox)

Could you please advise how can I confirm the value is there?

Configuration: go-e charger Gemini 22, HW v4, serial 201060, FW 055.8 go-e controller serial 905831, FW 1.0.6 Controller has installed three sensors on grid line, and one on solar line. On UI I see all power streams, but battery. 2023-12-28 23_42_05-go-e2 (picture on dropbox)

My goals are:

  1. to let charger know it can start charging based on info that PV produces enough energy, but not detected yet by sensor, as all energy goes into battery. This info I can write to charger/controller with my scripts (reading this info via modbus directly from inverter)
  2. display this info on mobile app UI.

I thought it would be enough if I set values into /ids/set as 'pakku'. But seems I misunderstood something, or misconfigured.

ai91 commented 7 months ago

Ok, I guess I can answer on some questions on my own (just in case if anybody else has same questions).

  1. The property names are case sensitive (at least when setting via MQTT). The correct names are "pAkku", "pPv", "pGrid". Means when setting via MQTT, the content for topic %charger_topic%/ids/set should look like: {"pAkku":-1000}, or {"pGrid":663, "pPv": 42, "pAkku":-1000}
  2. Despite of success response at %charger_topic%/ids/result, the real successfull result can be observed at following topics: %charger_topic%/pgrid, %charger_topic%/ppv and %charger_topic%/pakku. When providing incorrect properties (like pakku) - one still gets success response, but no value update on %charger_topic%/pakku.
  3. When setting not all properties, but only one (or two) value(s) via %charger_topic%/ids/set, skipped properties get null value. For example I'm getting pgrid and ppv values from go-e controller every second. If in parallel I'm running my script with update of pAkku value, then pgrid and ppv are getting null immediately after each update of pAkku. On next update of pgrid and ppv from go-e controller, the pakku get reset to null.
  4. No other signs if values were updated are found. Nothing on UI in go-e Charger Android App.

Also not sure how go-e charger behaves when updating values from different sources (see 3.) - wouldn't it be confused when it gets pgrid and ppv from controller, but pakku from MQTT? Taking into account it sets to null missing values on each update?

0xFEEDC0DE64 commented 7 months ago

to also show the battery power on the controller and in the app, you can use our external category powers api key:

ecp

is an array of powers measured in watt for each fixed or custom category. (use ccn for resolving the category names).

For example to set battery power to 1000W do following:

ecp=[null,null,null,null,null,1000]

usually the list is sorted like this: Home, Grid, Car, Relais, Solar, Akku, then the 10 custom categories

ai91 commented 7 months ago

ecp (external category powers api key)

Whoa. ecp is even better! First of all - it's a controller's input, which in turn will be transferred to a charger. As a result charger/pakku is also updated automatically! Secondly - it also updates controller UI in the app. image

Din't check yet, but I believe the [5]'th value set via controller/ecp ( -> charger/pakku) is taken into account by charger in order to detect surplus energy by substracting it from pgrid (@0xFEEDC0DE64 right?). So ecp is an answer on initial quesion. @SvenAbels must be happy :-)

Sidenotes for others:

  1. It's a go-e controller's api key (not charger's. not documented yet)
  2. It can't be written over MQTT (at least with firmware 1.0.6 I'm getting result api key is not allowed from mqtt).
  3. Works over http api. I don't like exposing http api: first of all it's unsecure as not protected, secondly it accepts GET requests for updates. Nevertheless, usage example: curl --location --globoff 'http://192.168.1.202/api/set?ecp=[null%2Cnull%2Cnull%2Cnull%2Cnull%2C1000]'
  4. charger/pakku gets updated automatically by go-e controller
woopstar commented 3 months ago

( -> charger/pakku) is taken into account by charger in order to detect surplus energy by substracting it from pgrid

Has anyone ever figured out if pAkku is subtracted from pGrid ? I believe pAkku is being used in beta 0.56.2 firmware.