# flowContext does not work

**URL:** <https://discourse.nodered.org/t/flowcontext-does-not-work/58703>\
**Category:** General\
**Created:** [20 February 2022 16:57 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703 "2022-02-20T16:57:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [20 February 2022 16:57 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/1 "2022-02-20T16:57:13Z")

</div>

Hi there  
I have some troubles with flowContext in below flow. The local variable SollPosSchlafen is properly set as an integer? Is there a way to check the type of the variable??  
On the other hand, the coser\_set\_pos does not work, allways get an error, that the value  
"position" is " ". Any help on this ?? Thank you.

```auto
[{"id":"7371101dc880a49f","type":"inject","z":"b922c92e.707c28","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":811.5555057525635,"y":1557.7778272628784,"wires":[["c9a3e353ae50b1ad"]]},{"id":"dd7d326adb53e9ec","type":"debug","z":"b922c92e.707c28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1199.6825199127197,"y":1557.714319229126,"wires":[]},{"id":"c9a3e353ae50b1ad","type":"api-call-service","z":"b922c92e.707c28","name":"SollPosSchlafen","server":"a11aa034.815b8","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.rollo_schlafzimmer"],"data":"{ \"position\": \"{{$flowContext(\"SollPosSchlafen\")}} \" }","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":999.3333282470703,"y":1557.3333072662354,"wires":[["dd7d326adb53e9ec"]]},{"id":"a11aa034.815b8","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

```

---

<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:** [20 February 2022 17:45 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/2 "2022-02-20T17:45:29Z")

</div>

You specified data type as json in the HA node. You need to specify JSONata as json does not accept expressions.

---

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [21 February 2022 06:43 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/3 "2022-02-21T06:43:56Z")

</div>

Thank you.  
You mean I only have to change to JSONata instead of JSON, anything else to change?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/7502d4c7c08b4c737cbd7ad20065d7b25dce36c8.png)

---

<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:** [21 February 2022 07:29 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/4 "2022-02-21T07:29:54Z")

</div>

Yes you do not need {{ }} around the $flowContext("blahblah") expresssion

---

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [21 February 2022 18:59 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/5 "2022-02-21T18:59:24Z")

</div>

Tried nearly everything but could not made this working.  
My last attempt was:

```auto
[{"id":"7371101dc880a49f","type":"inject","z":"b922c92e.707c28","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":811.5555057525635,"y":1557.7778272628784,"wires":[["c9a3e353ae50b1ad"]]},{"id":"dd7d326adb53e9ec","type":"debug","z":"b922c92e.707c28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1199.6825199127197,"y":1557.714319229126,"wires":[]},{"id":"c9a3e353ae50b1ad","type":"api-call-service","z":"b922c92e.707c28","name":"SollPosSchlafen","server":"a11aa034.815b8","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.rollo_schlafzimmer"],"data":"{ \"position\": \"{{$flowContext('SollPosSchlafen')}}\" }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":999.3333282470703,"y":1557.3333072662354,"wires":[["dd7d326adb53e9ec"]]},{"id":"a11aa034.815b8","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

```

which gaves me following error:  
21.2.2022, 19:56:27[node: SollPosSchlafen](http://homeassistant:8123/api/hassio_ingress/ecOh_dhrZm_0AuxQZkS6UtShWXM_-9hLrXhtedO1D1U/#)msg :

object

domain: "cover"

service: "set\_cover\_position"

data: object

position: "{{$flowContext('SollPosSchlafen')}}"

entity\_id: "cover.rollo\_schlafzimmer"

21.2.2022, 19:56:27[node: SollPosSchlafen](http://homeassistant:8123/api/hassio_ingress/ecOh_dhrZm_0AuxQZkS6UtShWXM_-9hLrXhtedO1D1U/#)msg : string[72]

"Call-service error. expected int for dictionary value @ data['position']"

Any further ideas or help?? Thank you - JJ

---

<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:** [21 February 2022 19:10 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/6 "2022-02-21T19:10:25Z")

</div>

You did not follow my last post, I said you need to remove the {{ }} from around the flowContex().  
e.g.

```auto
[{"id":"7371101dc880a49f","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":1660,"wires":[["c9a3e353ae50b1ad"]]},{"id":"c9a3e353ae50b1ad","type":"api-call-service","z":"bf9e1e33.030598","name":"SollPosSchlafen","server":"a11aa034.815b8","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.rollo_schlafzimmer"],"data":"{ \"position\": $flowContext('SollPosSchlafen') }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":410,"y":1620,"wires":[["dd7d326adb53e9ec"]]},{"id":"dd7d326adb53e9ec","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":618.1270141601562,"y":1659.9364919662476,"wires":[]}]

```

and the quotes are not require either.

---

<div class="post-metadata">

**Author:** ![JJdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jjdave/32/39111_2.png) [@JJdave](https://discourse.nodered.org/u/JJdave)\
**Post date:** [21 February 2022 19:20 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/7 "2022-02-21T19:20:22Z")

</div>

Thanks - I was over reading the "not" in your first post - thanks a lot, it'n no working!!! JJ

---

<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:** [22 April 2022 19:21 UTC](https://discourse.nodered.org/t/flowcontext-does-not-work/58703/8 "2022-04-22T19:21:03Z")

</div>

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