SNMP binding confusion

Platform information:

  • Hardware: CPUArchitecture/RAM/storage VM 4 core, 2gb ram 32gb HDD
  • OS: what OS is used and which version ubuntu 18.04
  • Java Runtime Environment: which java platform is used and what version 1.8.0_191
  • openHAB version: Openhab2 2.4.0-1

I’m trying to get the snmp binding working but getting a bit confused with what needs configured where.

My end goal is to know the state of a PDU socket in Basic UI (with a light or indicator) and to make an on/off button and reboot button for the socket.

so far i have established from the command line on the Ubuntu machine running my Openhab install I can achieve these goals using the following commands

snmpwalk -v1 -c public

this returns

iso. = INTEGER: 2

(interger 2 tells me the socket is off )

so i can run
snmpset -v1 -c private$outlet integer 1

this switches the socket on.

if I run
snmpset -v1 -c private$outlet integer 3

this would immediately power cycle the socket.

could someone give me a rough order of how best to approach this. so far i’m just reading stuff about snmp and going round in circles.

i have reads the snmp bindings page about 100 times so far, pls don’t refer me to that.



Take a look at something I wrote up, the good news is you are so close to having what you want: Leveraging SNMP to detect your mobile device

What I think you need is the Map add-on and setup a .map file with the following in it:


Then just slap :MAP( to your item and OH should then translate the integers into the ON/OFF you want in Basic UI.

Thanks for your help, but I think I’m a lot further away than you realize :confused:

The 2 lines below which I currently run from the Ubuntu prompt, from my understanding i need to put these in the snmp.cfg file
1. snmpwalk -v1 -c public

2. snmpset -v1 -c private$outlet integer 2

do you know what syntax I would need to use for these in the snmp.cfg i have attempted below

1. snmp="<[]"

I’m looking at the snmp binding guide but there is no example of snmpwalk so do I just format it the same as the GET example they use? Also what about the . before the OID? In my ubuntu command I don’t use that, is it specifically required for the openhab binding or is it just specific to the example OIDs they happen to be using?
in this status request there is no integer from the command line so can I omit the last :value in my snmp.cfg?

I’m slightly more confident with the 2 below than the one above?

2. snmp=">[OFF:$outlet integer 2]"
2. snmp=">[ON:$outlet integer 1]"

my binding is installed but still doesn’t show in the paperui list so im guessing there is still something wrong.

Ahhh you need to move your work out of snmp.cfg as that is for the system settings like SNMP timeout, SNMP community, etc.

Add your work into an items file, in my doc I’m just pulling information from the device so I use the ‘<’ and the end of that before you end the line do a ‘>’ to push commands to the device.

yes initially i had them in the items file (although undoubtedly with the wrong syntax) , then last night i thought maybe they go directly in the cfg file

anyway… I have now moved them back out of the cfg file. it looks like this, is that all that is required in the snmp.cfg?

# Listening Port (optional, defaults to '162')
# The SNMP community to listen to (optional, defaults to 'public')
community= public
# The SNMP retry timeout (in milliseconds). Defaults to 1500.
# Sets the number of milliseconds between retries.
timeout= 1500
# The SNMP number of retries. Defaults to 0.
# Sets the number of retries before aborting the request.

at what point should i see the snmp binding show up in the paperui ? it is definitely installed, but not displayed here.


are these the only files that i need to configure ?


or do i also need to configure


Are there any other files I need to configure on the openhab box that I haven’t listed above?
At this stage i’m not talking about the binding port workaround.


This is my SNMP.cfg

# Listening Port (optional, defaults to '162')

# The SNMP community to listen to (optional, defaults to 'public')

# The SNMP retry timeout (in milliseconds). Defaults to 1500.
# Sets the number of milliseconds between retries.

# The SNMP number of retries. Defaults to 0.
# Sets the number of retries before aborting the request.

As for PaperUI, you have to always keep in mind that if it is a 1.x binding, chances are it isn’t going to show up in PaperUI; also confirmed on mine it doesn’t show up.

Just for grins post up the item so we can confirm things are correct in that. And you also need the following file created:
/etc/openhab2/transform/ <-- This will require the transformation binding ‘map’ to be installed. And a small change to the item line will be needed to call the map file when it sends/receives the SNMP values.

Once installed and the map file is created you need to map the number to corresponding ON/OFF. Post the map file lines when you post your item line.

Thanks for taking the time to reply,

i will spend some time trying to make it work with the information you have given and come back to post configs when i get completely lost again. I feel like i have enough info to digest and work on for a while.

Appreciate your help

here is my items file that i have being working on today with no success.

I’ve been googling for background reading material but i struggle to find relevant info that i’m able to apply to this situation.

//  snmpset -v1 -c private$outlet integer 1
//  snmpset -v1 -c private$outlet integer 2
//  snmpwalk -v1 -c public

//MY FAILED ATTEMPTS to convert the commands above to something openhab can use
//Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:$outlet integer 2:MAP(] >[ON:$outlet integer 1:MAP(]"}
//Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF: integer 2] >[ON:$outlet integer 1] "}
//Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:] >[ON:] "}
//Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:] >[ON:] "}
//Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:] >[ON:] "}
//Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:] >[ON:] "}

Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:] >[ON:] "}

