Ethernet Relay Board -- Works Great!

Posted on
Wed Sep 27, 2017 5:10 am
jens offline
Posts: 265
Joined: May 03, 2015
Location: Sweden

Re: Ethernet Relay Board -- Works Great!

Is it possible to get an easier instruction how to make it work?

What code should you enter to activate a relay, eg nt 2 and how to turn it off again?


// Jens

Posted on
Wed Sep 27, 2017 5:56 am
zaiks offline
Posts: 19
Joined: May 19, 2016

Re: Ethernet Relay Board -- Works Great!

jay (support) wrote:
How are you calling the script?


I'm callinng this as embedded script each call in separate Action Group

jens wrote:
Is it possible to get an easier instruction how to make it work?


Unfortunately this is all I have

Posted on
Wed Sep 27, 2017 9:27 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Ethernet Relay Board -- Works Great!

zaiks wrote:
jay (support) wrote:
How are you calling the script?


I'm callinng this as embedded script each call in separate Action Group


And you just uncomment one of the lines at the top depending on what you want to do?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Sep 27, 2017 2:40 pm
zaiks offline
Posts: 19
Joined: May 19, 2016

Re: Ethernet Relay Board -- Works Great!

jay (support) wrote:
And you just uncomment one of the lines at the top depending on what you want to do?


Exactly

Posted on
Thu Sep 28, 2017 2:48 am
zaiks offline
Posts: 19
Joined: May 19, 2016

Re: Ethernet Relay Board -- Works Great!

jay (support) wrote:
From an Indigo standpoint, you don't need to convert it since the script doesn't target Indigo.


Ok. This script might be converted to external and it does what it is supposed to do as long as Apple keeps it's scripting envionment alive.
But for status requests I call for Indigo and write the states to variables - this part will be killed as I understand?

Posted on
Thu Sep 28, 2017 12:35 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Ethernet Relay Board -- Works Great!

zaiks wrote:
But for status requests I call for Indigo and write the states to variables - this part will be killed as I understand?


I don't know - the code you posted doesn't appear to communicate with Indigo. To reinforce what we've already posted, any AppleScript that has a "tell 'IndigoServer'" in it won't work.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Oct 01, 2017 12:53 pm
zaiks offline
Posts: 19
Joined: May 19, 2016

Re: Ethernet Relay Board -- Works Great!

Ok. Anyway as its always good idea to let something uncertain be the base for your crucial need I started to port this code over to python. I have all states read and written to variables, but for controlling I would like to get help with following shellscript:

Code: Select all
curl --connect-timeout 2 --data saida1off=off http://admin:12345678@192.168.1.166/relay_en.cgi


How I can achieve the same with python?

Posted on
Sun Oct 01, 2017 4:01 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Ethernet Relay Board -- Works Great!

zaiks wrote:
Ok. Anyway as its always good idea to let something uncertain be the base for your crucial need I started to port this code over to python. I have all states read and written to variables, but for controlling I would like to get help with following shellscript:

Code: Select all
curl --connect-timeout 2 --data saida1off=off http://admin:12345678@192.168.1.166/relay_en.cgi


How I can achieve the same with python?


See this thread: viewtopic.php?f=107&t=19059

Something like:
Code: Select all
import requests

url = "http://admin:12345678@192.168.1.166/relay_en.cgi?saida1off=off"
r = requests.get(url)

# Example of logging to Indigo the HTTP result status code and text:
indigo.server.log("result status: %d, text: %s" % (r.status_code, r.text))

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 02, 2017 3:17 am
zaiks offline
Posts: 19
Joined: May 19, 2016

Re: Ethernet Relay Board -- Works Great!

Thank you Joe - this pointed me to the desired direction :D

My code is maybe a little robust, but i'll share the results with you as well. Now I'm able to control this card with some different python scripts and am futureproof.

For statuses and writing these to variables:
Code: Select all
 # Script for getting statuses of ethernet Relay board

import urllib

# Input your data here:
BoardIP = '192.168.1.166'
User = 'admin'
Pass = '12345678'
RelayName = 'No1' # If you have more than 1 relay board

# Constants and global variables
SearchString2 = "img src"
Result = ''
variableOut = ''
Output = ''
a = 1

# Start extraction of data
urlReturned = urllib.urlopen('http://' + User + ':' + Pass + '@' + BoardIP + '/relay_en.cgi')
data_getStatuses = urlReturned.read()

for a in range(1, 9):
   SearchString = 'saida' + str(a) + 'pluse'
   ResultA = data_getStatuses[data_getStatuses.find(SearchString):data_getStatuses.find(SearchString)+150]
   ResultB = ResultA[ResultA.find(SearchString2)+9:ResultA.find(SearchString2)+16]
   if ResultB == "lighton":
      Result = str(Result) + '1'
      Output = "true"
   else:
      Result = str(Result) + '0'
      Output = "false"
   # Sending info to variables
   variableOut = str(RelayName) + '_onStateRelay_' + str(a)
   try:
      var = indigo.variables[variableOut]
   except:
      indigo.variable.create(variableOut)
   indigo.variable.updateValue(variableOut, Output)

# Relay states as list
# indigo.server.log(str(Result))


For changing single relay state:
Code: Select all
# Script for setting status of ethernet Relay board one relay at a time

import requests

# Input your data here:
BoardIP = '192.168.1.166'
User = 'admin'
Pass = '12345678'
RelayNo = '1'
RelayCommand = 'on'   # accepts on/off

# Constants and global variables
key1 = ''
value1 = ''

# Start execution of change
url = ('http://' + BoardIP + '/relay_en.cgi')
key1 = 'saida' + RelayNo + RelayCommand
value1 = RelayCommand
payload = {key1: value1}
r = requests.post(url, auth=(User, Pass), data=payload)


