Batteries /api/batteries.
See Supported Devices for more information.
The /api/batteries endpoint can be used to retrieve information about the control system of the Plug-In Battery/batteries and allows you to change the control mode.
Despite its name, the /api/batteries endpoint is available on the P1 Meter and kWh Meter. These devices manage and control connected batteries. The endpoint is not available directly on the Plug-In Battery.
Parameters
| Data | Type | Access | Description | Availability |
|---|---|---|---|---|
| mode | String | Read/Write | Control mode of the Plug-In Battery. Can be zero, to_full, standby, or predictive. Mode predictive is available for API version 2.3.0 (in beta) | Available Beta |
| permissions | Array[String] | Read/Write* | Permissions to allow charging, discharging, both, or neither. Note: Read-only in to_full mode. | Available |
| charge_to_full | Boolean | Read/Write | Whether the Plug-In Battery should be charged to full. This will replace the to_full mode. When to_full mode is enabled, this field will be set to true and all the batteries will charge to 100%, when all batteries are fully charged, this field will be set to false and the mode will switch to the previous mode. You can turn off charge_to_full at any time. | Beta |
| battery_count | Number | Read-only | Number of connected Plug-In Batteries. | Available |
| power_w | Number | Read-only | Current combined power consumption/production of the controlled Plug-In Batteries. | Available |
| target_power_w | Number | Read-only | Target power consumption/production of the controlled Plug-In Batteries. | Available |
| max_consumption_w | Number | Read-only | Maximum allowed consumption power of the controlled Plug-In Batteries. | Available |
| max_production_w | Number | Read-only | Maximum allowed production power of the controlled Plug-In Batteries. | Available |
API 2.3.0 requires a firmware updates for certain devices, this firmware is currently being tested by a closed group of beta testers.
- P1 Meter:
6.04xxor higher - kWh Meter:
5.02xxor higher
Mode
The group of connected batteries can be controlled in five different modes:
zero- The Plug-In Battery will try to keep the power consumption/production of your home at zero. This means that the Plug-In Battery will charge or discharge to maintain a net-zero power balance. This is the default mode.predictive- The Plug-In Battery will automatically select betweencharge_allowed,discharge_allowed, both or neither based on the current and predicted power consumption/production of your home and the current energy prices. This mode is only functional when the P1 Meter is connected to the HomeWizard cloud.standby(legacy) - Batteries will enter standby mode. This means that the Plug-In Battery will neither charge nor discharge.to_full(legacy) - All connected Plug-In Batteries will be charged to 100%, regardless of the power consumption/production of your home. When all batteries are fully charged, the Plug-In Battery will switch to the zero mode.
The modes standby and to_full are provided for backwards compatibility reasons.
- For
standby, we recommend using thepermissionsfield to disallow both charging and discharging instead of using this mode, as it provides more flexibility and will be the only option in the future whenstandbymode is removed. - For
to_full, we recommend using thecharge_to_fullfield instead of this mode. During the deprecation period,modewill be set toto_fullwhen this field is set totrueand will be set to the previous mode when this field is set tofalseto reflect the old behavior.
Permissions
The permissions field can be used to set specific permissions for charging and discharging the connected Plug-In Batteries. The possible values are:
charge_allowed- Allow the Plug-In Battery to charge.discharge_allowed- Allow the Plug-In Battery to discharge.
Provide these via an array when updating the permissions field. For example, to allow both charging and discharging, set permissions to ["charge_allowed", "discharge_allowed"]. To disallow both, set it to an empty array [].
Backwards compatibility with standby mode
Mode standby is exactly the same as mode zero with both charging and discharging disallowed, therefore the following rules apply for backwards compatibility:
- When switching to
standbymode, thepermissionsfield will be set to an empty array[]. - When adding a permission to the
permissionsfield while instandbymode, the mode will automatically switch tozero. zeromode with both permissions allowed is the same as the defaultzeromode.zeromode with both permissions disallowed is the same asstandbymode, therefore mode will automatically switch tostandby.
Examples
Get Battery Group Information
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2"
https/1.1 200 OK
Content-Type: application/json
{
"mode": "zero",
"permissions" : ["charge_allowed", "discharge_allowed"],
"charge_to_full": false,
"battery_count": 2,
"power_w": -404,
"target_power_w": -400,
"max_consumption_w": 1600,
"max_production_w": 800
}
Change Control Mode
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-X PUT \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2" \
-d '{"mode": "to_full"}'
https/1.1 200 OK
Content-Type: application/json
{
"mode": "to_full",
"permissions" : [],
"charge_to_full": true,
"battery_count": 2,
"power_w": 1599,
"target_power_w": 1600,
"max_consumption_w": 1600,
"max_production_w": 800
}
Change permissions
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-X PUT \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2" \
-d '{"permissions": ["charge_allowed"]}'
https/1.1 200 OK
Content-Type: application/json
{
"mode": "zero",
"permissions" : ["charge_allowed"],
"charge_to_full": false,
"battery_count": 2,
"power_w": 404,
"target_power_w": 400,
"max_consumption_w": 1600,
"max_production_w": 800
}
Set battery to charge to full
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-X PUT \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2" \
-d '{"mode": "to_full"}'
# or
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-X PUT \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2" \
-d '{"charge_to_full": true}'
https/1.1 200 OK
Content-Type: application/json
{
"mode": "to_full",
"permissions" : ["charge_allowed", "discharge_allowed"],
"charge_to_full": true,
"battery_count": 2,
"power_w": 1600,
"target_power_w": 1600,
"max_consumption_w": 1600,
"max_production_w": 800
}
Change permissions and mode
You can set mode and permissions in one request. You cannot set mode to to_full and change permissions at the same time, as permissions is read-only in to_full mode.
Mode will change to standby or zero depending on the provided permissions.
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-X PUT \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2" \
-d '{"permissions": ["discharge_allowed"], "mode": "zero"}'
https/1.1 200 OK
Content-Type: application/json
{
"mode": "zero",
"permissions": ["discharge_allowed"],
"charge_to_full": false,
"battery_count": 2,
"power_w": -404,
"target_power_w": -400,
"max_consumption_w": 1600,
"max_production_w": 800
}