//Switch Switch_PortEnable03 "Port 03 [%s]" <port> (ports)	{ snmp="<[] >[OFF:] >[ON:]" }
//Switch Switch_POEEnable2 "PoE WiFi Enable [%s]"  { snmp="<[] >[OFF:] >[ON:]" }
//Switch phone1_ap1_24    "phone1 Association Ap1"    (phone1V, gPersist)    { snmp="<[]"}
//Number AR_Printer_1 		"AR Black Toner [%d%%]"		<_4250>		(AR_Printer)	{ snmp="<[]"}
//Switch Strip1_plug2 “Strip 1 Outlet 2 [%s] " { snmp=”<[] >[ON:] >[OFF:]"}

//  [config=java.util.regex.Matcher[pattern=<\[([0-9.a-zA-Z/]+):(v1|v2c|v3):([0-9.a-zA-Z]+):([0-9.a-zA-Z]+):([0-9]+):(.*)?\] region=0,57 lastmatch=]] 
//  [config=java.util.regex.Matcher[pattern=>\[([0-9.a-zA-Z]+):([0-9.a-zA-Z/]+):(v1|v2c|v3):([0-9.a-zA-Z]+):([0-9.a-zA-Z]+):([0-9]+)\] region=0,57 lastmatch=]]

I’m also not sure if the :1600 i have in some of my lines is supposed to signify the port number? there is no reference to this in the command i’m sending directly to the PDU.
in the other examples in my items file they have used 10000, 60000, 1500

does it matter if the :MAP( is at the end of my line or in the middle?

Below is my 2 tries at I’m not sure which of the 2 is correct if the PDU needs “$outlet integer 1” from the command line I’m thinking it must need it from openhab as well?

$outlet integer 1=ON
$outlet integer 2=OFF




Lets keep breaking out the problem, instead of also making the switch turn the outlet on and off; lets try to just pull the state of the outlet and get that up and working.

Switch Lswitchenable "Lswitch [%s]" {snmp="<[]"}

You should be able to watch your event log or the Basic UI and make manual changes that OH picks up and translates correctly from the map transformation.

Also something odd and not sure of (due to not having access to this hardware), looking into the OID you provided it doesn’t fully resolve to anything. But when I do find as a valid OID for rPDUOutletControlOutletCommand. Site that I used to lookup the MIB tree -

thank you once again!! I now have this switch fully working. :smile:
1 thing i still don’t understand though, what is the significance of the 10000 what does it do?

ip : community string : 10000 : MAP command

my next project is to replicate this to many switches and also to sort them into groups and make a suitable gui.

thank you so much for your help.

Excellent to hear, may I also suggest you post your solution for any future reader who needs a working example . :wink:

Reviewing the doco for the SNMP binding, the 10000 is the update interval for SNMP GET vs a SET/TRAP. It can probably change to other msec values, in my case it works.

It took me a while to get a grasp of Habpanel, but it’s a very flexible at making the GUI how you would like and have made group buttons to control many item state changes vs having to tap the dashboard multiple times.

so to summarize from beginning to end I think this outlines everything I did to make my first SNMP switch.

-install OS
-install java
-install openhab
-create samba shares
-install snmp binding (it shows as installed in paperui but you don’t see any other indication that its installed or working like you do with 2.0 bindings.)
-created the following files in these folders. (you don’t need to name them all snmp.xxxx i just did this for easy identification.)


the contents of my files are as follows.


community= public
timeout= 1500


Switch Lswitchenable "Lswitch [%s]" {snmp="<[] >[OFF:] >[ON:]"}


sitemap snmp label="rebooting by SNMP" {

Frame label="snmp testing" icon="settings" {
        Switch item=Lswitchenable label="Lswitch[]" mappings=[ON="ON",OFF="OFF"]


hope this helps someone.