# Change Function

**URL:** <https://discourse.nodered.org/t/change-function/15862>\
**Category:** General\
**Created:** [24 September 2019 19:14 UTC](https://discourse.nodered.org/t/change-function/15862 "2019-09-24T19:14:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaynel2006](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@shaynel2006](https://discourse.nodered.org/u/shaynel2006)\
**Post date:** [24 September 2019 19:14 UTC](https://discourse.nodered.org/t/change-function/15862/1 "2019-09-24T19:14:20Z")

</div>

Hi, hoping for some guidance  
i have a chart in which i have made some change fuctions  
EG. if the value is 0 it Offline for the battery voltage  
can i set another change value that if the voltage is more than 3 volts its online.  
i have 27 meters and they all range from 3.1 to 3.66 volts, can i just set the change to anything more than 3 volts is considered online?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/98ed07353d66c79ffc7a13b1a7c95819244e9cbf.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8c9593a34f027422b1bd2f539e4f28c477f4b8d1.png)

---

<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:** [25 September 2019 05:59 UTC](https://discourse.nodered.org/t/change-function/15862/2 "2019-09-25T05:59:40Z")

</div>

To do it that way, you will likely need to use a JSONata function.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [25 September 2019 06:25 UTC](https://discourse.nodered.org/t/change-function/15862/3 "2019-09-25T06:25:39Z")

</div>

This is a generic method of converting \>+3V to Online

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

```auto
[{"id":"5f3702f5.b4473c","type":"inject","z":"2f1fd98b.bb0256","name":"","topic":"","payload":"3.19","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":276,"y":176,"wires":[["2b336585.bbc3ba"]]},{"id":"298c8fc6.6a996","type":"inject","z":"2f1fd98b.bb0256","name":"","topic":"","payload":"2.9","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":264,"wires":[["2b336585.bbc3ba"]]},{"id":"2b336585.bbc3ba","type":"switch","z":"2f1fd98b.bb0256","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"3","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":220,"wires":[["1bbf8008.d43bd"],["668f44f2.77ab3c"]]},{"id":"1bbf8008.d43bd","type":"change","z":"2f1fd98b.bb0256","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Online","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":674,"y":176,"wires":[["668f44f2.77ab3c"]]},{"id":"668f44f2.77ab3c","type":"debug","z":"2f1fd98b.bb0256","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":884,"y":220,"wires":[]}]

```
