Page 1 of 1

Denkovi ethernet relay board

PostPosted: Wed Nov 04, 2015 12:18 am
by manwithavan
Can anyone please suggest the best / easiest way to talk to this thing using Indigo?

http://denkovi.com/internet-ethernet-12 ... o-snmp-web

:)

Re: Denkovi ethernet relay board

PostPosted: Wed Nov 04, 2015 11:45 am
by jay (support)
A brief glance seems to indicate it has an HTTP/XML API. So you'd need to either write Python scripts or a plugin to talk to it. There are a couple of 3rd party I/O plugins for other multi-i/o devices that might suit your needs if you're open to other hardware options.

[MODERATOR NOTE] moved to the appropriate forum.

Re: Denkovi ethernet relay board

PostPosted: Wed Nov 04, 2015 2:27 pm
by manwithavan
Thanks Jay :)


Sent from my iPhone using Tapatalk

Re: Denkovi ethernet relay board

PostPosted: Tue Jul 09, 2019 1:13 am
by berkinet
manwithavan wrote:
Can anyone please suggest the best / easiest way to talk to this thing using Indigo?

http://denkovi.com/internet-ethernet-12 ... o-snmp-web

I have implemented an Indigo virtual device for this board and it works well. PM or reply to this thread if you would like more information.

Re: Denkovi ethernet relay board

PostPosted: Tue Jul 09, 2019 4:49 am
by manwithavan
Yes please! Keen to try it out.

Thanks

Re: Denkovi ethernet relay board

PostPosted: Tue Jul 09, 2019 7:41 am
by berkinet
manwithavan wrote:
Yes please! Keen to try it out....

No problem...

A little background. On the Denkovi model I am using, DO 9 to 13 correspond to Relays 1 to 5. I used DO 9 to control Relay 1. I used the Common (COM) and Normally Open (NO) contacts to switch the power to my real device, a pump. There are two external interfaces available for controlling the Denkovi products: HTTP (json or xml) and SNMP. I chose SNMP mostly because I was not that familiar with it and wanted a chance to see how it worked, But, I could have just as easily used HTTP (via curl.

Since I was going to use the Indigo built-in Virtual Device type, I first needed to create Action Groups to perform the necessary functions: On, Off, Toggle, and Status. I also needed to create a variable for Indigo to watch to update the virtual device's state.

For the Action Groups I used the action type Run Shell Script (Sscipt and File Actions). For the On action Group, the "Shell Script*" I entered was:
Code: Select all
 /usr/bin/snmpset -v1 -c private 192.168.1.10 .1.3.6.1.4.1.42505.1.2.3.1.11.8 i 1
Where:
    /usr/bin/snmpset is a command included in MacOS that can send SNMP requests.
    192.168.1.10 is the IP address of my Denkovi switch.
    .1.3.6.1.4.1.42505.1.2.3.1.11.8 is the OID (SNMP Object) for DO 9 (the DOs are internally numbered starting with 0, so .8 is DO 9 and DO 1 would end with .0)
    i indicates that the value to be assigned to the OID is an integer
    1 is the actual value to assign (0 = off, 1 = on and 2 = toggle)
So, executing this Action Group will turn on DO 9 and, on my switch, the associated Relay, 1.
The Off action is similar except the final digit is a 0.

For the status Action Group I used another command, snmpget. This is similar to snmpset, but is intended to read information rather than set information. The "Shell Script" I used here was:
Code: Select all
/usr/bin/snmpget -v1 -Ovq  -c private 192.168.1.10 .1.3.6.1.4.1.42505.1.2.3.1.11.8|/usr/bin/tr -d "\n"
The extra option -Ovq is used to suppress all output except the actual state value (0 or 1). The tr command at the end is to remove the trailing newline character - which confuses Indigo. Again, the last digit corresponds to the DO number, starting with 0. I also check the Store result in variable option to use to track the device state. I created the Indigo variable: pumpState. Note: This command will log an error in the Indigo log, just ignore it. it is due to the way the newline is removed.

The Toggle Action Group was slightly more complicated, since the end-state of the DO is not directly determined by the snmpset command. So, I used two Run Shell Script commands in the Action group. The first was:
Code: Select all
/usr/bin/snmpget -v1 -c private 192.168.1.10 .1.3.6.1.4.1.42505.1.2.3.1.11.8
Note there is no value since it is not required for the toggle function. The second "Shell Script" command was the same as used in the Status Action Group, and the save results option was also checked. So, after toggling the DO state, the second scripts checks to see what the new state is and saves it to a variable.

Finally, you need to create the Indigo Virtual Device. All you have to do for the various options is select the Action Groups and variable you created.

Let me know if you have any questions. Also, there is a way around the "status" error. But, it requires using a Python script in place of the snmpget command and, other than suppressing the error, adds no functionality.

* Although the Action option is named "Run Shell Script" it actually executes a Unix command line and is not limited to shell scripts. That is why it works with the snmpset and snmpget commands.

Re: Denkovi ethernet relay board

PostPosted: Tue Jul 09, 2019 8:23 am
by berkinet
BTW, It is also possible to have the Denkovi boards broadcast information about changes in port status (using snmp traps) so Indigo can know about changes entered via the web interface or local options. This is somewhat more complex than the simple Virtual Device. But, I can provide some more information if there is interest.

Re: Denkovi ethernet relay board

PostPosted: Wed Jul 10, 2019 10:29 am
by berkinet
Also, for anyone who is interested in one of the Denkovi products with a built-in weekly scheduler, I have worked out how to program the scheduler remotely by creating a text file containing the schedule and uploading it to the board using a simple shell script. This is infinitely easier than trying to set a schedule in the Denkovi WebUI. It also allows you to have several schedules and change them as you wish. Here is a sample schedule file. The "+" is the field separator and col 1 is the relay number, col 2 is 1 for on or 0 for off and col 3 is the time (hh:mm):
Code: Select all
9+0+00:00
9+1+01:00
9+0+03:00
9+1+04:00
9+0+09:00
9+1+10:00
9+0+15:00
9+1+18:00
10+1+07:00
10+0+21:00
11+0+02:00
11+1+02:01