# iAqualink for Pool Equipment strike again

**URL:** <https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321>\
**Category:** General\
**Created:** [31 May 2022 18:22 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321 "2022-05-31T18:22:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![VVorttexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vvorttexx/32/62463_2.png) [@VVorttexx](https://discourse.nodered.org/u/VVorttexx)\
**Post date:** [31 May 2022 18:22 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/1 "2022-05-31T18:22:17Z")

</div>

hello,  
I found a post that exactly matches my problem:

> [@iAqualink for Pool Equipment](https://discourse.nodered.org/t/iaqualink-for-pool-equipment/29689):
>
> BACKGROUND iAqualink is a service created for connecting Zodiac/Fluidra pool equipment to a cloud-based service for monitoring and control. There are apps for iOS and Android but no open-API for 3rd party control. Someone has managed to sniff the login process using a http proxy and published a number of curl commands. I'd like to create a project to do this with Node-Red but lack sufficient depth of knowledge to get it going. I can see parallels with an existing project for Miele home applia…

and even the spotify example that goes with it. But unfortunately like Tico, I'm drooling hats tried to recover the bearer token to put it in another http request... I manage to put it in a flow or global variable... but I can't never with a node function or change to reuse it in another http...  
{ "Authorization": "Bearer " +"the token from hell"}  
that works  
{ "Authorization": "Bearer " & $flowContext('iaqualink').TokenID}  
it does not work....  
for the love of code an saint axeerror. help me.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [31 May 2022 18:26 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/2 "2022-05-31T18:26:36Z")

</div>

> [@VVorttexx](#):
>
> { "Authorization": "Bearer " & $flowContext('iaqualink').TokenID}  
> it does not work....

Welcome to the forum!  
That doesn't look quite right. Have a read of [Working with context : Node-RED](https://nodered.org/docs/user-guide/context) which will help you retrieving flow context in the correct way.

---

<div class="post-metadata">

**Author:** ![VVorttexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vvorttexx/32/62463_2.png) [@VVorttexx](https://discourse.nodered.org/u/VVorttexx)\
**Post date:** [31 May 2022 19:52 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/3 "2022-05-31T19:52:04Z")

</div>

hi Paul , thks ,  
I've already gone through this doc, but to be honest I'm not into it enough to understand, I started with a few examples, like spotify , which I can't reproduce.  
I get a nice token that I put in a flow.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35341282b3564fdb635b9c0070aac96dfd56a10e.png)

it doesn't work anymore is when I try to reproduce this:  
'{  
"Authorization": "Bearer " & $flowContext('spotify').tokens.access\_token  
}'  
how to replace \<\<& $flowContext('spotify').tokens.access\_token\>\> by  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/00cb152fdd46f73b57dcc86c08cd02c3d2f994ac.png)  
that haven't no "copy path" by the way. (? [Copy path of a variable from Debug Node does not work](https://discourse.nodered.org/t/copy-path-of-a-variable-from-debug-node-does-not-work/56841))  
thks again

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [31 May 2022 20:41 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/4 "2022-05-31T20:41:56Z")

</div>

> [@VVorttexx](#):
>
> $flowContext('iaqualink').TokenID}

But you screenshot shows global.  
Try `$globalContext("TokenID")`

---

<div class="post-metadata">

**Author:** ![Tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@Tico](https://discourse.nodered.org/u/Tico)\
**Post date:** [31 May 2022 22:20 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/5 "2022-05-31T22:20:07Z")

</div>

Here's a flow that pulls info for two devices (Zodiac Chlorinator and Zodiac Heatpump) -

```auto
[{"id":"1e47a52e3f1755e1","type":"inject","z":"0ae35cdfe7f81cdd","name":"Every hour","repeat":"3540","crontab":"","once":true,"onceDelay":"60","topic":"","payload":"","payloadType":"date","x":110,"y":80,"wires":[["6808aab954fc8b01"]]},{"id":"7849f0c750568181","type":"http request","z":"0ae35cdfe7f81cdd","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":590,"y":80,"wires":[["18bf3f43ad2e6aa4"]]},{"id":"18bf3f43ad2e6aa4","type":"change","z":"0ae35cdfe7f81cdd","name":"IDToken","rules":[{"t":"move","p":"payload.userPoolOAuth.IdToken","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":80,"wires":[["ea244732498b9412"]]},{"id":"6808aab954fc8b01","type":"function","z":"0ae35cdfe7f81cdd","name":"Format Post Request","func":"msg.method = 'POST';\nmsg.headers = {};\nmsg.headers['Host'] = 'prod.zodiac-io.com';\nmsg.headers['accept'] = 'application/json';\nmsg.headers['content-type'] = 'application/json';\nmsg.headers['accept-encoding'] = 'gzip';\nmsg.headers['user-agent'] = 'okhttp/3.12.0';\nmsg.url = 'https://prod.zodiac-io.com/users/v1/login';\nmsg.payload = '{\"api_key\":\"yourapikeyhere\", \"email\":\"youremail@address.com\", \"password\":\"youriAqualinkpassword\"}';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":80,"wires":[["7849f0c750568181"]]},{"id":"ea244732498b9412","type":"function","z":"0ae35cdfe7f81cdd","name":"Set variable IDToken","func":"global.set(\"IDToken\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":80,"wires":[[]]},{"id":"dcd9bc84914a71f6","type":"http request","z":"0ae35cdfe7f81cdd","name":"Chlorinator","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":590,"y":400,"wires":[["02b59259a14e8461","b8075e9783a1eb4f","f0bb9145a81ce74a","eba07f6046f035d6","4ac01fee0ba334b1","018a8ddf5da0b1f2","9c4298d655076b55"]]},{"id":"9df6c312e595c863","type":"function","z":"0ae35cdfe7f81cdd","name":"Format Get Request","func":"let bearer = global.get(\"IDToken\");\nmsg.method = 'GET';\nmsg.headers = {};\nmsg.headers['Host'] = 'prod.zodiac-io.com';\nmsg.headers['accept'] = 'application/json';\nmsg.headers['authorization'] = bearer;\nmsg.headers['accept-encoding'] = 'gzip';\nmsg.headers['user-agent'] = 'okhttp/3.12.0';\nmsg.url = 'https://prod.zodiac-io.com/devices/v1/yourDeviceIDhere/shadow';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":400,"wires":[["dcd9bc84914a71f6"]]},{"id":"a56824124abf6deb","type":"inject","z":"0ae35cdfe7f81cdd","name":"Every 10 mins","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"600","crontab":"","once":true,"onceDelay":"300","topic":"","payloadType":"date","x":120,"y":400,"wires":[["9df6c312e595c863","295782e3c29ee112"]]},{"id":"02b59259a14e8461","type":"change","z":"0ae35cdfe7f81cdd","name":"ORP","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.sns_2.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":320,"wires":[[]]},{"id":"b8075e9783a1eb4f","type":"change","z":"0ae35cdfe7f81cdd","name":"pH","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.sns_1.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":160,"wires":[["0e3f2e3e62511c3a"]]},{"id":"f0bb9145a81ce74a","type":"change","z":"0ae35cdfe7f81cdd","name":"Filter Temp","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.sns_3.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":480,"wires":[[]]},{"id":"0e3f2e3e62511c3a","type":"range","z":"0ae35cdfe7f81cdd","minin":"0","maxin":"10","minout":"0","maxout":"1","action":"scale","round":false,"property":"payload","name":"Divide by 10","x":1030,"y":160,"wires":[[]]},{"id":"eba07f6046f035d6","type":"change","z":"0ae35cdfe7f81cdd","name":"ORP Setpoint","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.orp_sp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":400,"wires":[[]]},{"id":"4ac01fee0ba334b1","type":"change","z":"0ae35cdfe7f81cdd","name":"pH Setpoint","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.ph_sp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":240,"wires":[["874e523fa6c7da37"]]},{"id":"874e523fa6c7da37","type":"range","z":"0ae35cdfe7f81cdd","minin":"0","maxin":"10","minout":"0","maxout":"1","action":"scale","round":false,"property":"payload","name":"Divide by 10","x":1030,"y":240,"wires":[[]]},{"id":"018a8ddf5da0b1f2","type":"change","z":"0ae35cdfe7f81cdd","name":"Zodiac Error Code","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.error_code","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":560,"wires":[[]]},{"id":"e64f08a15e168247","type":"function","z":"0ae35cdfe7f81cdd","name":"Format Get Request","func":"let bearer = global.get(\"IDToken\");\nmsg.method = 'GET';\nmsg.headers = {};\nmsg.headers['Host'] = 'prod.zodiac-io.com';\nmsg.headers['accept'] = 'application/json';\nmsg.headers['authorization'] = bearer;\nmsg.headers['accept-encoding'] = 'gzip';\nmsg.headers['user-agent'] = 'okhttp/3.12.0';\nmsg.url = 'https://prod.zodiac-io.com/devices/v1/yourDeviceIDhere/shadow';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":720,"wires":[["c6ca1d3e24bfb92e"]]},{"id":"c6ca1d3e24bfb92e","type":"http request","z":"0ae35cdfe7f81cdd","name":"Heat Pump","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":590,"y":720,"wires":[["8b1cfc1cd0be14da","3c3f9237065a8ad6","5c21887674341499","98851fd84020e5da","5df5ed4f4d40d4ef"]]},{"id":"295782e3c29ee112","type":"delay","z":"0ae35cdfe7f81cdd","name":"5 mins","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":230,"y":560,"wires":[["e64f08a15e168247"]]},{"id":"8b1cfc1cd0be14da","type":"change","z":"0ae35cdfe7f81cdd","name":"Heat Pump Setpoint","rules":[{"t":"move","p":"payload.state.reported.equipment.hp_0.tsp","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":720,"wires":[[]]},{"id":"5c21887674341499","type":"change","z":"0ae35cdfe7f81cdd","name":"Heap Pump Air Temp","rules":[{"t":"move","p":"payload.state.reported.equipment.hp_0.sns_2.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":880,"wires":[[]]},{"id":"3c3f9237065a8ad6","type":"change","z":"0ae35cdfe7f81cdd","name":"Heap Pump Water Temp","rules":[{"t":"move","p":"payload.state.reported.equipment.hp_0.sns_1.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":800,"wires":[[]]},{"id":"17a5e515d5f4c27f","type":"inject","z":"0ae35cdfe7f81cdd","name":"Test only","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":100,"y":720,"wires":[["e64f08a15e168247"]]},{"id":"98851fd84020e5da","type":"change","z":"0ae35cdfe7f81cdd","name":"Heat Pump Status","rules":[{"t":"move","p":"payload.state.reported.equipment.hp_0.status","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":960,"wires":[[]]},{"id":"5df5ed4f4d40d4ef","type":"change","z":"0ae35cdfe7f81cdd","name":"Heat Pump Reason","rules":[{"t":"move","p":"payload.state.reported.equipment.hp_0.reason","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":1040,"wires":[[]]},{"id":"9c4298d655076b55","type":"change","z":"0ae35cdfe7f81cdd","name":"Low Setting","rules":[{"t":"move","p":"payload.state.reported.equipment.swc_0.low","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":640,"wires":[[]]}]

```

Note that in the Function node (Format Post Request) preceeding the first HTTP Request , you will require three bits of info -

API Key (generic for all users) - EOOEMOW4YR6QNB11  
Email  
Password

In the Function node (Format Get Request) preceeding the Device, you will need 'yourDeviceIDhere' where specified. It's the serial number of the device and looks something like -

JT19000123  
or  
JX19100123

The post you originally linked to has the curl commands necessary to pull the DeviceID. They might also be physically printed on the device somewhere but I haven't looked.

---

<div class="post-metadata">

**Author:** ![VVorttexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vvorttexx/32/62463_2.png) [@VVorttexx](https://discourse.nodered.org/u/VVorttexx)\
**Post date:** [1 June 2022 07:26 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/6 "2022-06-01T07:26:59Z")

</div>

hi Guys,  
thks a lot  
@ [E1cid](https://discourse.nodered.org/u/E1cid)  
yes i try an other way in the meantime, but is consistent  
@Tico  
hey, I was hoping that you had finalized on your side, iwill try your solution  
I have no problem recovering the token and getting the info from the chlorinator, but doing it automatically...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf9d6bc318269dd02f2899f20e70139db84bcc66.png)  
(and sorry..yes...i'm french.)

---

<div class="post-metadata">

**Author:** ![VVorttexx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vvorttexx/32/62463_2.png) [@VVorttexx](https://discourse.nodered.org/u/VVorttexx)\
**Post date:** [1 June 2022 08:21 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/7 "2022-06-01T08:21:29Z")

</div>

you make my day...my week..and after.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fdfef728c77f8a5123ff9b14524163a5d1aebb9f.jpeg)  
thks a lot everybody.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 June 2022 14:58 UTC](https://discourse.nodered.org/t/iaqualink-for-pool-equipment-strike-again/63321/9 "2022-06-23T14:58:57Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
