flowContext does not work

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.

[{"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}]

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

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

image

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

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

[{"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:27node: SollPosSchlafenmsg :

object

domain: "cover"

service: "set_cover_position"

data: object

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

entity_id: "cover.rollo_schlafzimmer"

21.2.2022, 19:56:27node: SollPosSchlafenmsg : string[72]

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

Any further ideas or help?? Thank you - JJ

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

[{"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.

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

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