# Removal of extensions in strings and converting to number for a two-point control

**URL:** <https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196>\
**Category:** Developing Nodes\
**Created:** [14 October 2021 07:09 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196 "2021-10-14T07:09:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [14 October 2021 07:09 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/1 "2021-10-14T07:09:40Z")

</div>

Removing extensions in strings and converting to number for a twoGood morning for days I've been trying the following: I have a target and actual temperature from OpenHab. I would like to subtract these from each other using a function and if the difference is greater than zero, it must be heated. Can someone help me there or is there another way.

in the meantime I've got the temperatures in the variables. Now I want to calculate the difference. Since the variables are strings with a unit, I try to get rid of the unit and convert the whole thing into numbers. Can someone give me a tip on this?

I am completely clueless.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 October 2021 08:16 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/2 "2021-10-14T08:16:50Z")

</div>

There are various ways in Node-RED to be able to do this depending on what else you are trying to do.

JavaScript is often quite forgiving of text to number conversions on the fly so using just a change node to replace the unit text with an empty string may be all you need. More can be done with JSONata also in a change node or you could use a function node with plain JavaScript if you need to do more complex processing.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [14 October 2021 08:29 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/3 "2021-10-14T08:29:52Z")

</div>

You can use `parseFloat(msg.myInputFloatingNumber)` or `parseInt(msg.myInputInteger)` in a function node.  
These `parse` functions will convert them to numbers if they are strings that start with numbers.

eg

 ![Screenshot 2021-10-14 at 10.32.25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21826238590965a811ec93a8beccbf6f4c342595.jpeg)

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [14 October 2021 08:42 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/4 "2021-10-14T08:42:47Z")

</div>

Can you give me an example of such a script? I have a flow variable that includes the following value: 23.5 ° C and the ° C has to go. and then it has to be processed further as a number. I would like to have a true or false at the end if the difference between the two temperatures is greater or less than zero for the other variant.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 October 2021 08:55 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/5 "2021-10-14T08:55:43Z")

</div>

This is an example of doing it without a function node. But often, it is easier to use a function node:

```auto
[{"id":"4fb7c47673f019ee","type":"inject","z":"3ffe8f3084d4d0bd","name":"","props":[{"p":"payload"},{"p":"compare","v":"25.0","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"23.5 ° C","payloadType":"str","x":310,"y":440,"wires":[["041a671156770a05"]]},{"id":"041a671156770a05","type":"change","z":"3ffe8f3084d4d0bd","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":" ° C","fromt":"str","to":"","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"compare - $number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":440,"wires":[["049e803ae9f7163a"]]},{"id":"049e803ae9f7163a","type":"debug","z":"3ffe8f3084d4d0bd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":440,"wires":[]}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7b7f52c05ac567ebd0d9fea1159e5419e821ccf6.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75f015a7432567a25923814e12daa11debd24018.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:** [14 October 2021 09:01 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/6 "2021-10-14T09:01:59Z")

</div>

And here is how to remove ° c and convert to number, then return a boolean if the subtraction is greater than 0

```auto
[{"id":"f0f4c69.855abb8","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"temp1","v":" 23.5 ° C","vt":"str"},{"p":"temp2","v":" 20 ° C","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":200,"y":4820,"wires":[["3127aea.44ee2d2"]]},{"id":"3127aea.44ee2d2","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number($trim($split(temp1,\"°\")[0])) - $number($trim($split(temp2, \"°\")[0])) > 0\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":4820,"wires":[["a22d044f.37e61"]]},{"id":"a22d044f.37e61","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":713.0000152587891,"y":4714,"wires":[]}]

```

The JSONata expression

```auto
$number($trim($split(temp1,"°")[0])) - $number($trim($split(temp2, "°")[0])) > 0

```

This will return true or false  
[edit]  
and here is the similar using a function node.

```auto
msg.payload = parseFloat(msg.temp1) - parseFloat(msg.temp2) > 0
return msg;

```

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [15 October 2021 04:54 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/7 "2021-10-15T04:54:23Z")

</div>

Could you Explain me, the nummer is 1.5 and not 23.5 why?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 October 2021 05:32 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/8 "2021-10-15T05:32:40Z")

</div>

Import the flow he posted and doubleclick the inject node and then check the change node.

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [15 October 2021 06:11 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/9 "2021-10-15T06:11:15Z")

</div>

There is my program an it doesn´t run

```auto
[
    {
        "id": "70025a83831da9ae",
        "type": "tab",
        "label": "Flow 7",
        "disabled": false,
        "info": ""
    },
    {
        "id": "c369be09dd2d8550",
        "type": "function",
        "z": "70025a83831da9ae",
        "name": "",
        "func": "global.set(\"Ist_Temp_DZ\",msg.temp1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 365.75,
        "y": 29.75,
        "wires": [
            [
                "5f70099b9e59e469",
                "66e9b0320162a51a"
            ]
        ]
    },
    {
        "id": "5f70099b9e59e469",
        "type": "debug",
        "z": "70025a83831da9ae",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 695.75,
        "y": 29.75,
        "wires": []
    },
    {
        "id": "80cd2969d0328314",
        "type": "function",
        "z": "70025a83831da9ae",
        "name": "",
        "func": "global.set(\"Soll_Temp_DZ\",msg.temp2);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 355.75,
        "y": 109.75,
        "wires": [
            [
                "5f70099b9e59e469",
                "66e9b0320162a51a"
            ]
        ]
    },
    {
        "id": "66e9b0320162a51a",
        "type": "change",
        "z": "70025a83831da9ae",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "Ist_Temp_DZ",
                "pt": "global",
                "from": " ° C",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "Soll_Temp_DZ",
                "pt": "global",
                "from": " ° C",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number(Ist_Temp_DZ) - $number(Soll_Temp_DZ)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 735.75,
        "y": 189.75,
        "wires": [
            [
                "f278fe3fde7384b8"
            ]
        ]
    },
    {
        "id": "f278fe3fde7384b8",
        "type": "debug",
        "z": "70025a83831da9ae",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1035.75,
        "y": 189.75,
        "wires": []
    },
    {
        "id": "c9257a1d7a8e73f3",
        "type": "inject",
        "z": "70025a83831da9ae",
        "name": "soll",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "23 °C",
        "payloadType": "str",
        "x": 90,
        "y": 40,
        "wires": [
            [
                "c369be09dd2d8550"
            ]
        ]
    },
    {
        "id": "8026359969dac9d9",
        "type": "inject",
        "z": "70025a83831da9ae",
        "name": "Ist",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "21.5 °C",
        "payloadType": "str",
        "x": 90,
        "y": 100,
        "wires": [
            [
                "80cd2969d0328314"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [15 October 2021 06:17 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/11 "2021-10-15T06:17:24Z")

</div>

here my code and the picture

 ![node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/9087bbe95f16cf10b1c2b7f1cf552acff6a4ce80.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 October 2021 06:22 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/12 "2021-10-15T06:22:08Z")

</div>

In the change node, change the jsonata string:

```auto
$number($globalContext(Ist_Temp_DZ)) - $number($globalContext(Soll_Temp_DZ))

```

Messages are not aware of eachother, so if you want to make comparison from 2 different source, you either need to join the messages into 1 message (join node), but as you are using the global variables, you can access them both.

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [15 October 2021 11:30 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/13 "2021-10-15T11:30:08Z")

</div>

it does´t run

 ![Unbenannt](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bdf6e9f2d7c8eaa758813c558a6bc5513ea8ffa0.png)

```auto
[
    {
        "id": "b2964c3aa7426115",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": ""
    },
    {
        "id": "110f04cc138a0e07",
        "type": "openhab2-in",
        "z": "b2964c3aa7426115",
        "name": "Ist_Temp",
        "controller": "2341e6d1c1f117f5",
        "itemname": "ThermostatDurchgangszimmer_ActualTemperature",
        "x": 230,
        "y": 160,
        "wires": [
            [
                "54236c96a417792b"
            ],
            []
        ]
    },
    {
        "id": "b1147b809f6e4e95",
        "type": "openhab2-in",
        "z": "b2964c3aa7426115",
        "name": "Soll_Temp",
        "controller": "2341e6d1c1f117f5",
        "itemname": "ThermostatDurchgangszimmer_SetTemperature",
        "x": 240,
        "y": 240,
        "wires": [
            [
                "afcc40e1aa707e49"
            ],
            []
        ]
    },
    {
        "id": "54236c96a417792b",
        "type": "function",
        "z": "b2964c3aa7426115",
        "name": "",
        "func": "global.set(\"Ist_Temp_DZ\",msg.temp1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 160,
        "wires": [
            [
                "52824f7e12ac7a94",
                "29bce0cc076928f8"
            ]
        ]
    },
    {
        "id": "52824f7e12ac7a94",
        "type": "debug",
        "z": "b2964c3aa7426115",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 160,
        "wires": []
    },
    {
        "id": "afcc40e1aa707e49",
        "type": "function",
        "z": "b2964c3aa7426115",
        "name": "",
        "func": "global.set(\"Soll_Temp_DZ\",msg.temp2);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 240,
        "wires": [
            [
                "52824f7e12ac7a94",
                "29bce0cc076928f8"
            ]
        ]
    },
    {
        "id": "29bce0cc076928f8",
        "type": "change",
        "z": "b2964c3aa7426115",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "Ist_Temp_DZ",
                "pt": "global",
                "from": " °C",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "Soll_Temp_DZ",
                "pt": "global",
                "from": " °C",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number($globalContext(Ist_Temp_DZ)) - $number($globalContext(Soll_Temp_DZ))",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 850,
        "y": 320,
        "wires": [
            [
                "40d8a5b513354c8d"
            ]
        ]
    },
    {
        "id": "40d8a5b513354c8d",
        "type": "debug",
        "z": "b2964c3aa7426115",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1170,
        "y": 320,
        "wires": []
    },
    {
        "id": "2341e6d1c1f117f5",
        "type": "openhab2-controller",
        "name": "Ziegler",
        "protocol": "http",
        "host": "192.168.178.40",
        "port": "8080",
        "path": "",
        "username": "oh.NODERED.uPzMpvN5MI0C7cRpW9uNkqwWxx3XetWukNOAwEuYuvyd0CyiEj3oraUSQpqun8C0Bn2zUgXtZQs7AQ5ntky5pQ",
        "password": ""
    }
][
    {
        "id": "b2964c3aa7426115",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": ""
    },
    {
        "id": "110f04cc138a0e07",
        "type": "openhab2-in",
        "z": "b2964c3aa7426115",
        "name": "Ist_Temp",
        "controller": "2341e6d1c1f117f5",
        "itemname": "ThermostatDurchgangszimmer_ActualTemperature",
        "x": 230,
        "y": 160,
        "wires": [
            [
                "54236c96a417792b"
            ],
            []
        ]
    },
    {
        "id": "b1147b809f6e4e95",
        "type": "openhab2-in",
        "z": "b2964c3aa7426115",
        "name": "Soll_Temp",
        "controller": "2341e6d1c1f117f5",
        "itemname": "ThermostatDurchgangszimmer_SetTemperature",
        "x": 240,
        "y": 240,
        "wires": [
            [
                "afcc40e1aa707e49"
            ],
            []
        ]
    },
    {
        "id": "54236c96a417792b",
        "type": "function",
        "z": "b2964c3aa7426115",
        "name": "",
        "func": "global.set(\"Ist_Temp_DZ\",msg.temp1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 160,
        "wires": [
            [
                "52824f7e12ac7a94",
                "29bce0cc076928f8"
            ]
        ]
    },
    {
        "id": "52824f7e12ac7a94",
        "type": "debug",
        "z": "b2964c3aa7426115",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 160,
        "wires": []
    },
    {
        "id": "afcc40e1aa707e49",
        "type": "function",
        "z": "b2964c3aa7426115",
        "name": "",
        "func": "global.set(\"Soll_Temp_DZ\",msg.temp2);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 240,
        "wires": [
            [
                "52824f7e12ac7a94",
                "29bce0cc076928f8"
            ]
        ]
    },
    {
        "id": "29bce0cc076928f8",
        "type": "change",
        "z": "b2964c3aa7426115",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "Ist_Temp_DZ",
                "pt": "global",
                "from": " °C",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "Soll_Temp_DZ",
                "pt": "global",
                "from": " °C",
                "fromt": "str",
                "to": "",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number($globalContext(Ist_Temp_DZ)) - $number($globalContext(Soll_Temp_DZ))",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 850,
        "y": 320,
        "wires": [
            [
                "40d8a5b513354c8d"
            ]
        ]
    },
    {
        "id": "40d8a5b513354c8d",
        "type": "debug",
        "z": "b2964c3aa7426115",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1170,
        "y": 320,
        "wires": []
    },
    {
        "id": "2341e6d1c1f117f5",
        "type": "openhab2-controller",
        "name": "Ziegler",
        "protocol": "http",
        "host": "192.168.178.40",
        "port": "8080",
        "path": "",
        "username": "oh.NODERED.uPzMpvN5MI0C7cRpW9uNkqwWxx3XetWukNOAwEuYuvyd0CyiEj3oraUSQpqun8C0Bn2zUgXtZQs7AQ5ntky5pQ",
        "password": ""
    }
]

```

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [16 October 2021 07:32 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/14 "2021-10-16T07:32:48Z")

</div>

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/131715e9e6931ef2d2ac867828c46ccbbf6a91d6.png)

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [16 October 2021 07:40 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/15 "2021-10-16T07:40:43Z")

</div>

Hello I test your JSONata like this, where id did the error

```auto
$number($trim($split($globalContext(Ist_Temp_DZ),"°C")[0])) - $number($trim($split($globalContext(Soll_Temp_DZ), "°C")[0])) > 0	

```

---

<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:** [16 October 2021 08:00 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/16 "2021-10-16T08:00:50Z")

</div>

```auto
$number($trim($split($globalContext("Ist_Temp_DZ"),"°C")[0])) - $number($trim($split($globalContext("Soll_Temp_DZ"), "°C")[0])) > 0

```

Ist\_Temp\_DZ and Soll\_Temp\_DZ are string references to global properties so need to be in quotes.  
If still not working please supply what the global context values are.

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [16 October 2021 16:14 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/17 "2021-10-16T16:14:17Z")

</div>

it ist sitll not workinjg....

```auto
[
    {
        "id": "b2964c3aa7426115",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": ""
    },
    {
        "id": "110f04cc138a0e07",
        "type": "openhab2-in",
        "z": "b2964c3aa7426115",
        "name": "Ist_Temp",
        "controller": "2341e6d1c1f117f5",
        "itemname": "ThermostatDurchgangszimmer_ActualTemperature",
        "x": 230,
        "y": 160,
        "wires": [
            [
                "54236c96a417792b"
            ],
            []
        ]
    },
    {
        "id": "b1147b809f6e4e95",
        "type": "openhab2-in",
        "z": "b2964c3aa7426115",
        "name": "Soll_Temp",
        "controller": "2341e6d1c1f117f5",
        "itemname": "ThermostatDurchgangszimmer_SetTemperature",
        "x": 240,
        "y": 240,
        "wires": [
            [
                "afcc40e1aa707e49"
            ],
            []
        ]
    },
    {
        "id": "54236c96a417792b",
        "type": "function",
        "z": "b2964c3aa7426115",
        "name": "",
        "func": "global.set(\"Ist_Temp_DZ\",msg.temp1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 510,
        "y": 160,
        "wires": [
            [
                "52824f7e12ac7a94",
                "ff4f2b84c8d03171"
            ]
        ]
    },
    {
        "id": "52824f7e12ac7a94",
        "type": "debug",
        "z": "b2964c3aa7426115",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 160,
        "wires": []
    },
    {
        "id": "afcc40e1aa707e49",
        "type": "function",
        "z": "b2964c3aa7426115",
        "name": "",
        "func": "global.set(\"Soll_Temp_DZ\",msg.temp2);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 240,
        "wires": [
            [
                "52824f7e12ac7a94",
                "ff4f2b84c8d03171"
            ]
        ]
    },
    {
        "id": "40d8a5b513354c8d",
        "type": "debug",
        "z": "b2964c3aa7426115",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1130,
        "y": 320,
        "wires": []
    },
    {
        "id": "ff4f2b84c8d03171",
        "type": "change",
        "z": "b2964c3aa7426115",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$number($trim($split($globalContext(\"Ist_Temp_DZ\"),\"°C\")[0])) - $number($trim($split($globalContext(\"Soll_Temp_DZ\"), \"°C\")[0])) > 0",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 750,
        "y": 280,
        "wires": [
            [
                "40d8a5b513354c8d"
            ]
        ]
    },
    {
        "id": "2341e6d1c1f117f5",
        "type": "openhab2-controller",
        "name": "Ziegler",
        "protocol": "http",
        "host": "192.168.178.40",
        "port": "8080",
        "path": "",
        "username": "oh.NODERED.uPzMpvN5MI0C7cRpW9uNkqwWxx3XetWukNOAwEuYuvyd0CyiEj3oraUSQpqun8C0Bn2zUgXtZQs7AQ5ntky5pQ",
        "password": ""
    }
]

```

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f65cb6922b6cd0971417a954eeca99f31b18a0b0.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:** [16 October 2021 16:37 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/18 "2021-10-16T16:37:54Z")

</div>

your functions are referencing msg.temp1 etc, they needed to reference the incoming payload from the openhab2 in nodes.

But why not just join the messages as below, replace injects with openhub2 nodes

```auto
[{"id":"f62322f0.ae0c38","type":"inject","z":"b2964c3aa7426115","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"23 °C","payloadType":"str","x":240,"y":160,"wires":[["742592b4.5eed0c"]]},{"id":"742592b4.5eed0c","type":"change","z":"b2964c3aa7426115","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"temp1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":220,"wires":[["fa678a58.c21848"]]},{"id":"fa678a58.c21848","type":"join","z":"b2964c3aa7426115","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":590,"y":280,"wires":[["ff4f2b84c8d03171"]]},{"id":"ff4f2b84c8d03171","type":"change","z":"b2964c3aa7426115","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number($trim($split(payload.temp1,\"°C\")[0])) - $number($trim($split(payload.temp2, \"°C\")[0])) > 0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":280,"wires":[["40d8a5b513354c8d"]]},{"id":"34d9f5fe.34070a","type":"change","z":"b2964c3aa7426115","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"temp2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":280,"wires":[["fa678a58.c21848"]]},{"id":"40d8a5b513354c8d","type":"debug","z":"b2964c3aa7426115","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":280,"wires":[]},{"id":"1564eaff.715645","type":"inject","z":"b2964c3aa7426115","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20 °C","payloadType":"str","x":240,"y":240,"wires":[["34d9f5fe.34070a"]]}]

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 October 2021 16:40 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/19 "2021-10-16T16:40:10Z")

</div>

> [@AndyWB](#):
>
> it ist sitll not workinjg....

This works for me

```auto
[{"id":"4fb7c47673f019ee","type":"inject","z":"78cae700c1494223","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"23.5 °C","payloadType":"str","x":338,"y":192,"wires":[["e5731e202e66348f"]]},{"id":"049e803ae9f7163a","type":"debug","z":"78cae700c1494223","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":818,"y":216,"wires":[]},{"id":"2b5b0812d9e2e5a0","type":"inject","z":"78cae700c1494223","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"17 °C","payloadType":"str","x":338,"y":240,"wires":[["94561f5f71af8472"]]},{"id":"e5731e202e66348f","type":"change","z":"78cae700c1494223","name":"","rules":[{"t":"set","p":"ist","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":502,"y":192,"wires":[["b29731fcf4807d34"]]},{"id":"94561f5f71af8472","type":"change","z":"78cae700c1494223","name":"","rules":[{"t":"set","p":"soll","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":502,"y":240,"wires":[["b29731fcf4807d34"]]},{"id":"b29731fcf4807d34","type":"function","z":"78cae700c1494223","name":"","func":"soll = parseFloat(flow.get(\"soll\")) || 0\nist = parseFloat(flow.get(\"ist\")) || 0\n\nmsg.payload = ist - soll\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":684,"y":216,"wires":[["049e803ae9f7163a"]]}]

```

Initial run will not work as it requires both values to be set at least once.

---

<div class="post-metadata">

**Author:** ![AndyWB](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@AndyWB](https://discourse.nodered.org/u/AndyWB)\
**Post date:** [16 October 2021 17:11 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/20 "2021-10-16T17:11:30Z")

</div>

Thank you it works.....

---

<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:** [15 December 2021 17:12 UTC](https://discourse.nodered.org/t/removal-of-extensions-in-strings-and-converting-to-number-for-a-two-point-control/52196/21 "2021-12-15T17:12:20Z")

</div>

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