Homewizard P1 Meter - new_user token API V2

Hi All,

I recently got the Homewizard P1 Meter.
Their documentation describes how to request a new user token, but i can not get it to work.

I have my http post setup as:

And this gives me:

[{"id":"a6d766c733eddc04","type":"inject","z":"245407e94549f047","name":"Inject","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":220,"wires":[["b3332b0da77eccfb"]]},{"id":"b3332b0da77eccfb","type":"http request","z":"245407e94549f047","name":"Post API Request","method":"POST","ret":"obj","paytoqs":"body","url":"https://192.168.86.32/api/user","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"other","keyValue":"X-Api-Version","valueType":"other","valueValue":"2"},{"keyType":"other","keyValue":"name","valueType":"other","valueValue":"local/new_user"}],"x":470,"y":220,"wires":[["f1b847fc3f80a29e"]]},{"id":"f1b847fc3f80a29e","type":"debug","z":"245407e94549f047","name":"Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":680,"y":220,"wires":[]}]

What am i doing wrong?

Have you physically pressed the button on the device

  1. The user opens your app which initiates a network scan, discovering a device, such as a P1 Meter.
  2. After selecting the P1 Meter, the app sends a POST /api/user request with the necessary parameters
  3. The device responds with a 403 Forbidden status, indicating that the user must physically press the button on the device to continue.

Even if i press the button, I still get the same error.

All I can think is the new_user section of the name may need to be a username.

looking again the name needs to be in the payload not the header

[{"id":"b3332b0da77eccfb","type":"http request","z":"d1395164b4eec73e","name":"Post API Request","method":"POST","ret":"obj","paytoqs":"body","url":"https://192.168.86.32/api/user","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"other","keyValue":"X-Api-Version","valueType":"other","valueValue":"2"}],"x":530,"y":6660,"wires":[["f1b847fc3f80a29e"]]},{"id":"a6d766c733eddc04","type":"inject","z":"d1395164b4eec73e","name":"Inject","props":[{"p":"payload,name","v":"local/new_user","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":6660,"wires":[["b3332b0da77eccfb"]]},{"id":"f1b847fc3f80a29e","type":"debug","z":"d1395164b4eec73e","name":"Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":6660,"wires":[]}]

From the node-red system can you ping 192.168.86.32 ?

On the website the curl example is

curl https://<IP ADDRESS>/api/user --insecure \ 
-X POST \
-H "Content-Type: application/json" \  
-H "X-Api-Version: 2" \  -d '{"name": "local/new_user"}'

it has the --insecure flag which is to connect to server that has self signed certificates ?
In Node-red you can try to set from your Inject node msg.rejectUnauthorized to false

image

1 Like