I’ve only had the Victron system for a few days and unfortunately, I’m stuck with the API. Hopefully, someone here can help.
I have a Cerbo GX, a Multiplus II (with a Pylontech battery connected to it), and an ET340. I also have 2 Growatt inverters.The system operates as an ESS, and that part is working well.
In the VRM portal, a negative value is shown under "grid" when more power is generated than consumed. It's quite frustrating that this isn’t captured under "to grid," otherwise, I would have already found what I need in the API.
To see how much I’m feeding into the grid, I created a custom widget in the portal. It shows the "grid meter - grid total energy to net (kWh)" from the ET340. This value seems to be accurate. Again, Victron, it's really annoying that this isn’t displayed on the dashboard.
I’m trying to access this value through the API but haven’t had any luck so far. I recently tried using the "graph" endpoint, but it didn’t return any data.
I’ve implemented this using PHP. I hope someone has a tip for me on where I can find this in the API or how I might be able to configure the system to show this value under "to grid" on the dashboard.
Does anybody know, what these attribudeCodes are?
Thanks, everyone!
Here's the code so far:
-------------------------
$username = private
$password = private
$siteId= private
$userId= private
$instance = 30; //instance of the et340
>>>>> $attributeCodes = ['dE']; // what should stand here? <<<<<
$attributeIds = [540];
$startTime = strtotime("-2 days");
$endTime = strtotime('now');
$useMinMax = 1;
$width = 768;
$apiUrl = 'https://vrmapi.victronenergy.com/v2/installations/' . $siteId . '/widgets/Graph';
$queryParams = http_build_query([
'attributeCodes[]' => $attributeCodes,
'attributeIds[]' => $attributeIds,
'start' => $startTime,
'end' => $endTime,
'instance' => $instance,
'useMinMax' => $useMinMax,
'width' => $width,
]);
$apiUrl .= '?' . $queryParams;
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'x-authorization: Bearer ' . $bearerToken,
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$responseData = json_decode($response, true);
print_r($responseData);