# Node-red-node-snmp dynamic host?

**URL:** <https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615>\
**Category:** General\
**Created:** [10 April 2020 20:12 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615 "2020-04-10T20:12:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgarito](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mgarito](https://discourse.nodered.org/u/mgarito)\
**Post date:** [10 April 2020 20:12 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/1 "2020-04-10T20:12:50Z")

</div>

I'm trying to find documentation on how to dynamically set the 'Host' parameter of the SNMP node.

Use case:  
[Http://server:1880/ip?ip=ip.to.check](Http://server:1880/ip?ip=ip.to.check) \>\>\> SNMP host \<ip.to.check\>

![Screen Shot 2020-04-10 at 4.11.22 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/5546fc0b1064cfd5b3116c92aaf72efdcf293d4a.png)

---

<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:** [10 April 2020 21:08 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/2 "2020-04-10T21:08:18Z")

</div>

I think if you leave it blank in the node then msg.host can be used to set it.

---

<div class="post-metadata">

**Author:** ![mgarito](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mgarito](https://discourse.nodered.org/u/mgarito)\
**Post date:** [10 April 2020 21:49 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/3 "2020-04-10T21:49:01Z")

</div>

Leaving the SNMP node's host parameter empty returns:  
"TypeError: Cannot read property 'indexOf' of undefined"

Using Set msg.payload to msg.host has also been unsuccessful.

---

<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:** [10 April 2020 21:57 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/4 "2020-04-10T21:57:33Z")

</div>

Ok - will have a look over the weekend

---

<div class="post-metadata">

**Author:** ![mgarito](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mgarito](https://discourse.nodered.org/u/mgarito)\
**Post date:** [13 April 2020 13:43 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/5 "2020-04-13T13:43:34Z")

</div>

If it helps..., I have the node-red-node-snmp (0.0.24) installed.

Also as a test I've tied Injecting {"host":"10.128.135.20"} directly into the SNMP node with no luck.

 ![Screen Shot 2020-04-13 at 9.57.39 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/236f018df286f188b4785187d23c36c56df29599.png)

---

<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:** [13 April 2020 18:40 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/6 "2020-04-13T18:40:49Z")

</div>

hi  
it needs to be `msg.host` node `msg.payload.host`

---

<div class="post-metadata">

**Author:** ![mgarito](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mgarito](https://discourse.nodered.org/u/mgarito)\
**Post date:** [13 April 2020 22:02 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/7 "2020-04-13T22:02:35Z")

</div>

The SNMP Node does not seem to be unwrapping the variable in the host field BEFORE triggering the SNMP call.

 ![Screen Shot 2020-04-13 at 5.53.47 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bba4bd7f7b2201f3d757a8c9d91add10237934d2.png)

[I have also tried {{req.params.host}} as outlined here without any luck...](https://cookbook.nodered.org/http/handle-url-parameters#flow)

 ![Screen Shot 2020-04-13 at 5.57.44 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/0/10c89848a7c2cc4f45e7a9efc03a8f97c9a5c05c.png)

The Template and HTTP out page load as expected...

I have also been looking at using a sub-flow with an environmental variable.... so far without luck.

---

<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:** [13 April 2020 22:08 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/8 "2020-04-13T22:08:38Z")

</div>

The top screenshot still shows msg.payload.host.... it must be msg.host - you need a change node after the inject to move it.

---

<div class="post-metadata">

**Author:** ![mgarito](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@mgarito](https://discourse.nodered.org/u/mgarito)\
**Post date:** [14 April 2020 15:17 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/9 "2020-04-14T15:17:30Z")

</div>

**Success!**

When I had initially worked with the change node, it failed. I now see that it was because the default 'Set' was not changing the payload as expected. Swapping 'Set' to 'Move' resolved the issue. With additional tinkering I found hat 'Set' could be made to work, however the fields have to be flipped when using 'Set'.

Change \> Move: msg.req.params.host To: msg.host  
Change \> Set: msg.host To: msg.req.params.host

Thanks!

 ![Screen Shot 2020-04-14 at 11.05.24 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cded66a99337dcaab0d510fac6d053a97ba90f0d.png) ![Screen Shot 2020-04-14 at 11.05.46 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab07c36b51870f82db1efac9f4dbd026878edb3b.png)

---

<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:** [28 April 2020 15:17 UTC](https://discourse.nodered.org/t/node-red-node-snmp-dynamic-host/24615/10 "2020-04-28T15:17:31Z")

</div>

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