# Switch SmartPlug according to Humidity

**URL:** <https://discourse.nodered.org/t/switch-smartplug-according-to-humidity/38481>\
**Category:** General\
**Created:** [3 January 2021 21:44 UTC](https://discourse.nodered.org/t/switch-smartplug-according-to-humidity/38481 "2021-01-03T21:44:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [3 January 2021 22:19 UTC](https://discourse.nodered.org/t/switch-smartplug-according-to-humidity/38481/4 "2021-01-03T22:19:00Z")

</div>

A conditional in the change node should get you true/false output based on humdity value. This uses a JSONata expression, you could do similar in a function node  
e.g.

```auto
[{"id":"c202f2f3.ee146","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"35","payloadType":"num","x":160,"y":2400,"wires":[["e55b031e.79888"]]},{"id":"1c9ac260.e6e08e","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":160,"y":2460,"wires":[["e55b031e.79888"]]},{"id":"e55b031e.79888","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload < 40 ? true : false","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":2420,"wires":[["1cd6b62b.b27a2a"]]},{"id":"1cd6b62b.b27a2a","type":"rbe","z":"8d22ae29.7df6d","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":500,"y":2420,"wires":[["c7a8c472.018348"]]},{"id":"c7a8c472.018348","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":2320,"wires":[]}]

```

I also added a rbe node, so to filter out repeated trues and falses.

---

_[View the full topic](https://discourse.nodered.org/t/switch-smartplug-according-to-humidity/38481)._