For changing relay states by list:
Code: Select all
# Script for setting status of ethernet Relay board relay's by list

import requests

# Input your data here:
BoardIP = '192.168.1.166'
User = 'admin'
Pass = '12345678'
RelayList = '00000000'  # 1- true, 0 - false, any other character - ignore, 1st relay is 1st position in list

# Constants and global variables
key1 = ''
value1 = ''
a = 1
state = ''
RelayCommand = ''

# Start execution of change
url = ('http://' + BoardIP + '/relay_en.cgi')

for a in range(0,8):
   state = RelayList[a]
   if state == '1':
      RelayCommand = 'on'
   if state == '0':
      RelayCommand = 'off'
   if state <> '1' and state <> '0':
      RelayCommand = ''
   key1 = 'saida' + str(a+1) + RelayCommand
   value1 = RelayCommand
   payload = {key1: value1}
   r = requests.post(url, auth=(User, Pass), data=payload)

Posted on
Sat Jan 13, 2018 11:02 am
jens offline
Posts: 265
Joined: May 03, 2015
Location: Sweden

Re: Ethernet Relay Board -- Works Great!

Where should I enter the code?

//Jens

Posted on
Sun Jan 14, 2018 1:04 pm
TwitchCaptain offline
User avatar
Posts: 104
Joined: Dec 13, 2016
Location: San Francisco

Re: Ethernet Relay Board -- Works Great!

I just bought one of these network relay boards to control my four sprinkler zones and pool fill valve. I was trying to do this with an arduino connected to an 8 relay board, but what a mess. Once I write some code to interact with this board, I'll post it to my github. I'll aim for a plugin, but we'll see what I come up with. 8) Thanks for the data so far, this look promising!

Posted on
Wed Jan 17, 2018 3:05 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Ethernet Relay Board -- Works Great!

This relay board looks very interesting, what about the 8 inputs ? can you read their status or are they only able to command the relays ?

I have been looking for any sort of documentation about this board (and the inputs, as you seem to have the relay part well covered) and cannot find anything, do you have something ?

Thank you,

Patrick

Posted on
Wed Jan 17, 2018 7:59 am
raneil offline
User avatar
Posts: 90
Joined: Feb 11, 2011
Location: Grapevine, Texas

Re: Ethernet Relay Board -- Works Great!

DomoPat wrote:
This relay board looks very interesting, what about the 8 inputs ? can you read their status or are they only able to command the relays ?

I have been looking for any sort of documentation about this board (and the inputs, as you seem to have the relay part well covered) and cannot find anything, do you have something ?

Thank you,

Patrick



Unfortunately there is no documentation provided, only scattered bits of information on the various eBay listings. But here's my best guess based on those listings and the onboard web-based UI. If I get a chance to test this out, I'll post an update.

    • The inputs are digital (presumably 5V), not analog.
    • Their current states cannot be queried like the relay states can.
    • They appear to be used only for directly controlling the relays.
    • There is a configuration webpage that can be used to map each input to any combination of relays. See screenshot below.
    • My assumption is that applying 5V to a given input will immediately energize the relay(s) mapped to it, and removing the input voltage will immediately de-energize the mapped relay(s).

Image

Posted on
Thu Jan 18, 2018 4:36 am
TwitchCaptain offline
User avatar
Posts: 104
Joined: Dec 13, 2016
Location: San Francisco

Re: Ethernet Relay Board -- Works Great!

The input relays can be "disconnected" from the output relays and you can read their status remotely. Here's some docs to use TCP mode (not HTTP). This device is pretty epic, the only real disadvantage is that it must be polled. I'm working on a plugin now....

Code: Select all
Parameters of controller Default IP: 192.168.1.166 Default TCP port: 1234

(1) Open the relay
TCP Relay Protocol V1.0
L(n) ,n=1:8,Such as the need to open the relay 1, then send the string “L1”. The board will return “Relayon 1” after the relay in operation.

(2) Close the relay
D(n),n=1:8,Such as the need to close the relay 1, then send the string “D3”. The board will return “Relayoff 3” after the relay in operation.

 (3) 800ms pluse,Open relay for 800ms,then close.
P(n),n=1:8,Such as the need to pluse the relay 1, then send the string “P1”. The board will return “Press 1” after the relay in operation.

(4) Read status of relays
R(n),n=1:8,Such as the need to read the status of relay 1, then send the string “R1”. The board will return “Relayon 1” or “Relayoff 1”.

(5) Read input status
I(n),n=1:8, Such as the need to read the status of input 1, then send the string “I1”. The board will return “IL 1” or “IH 1”.

(6) Burst mode read status
Send strings ”DUMP” or “dump”,the board will return all status of relays and inputs by end of “OK”.

(7) Examples
1. Connect to TCP port;
2. Send command,all commad by ends of “\r\n”;
3. If the PC within 30s no data is sent to the controller, the controller will disconnect to PC.

L1
Relayon 1

DUMP
Relayon 1
Relayoff 2
Relayoff 3
Relayoff 4
Relayoff 5
Relayoff 6
Relayoff 7
Relayoff 8
IL 1
IL 2
IL 3
IL 4
IL 5
IL 6
IL 7
IL 8
OK


To energize the input contacts, connect GRN to COM and 5V to one of the relay pins. There are two COM pins, one for ports 1-4 and one for ports 5-8. These can all be jumpered together if you're so inclined. The inputs are either on or off. (high/low)

Posted on
Thu Jan 18, 2018 8:37 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Ethernet Relay Board -- Works Great!

Very interesting, thank you Raneil and Frankyhall ! I am going to order one (or two considering the price !) to replace some old X10 modules and gain some inputs in a far away location. Nice !

Who is online

Users browsing this forum: No registered users and 4 guests