# Using a flow variable in the home assistant call service node

**URL:** <https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948>\
**Category:** General\
**Created:** [18 November 2021 16:04 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948 "2021-11-18T16:04:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crabsticks](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crabsticks/32/94714_2.png) [@Crabsticks](https://discourse.nodered.org/u/Crabsticks)\
**Post date:** [18 November 2021 16:04 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948/1 "2021-11-18T16:04:26Z")

</div>

Hi,

I need some help with the correct syntax to use. I am trying to set my thermostat to a value I have stored in a flow variable - the variable is called TargetHigh - I have tried using the following but get an error -

 ![Untitled](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/197418fef3d9eacab52e746906b53a33d27e8702.jpeg)

I am pretty sure I just have the syntax wrong, if I replace the word TargetHigh with a value - for example 23 the code works and the thermostat is set to 23.  
Many Thanks

---

<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:** [18 November 2021 16:12 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948/2 "2021-11-18T16:12:33Z")

</div>

Using JSONata try.  
`{"temperature": $flowContext("TargetHigh")}`

---

<div class="post-metadata">

**Author:** ![Crabsticks](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crabsticks/32/94714_2.png) [@Crabsticks](https://discourse.nodered.org/u/Crabsticks)\
**Post date:** [18 November 2021 16:13 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948/3 "2021-11-18T16:13:57Z")

</div>

> [@E1cid](#):
>
> {"temperature": $flowContext("TargetHigh")}

It gives me the following error -  
"Call-service error. must contain at least one of temperature, target\_temp\_high, target\_temp\_low."

---

<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:** [18 November 2021 16:16 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948/4 "2021-11-18T16:16:10Z")

</div>

Have you set the value 23 to flow context "TargetHigh"  
show us the context variable is set, and is in the same flow tab.

---

<div class="post-metadata">

**Author:** ![Crabsticks](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crabsticks/32/94714_2.png) [@Crabsticks](https://discourse.nodered.org/u/Crabsticks)\
**Post date:** [18 November 2021 16:20 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948/5 "2021-11-18T16:20:39Z")

</div>

Hi,

Here is a screen shot of the variable getting set, it's in the same flow - the current value is 20.4 which is shown in the debug window (I don't know how else to show you - sorry I'm quite new at this)

 ![Untitled](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1aada2a8edbc3e9ff99a1b5d9d7ffae438a579bd.jpeg)

---

<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:** [17 January 2022 16:21 UTC](https://discourse.nodered.org/t/using-a-flow-variable-in-the-home-assistant-call-service-node/53948/6 "2022-01-17T16:21:03Z")

</div>

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