HomeWizard API
website·Indexed 35 days ago
https://api-documentation.homewizard.comLocal network API for HomeWizard energy devices, including the P1 Meter (HWE-P1), Energy Sockets (HWE-SKT), 1-Phase and 3-Phase kWh Meters (HWE-KWH1, HWE-KWH3, SDM230-wifi, SDM630-wifi), and Plug-In Batteries (HWE-BAT). Documentation covers v1 and v2 versions, featuring measurement data, system actions, WebSocket communication, device discovery via mDNS, and authorization.
What's inside HomeWizard
- HomeWizard devices (P1 Meter, Energy Socket, kWh Meter, Watermeter, and Plug-In Battery) provide a local API to retrieve real-time measurements or control the device. To use the local API, the client must be connected to the same Wi-Fi network as the device. Note that historical data cannot be retrieved via the local API as it is not stored on the device.
Authorize API requests with a Bearer token
v2The HomeWizard API requires a Bearer token for authorization. This token must be included in theAuthorizationheader of every request. If the token is missing or invalid, the API returns a401 Unauthorizedresponse with the erroruser:unauthorized.curl https://<IP ADDRESS>/api --insecure \ -H "Authorization: Bearer <TOKEN>" \ -H "X-Api-Version: 2"Understand HomeWizard API versioning and backward compatibility
The HomeWizard API follows semantic versioning (
MAJOR.MINOR.PATCH).MAJORupdates indicate incompatible API changes.MINORupdates add backward-compatible features.PATCHupdates provide backward-compatible bug fixes.
To maintain backward compatibility, when a breaking change occurs, the
MAJORversion increases, but the previous version remains accessible for a period of time.Access the HomeWizard API locally
The HomeWizard API is available on your local network, allowing it to be used without an active internet connection. Users have the option to disable the cloud connection entirely via the system settings.Unsubscribe from a WebSocket topic
v2To stop receiving real-time updates for a specific topic, send anunsubscribemessage with the topic name in thedatafield.{ "type": "unsubscribe", "data": "system" }Toggle HomeWizard cloud communication
v1Use the
/api/v1/systemendpoint to enable or disable all communication between the HomeWizard device and the HomeWizard cloud.Important Considerations:
- When
cloud_enabledis set tofalse, the device becomes fully local. It will no longer communicate with the HomeWizard app and will not receive firmware updates. - Cloud communication is restored by setting
cloud_enabledtotrue, performing a factory reset, or putting the device into pairing mode. - Because this action disables app functionality and updates, it is recommended to provide clear documentation or a confirmation popup to the end-user before triggering this change.
Supported Devices:
- P1 Meter
- Energy Socket
- kWh Meter
- Watermeter
- Plug-In Battery (v2)
- Note: Energy Display is not supported.
- When
Trigger the device LED to blink (Identify)
v2To visually identify a device, send theidentifycommand. This causes the device LED to blink for a few seconds.{ "type": "identify" }Handle HomeWizard API errors
v1When making requests to the HomeWizard API, always verify that the HTTP status code is200 OKbefore parsing the response. If a request is invalid or an error occurs, the API returns a non-200 status code and a JSON object containing anerrorobject with a numericidand a stringdescription.Create a local user and obtain an authorization token
v2To obtain an authorization token, you must create a user on the device via a
POST /api/userrequest. This process requires physical interaction with the device to prove possession.Pairing Flow:
- Send a
POST /api/userrequest with the desired user name. - The device will initially respond with
403 Forbidden(user:creation-not-enabled). - The user must physically press the button on the device.
- Note for kWh Meter: The wifi-pair button must be pressed for 1 to 3 seconds.
- While waiting for the button press, the app can continue sending the
POSTrequest to reset the timer. - Once the button is pressed, the next request within a 30-second window will return a
200 OKresponse containing the token.
Request Parameters:
name(String): Must be prefixed withlocal/. Length: 1-40 characters. Allowed characters:a-z,A-Z,0-9,-,_,\,/,#, and spaces. (Regex:^local\[a-zA-Z0-9\-\_/\\# \]{1,40}$).
Response Fields:
name(String): The user name prefixed withlocal/.token(String): A 32-character alphanumeric token (A-F, 0-9).
# Step 1 & 2: Request token (repeat until button is pressed) curl https://<IP ADDRESS>/api/user --insecure \ -X POST \ -H "Content-Type: application/json" \ -H "X-Api-Version: 2" \ -d '{"name": "local/new_user"}'- Send a
Generate an authorization token for HomeWizard API v2
The v2 API requires a secret token for access. To generate one:
- Identify the device's IP address.
- Send a POST request to the
/api/userendpoint. The first attempt will return{"error":"user:creation-not-enabled"}. - Physically press the button on the HomeWizard device once to authorize the request.
- Send the same POST request again to receive the token.
curl https://<IP ADDRESS>/api/user --insecure -X POST -d '{"name": "local/cool-new-app"}'Adjust status LED brightness
v2The status LED brightness can be adjusted between 0% and 100% using thestatus_led_brightness_pctparameter. This setting only affects the LED during normal operation; error indications always use default brightness.curl https://<IP ADDRESS>/api/system --insecure \ -X PUT \ -H "Authorization: Bearer <TOKEN>" \ -H "X-Api-Version: 2" \ -d '{"status_led_brightness_pct": 50}'Discover HomeWizard devices using mDNS
HomeWizard energy devices can be automatically discovered on a local network using Multicast DNS (mDNS), also known as Zeroconf or Bonjour. This allows applications to find devices without knowing their IP addresses. Depending on the API version supported by the device, it will broadcast one or both of the following services:
_hwenergy._tcp: Used for devices supporting API v1 (HTTP, port 80)._homewizard._tcp: Used for devices supporting API v2 and later (HTTPS, port 443).