# Conversion Fahrenheit to Celsius - Radio thermostat set temperature

**URL:** <https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678>\
**Category:** General\
**Created:** [28 December 2019 12:40 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678 "2019-12-28T12:40:23Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [28 December 2019 12:40 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/1 "2019-12-28T12:40:23Z")

</div>

Hello!

I have a radio thermostat CT80. Its curl commands work in Fahrenheit but I want to input Celsius via a chat bot to set the temp.  
Anyone know the process for doing this?

I think the input will need a template node to convert C to F....  
Then the converted F result will be sent to the curl command.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [28 December 2019 13:39 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/2 "2019-12-28T13:39:22Z")

</div>

Hi, have you actually tried it yet? Conversions from c to f, and f to c for that matter, follow simple formulas. You can use just about any node you like for that, from a function node to a change node (`payload.temp_celsius * 1.8 + 32` as JSONata expression for example). You said you use curl for communication, so that means you can use the exec node with a curl command, or the http request node if you use an http protocol within curl.

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [28 December 2019 13:59 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/3 "2019-12-28T13:59:57Z")

</div>

I've used a node flow from someone else for the ct80.  
All I need to do is inject the F in numerical value into a node.  
So whatever does the conversion needs to output a number ie: 72  
Will have a play later!  
Thank you 👌

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 December 2019 14:09 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/4 "2019-12-28T14:09:48Z")

</div>

Or use the range mode to rescale the numbers appropriately

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [28 December 2019 14:22 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/5 "2019-12-28T14:22:01Z")

</div>

Ooh, one I wouldn’t have thought of. Thanks Dave for reminding that it exists 🙂

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [28 December 2019 15:03 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/6 "2019-12-28T15:03:37Z")

</div>

> [@Mobile\_NR\_Env](#):
>
> to convert C to F....

You can also try to use my [node-red-contrib-unit-converter](https://github.com/bartbutenaers/node-red-contrib-unit-converter), which supports a.o. following temperature conversions:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/271e3ca65b2dc5122dc01f3c93793324cd9f91dc.png)

Good luck!  
Bart

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [29 December 2019 00:01 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/7 "2019-12-29T00:01:24Z")

</div>

Worked a treat! Thank you

Now all i need to do is work out how to trigger the temperature till a certain time via chat bot..

Loving node red 😀

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [4 January 2020 23:03 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/8 "2020-01-04T23:03:00Z")

</div>

I'm looking at implementing your method too. I've injected a number (19) in via a payload string.  
Have used a function node with:

```auto
payload.temp_celsius * 1.8 + 32;
return msg;

```

Getting error:

"ReferenceError: payload is not defined (line 1, col 1)"

On the debug node....

I'm really green with this atm. Any tips would be useful!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 January 2020 23:08 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/9 "2020-01-04T23:08:08Z")

</div>

Try adding ‘msg.’ before payload

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [4 January 2020 23:17 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/10 "2020-01-04T23:17:37Z")

</div>

> [@zenofmud](#):
>
> adding ‘msg.’ before payload

Close, but that won't fix it yet:

```auto
msg.payload = msg.payload.temp_celsius * 1.8 + 32;
return msg;

```

Or if you want to keep the original:

```auto
msg.payload.temp_fahrenheit = msg.payload.temp_celcius * 1.8 + 32;
return msg;

```

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [4 January 2020 23:27 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/11 "2020-01-04T23:27:08Z")

</div>

Test flow:

 ![Screenshot 2020-01-04 at 23.23.56](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/069f3d9f49d3329fc63f4503fe0fa6a9ddd8af1e.png)

Have tried the first one:

```auto
msg.payload = msg.payload.temp_celsius * 1.8 + 32;
return msg;

```

Got this in debug:  
 ![Screenshot 2020-01-04 at 23.25.39](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/65acc285656ab0f8f75e1ea7df01a12072c0abd1.png)

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [4 January 2020 23:48 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/12 "2020-01-04T23:48:30Z")

</div>

I may have (wrongly) assumed [Working with Messages](https://nodered.org/docs/user-guide/messages) was known information. What you are inserting as payload appears to be a numeric `19` value. In that case the contents of `msg.payload` in the function node becomes simply `19` and the description changes to `msg.payload = msg.payload * 1.8 + 32;`

---

<div class="post-metadata">

**Author:** ![Mobile\_NR\_Env](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@Mobile\_NR\_Env](https://discourse.nodered.org/u/Mobile_NR_Env)\
**Post date:** [4 January 2020 23:52 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/13 "2020-01-04T23:52:42Z")

</div>

That worked!

Will look at [Working With Messages](https://nodered.org/docs/user-guide/messages)

Thanks Afelix 👌

---

<div class="post-metadata">

**Author:** ![mrdvt92](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdvt92/32/33122_2.png) [@mrdvt92](https://discourse.nodered.org/u/mrdvt92)\
**Post date:** [14 June 2022 16:35 UTC](https://discourse.nodered.org/t/conversion-fahrenheit-to-celsius-radio-thermostat-set-temperature/19678/14 "2022-06-14T16:35:40Z")

</div>

The modern way to convert C to F or F to C is to use a range node.

C to F

-40 100  
-40 212

F to C

-40 212  
-40 100

```auto
[{"id":"b39e3a0a.9b8048","type":"range","z":"205d0e6a.aaefc2","minin":"-40","maxin":"100","minout":"-40","maxout":"212","action":"scale","round":false,"property":"payload","name":"C to F","x":730,"y":1100,"wires":[["6ea851ef.91e08"]]}]

```
