We have moved at community.getvera.com

Author Topic: Plugin for Relay Output / Analog Input Boards from iorelay.com  (Read 28977 times)

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
I've been working on some Monitoring and Management for my Garage, and wrote a plugin to handle Relay-based IO Boards from IORelay.com (National Control Devices)

It's now working for manual control/monitoring, so I'm publishing what I have so far:
    http://code.mios.com/trac/mios_iorelay


So far, it handles the ProXR, ProXR Lite and Reactor Relay boards from NCD.  Specifically models that support 1-8 Relays, and 8 Analog Inputs.  These boards each have Flexable Serial Interfaces, offering direct-USB, ZigBee ZB, 802.15.4, Ethernet and basically anything "Serial" that uses the Xbee-style pinout.

The Plugin will
  • expose each configured Relay as a Light Switch, with regular On / Off controls
  • expose each configured Analog Input as a Light Sensor, with values from 0-100%
  • poll the Inputs on a configurable frequency (seconds) for changes in value
  • poll the Relays, for any changes in status that occur "outside" of Vera (such as the Reactor Relays which run autonomously)
  • throw out "lost" messages when they're not acknowledged within a reasonable timeframe
  • allow manual (permanent, temporary or lockout) override for Reactor Relays, which are normally controlled by the Processor on the Reactor Relay.

I haven't tested it against Scenes yet, but it should work fine using standard LightSensor1 and BinarySwitch1 based scenes (for control and events)


In my configuration, I've been testing with the following boards:
  • 2 Relay, 8 Analog input ProXR Lite
    This is for my Garage, and is using a Roving Networks RN-XV for Wifi-based control. 
    It has inputs representing Light Level, Temperature and a few Reed Switches, the outputs will be used for Control.
  • 2 Relay, 8 Analog input Reactor Relay
    This is to eventually auto-restart Vera if it doesn't heartbeat, and uses a USB adapter for control (it hangs just below Vera).
    One Relay will Control power to Vera, and will eventually cut-it-off if it doesn't receive a [MiOS Scene-based] Heatbeat within 10-15 minutes.  This will be more fully implemented once I do the Garage stuff.[.li]
« Last Edit: November 22, 2011, 01:35:34 pm by guessed »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #1 on: August 27, 2011, 11:52:09 pm »
oops, realized I hadn't set the code.mios.com wiki perms correctly for public users.  Fixed now.

Attached are some pictures from the assembled Garage device, just before I swapped out the original 802.15.4 SF Communications modules for the RN-XV Wifi boards

The pics are a bit grainy, but you can see the wiring for the 2x Relay Outputs, and some of the Inputs, are externalized.  Internally I have a Temperature sensor hooked up, and externally I have a Light sensor and 2x Seco-Larm "wide-gap" reed switches to detect the Garage door position.
« Last Edit: November 22, 2011, 01:29:56 pm by guessed »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #2 on: August 30, 2011, 12:55:57 am »
Patched to 0.1.1 for stability.

There were some cases where the poll() loop would simply stop working.  Changed code from luup.call_timer to luup.call_delay, and ran a 24-hr burn in to ensure the Relays and Inputs stayed in sync.

Mostly putting info here for folks that may be doing things with high-frequency timers, combined with high-frequency IO.  In this situation, you may be better off using luup.call_delay.

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #3 on: October 12, 2011, 09:49:14 am »
To begin with: Thank you! This is the perfect plugin/toy for engineers like me...  8)

Do you think you could also provide a explanation of how to integrate the board with the wireless option? On the following page I only found one for the usb one, and it looks like some pictures are missing: http://code.mios.com/trac/mios_iorelay/wiki/Installation-UI4

How is the RN-XV configured? Somehow I need to tell it which wlan it has to join?

Do you think the following board would work with the RN-XV to?
http://www.controlanything.com/Relay/Device/ZR220HP
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #4 on: October 12, 2011, 12:01:47 pm »
@chixxi,
I can add that description, it might just take a little while to get to it.  Generally speaking though, I plugged the RN-XV module into a XBee explorer that I had from Sparkfun (http://www.sparkfun.com/products/8687) and then connected to it using a Terminal program ("screen" on my Mac) with it's initial Baud rate settings.

The commands are available in this doc:
    http://www.rovingnetworks.com/files/resources/WiFly-RN-UM.pdf

you need to set the Wifi Parameters, so that it'll connect to your Network (etc), as well as the Baud Rate, so that it'll connect [correctly] to the IORelay board.

After I got the basics working, I turned off all the response strings (using "set comm") so it wouldn't put excess characters out to the IORelay board.

Don't forget to "save" the changes after you make them, since most are transient otherwise.



To my knowledge, all of the IORelay.com/ControlAnything.com boards use the same API/Command structure, so as long as it has the XBee "footprint" you should be able to use it.  The plugin has a parameter for the # of inputs, which you'd need to set to "0" for that board, as well as a parameter for the # of outputs, which you'd set to "2".

For the boards I was using there's a "3rd rail" of connector just inside one of the XBee rails.  This is fine for an XBee module, since the clearances below it are larger, but it interferes with an RN-XV module.  I put an extra set of headers onto my RN-XV before installing it so that I could "raise it up".... the details for that are in the install instructions.

Some of the Relay-only boards don't have this extra row, but if you're ordering it, you may as well pay for the headers up front (note that these are non-standard pitch, so order the right ones)


Now, I've run into an occasional problem where mine seems to disappear off the network.  I haven't chased it down yet, but think it's because I've mounted it in a distant corner of my garage.  If I were doing it again, I'd custom-order (direct from RovingNetworks.com) the RN-XV that has the u.FL (RN-XV-U) or SMA (RN-XV-S) connector so that I could use an external antenna, since I think I have an antenna/range problem with the built-in antenna (RN-XV-W)

You'll see both those options in the "buy" tab on this page:
    http://www.rovingnetworks.com/products/RN_XV

Offline rickdunn

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #5 on: October 20, 2011, 07:01:07 pm »
Good day!

I've got a very basic relay from IORelay.com and tried to set it up using your steps. I just got my vera a few days ago so this was more to try adding a custom device than to actually use the relay (for now). I can add the relay no problem, but there's no options on the main screen. All I see is the relay in the devices list, with no ON/OFF button or anything. The images aren't available anymore in the post, so maybe I'm missing some step.

Could you help me out please ?

Thanks !
Eric.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #6 on: October 20, 2011, 11:17:17 pm »
ok, so what Model and IO Device are you using in your setup?

My primary one is Ethernet attached, and the settings dialog is per the attached images (for some reason, my images from the Wiki have vaporized)

For a USB (direct) attached one, it's a little simpler, except you need to go into the Serial Port configuration and "associate" the Serial port adapter with the IORelay board.

Can you push a screenshot of what you're seeing?  The "Parent" device really has no dashboard, it's empty.  But you should have 2 "Relay" child devices (represented as Light Switches) that you can use to control the Relays on the board.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #7 on: October 20, 2011, 11:24:31 pm »
oh, and I have my Interval set very aggressively, in order to cause a certain MiOS bug to occur.  I don't recommend setting it down that low.

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #8 on: November 18, 2011, 08:27:01 am »
Thanks so much for your response @guessed! I am going to get some boards for Christmas  ;)
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #9 on: November 18, 2011, 09:43:05 am »
Recommend you start with 1 board and get it working well, preferably with wired USB.

It's still in prototype stage and it does break, right now I think it's due to an interaction between the Wifi XVee and Vera but I haven't isolated it yet.  Also, the more inputs and outputs you have the more error probe right now due to the amount of polling I have to do.

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #10 on: November 18, 2011, 09:57:07 am »
Concratulations to your 2000th post!  :o

Yeah I'm gonna do that, even though it's going to be difficult for me to order "just one simple board".

dear guessed, may I kindly ask you to have a look at the following post from me, no hurry, just if you want to...
http://forum.micasaverde.com/index.php/topic,8440.0.html

have a nice weekend everybody!
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline The-Source

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #11 on: December 04, 2011, 10:42:25 am »
Recommend you start with 1 board and get it working well, preferably with wired USB.

It's still in prototype stage and it does break, right now I think it's due to an interaction between the Wifi XVee and Vera but I haven't isolated it yet.  Also, the more inputs and outputs you have the more error probe right now due to the amount of polling I have to do.
Im thinking of buying a wired USB relay board with 2 relay contacts and 8 A/D inputs.
But how serious is this polling issue?
Because im thinking of using this to view my alarm status and maybe in the future to set the alarm.
To view the status of my alarm i use analogue outputs (dry contact)  so that i can program a scene in case of break in, fire or sabotage..
there are only 10 types of people in the world those who understand binary and those who don't ;)

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #12 on: December 04, 2011, 10:51:41 am »
I haven't yet narrowed down why the WiFi board "just stops" during the polling cycles.  I suspect that there's something else going on with my Network that periodically causes the WiFi board to "drop out".  I've seen this type of thing before where Vera's HTTP-based "Discovery" techniques (for Video Cameras, GC100's etc) interfere with the Roving Networks WiFi chips (which also expose a HTTP interface)

I haven't tried a long run of it over direct-USB, so I don't know if the same types of problems are exhibited under that.

I currently poll every 3s, with 8 inputs and 2 outputs being sampled (which is very aggressive).  I sample the outputs as I may not be the only thing making changes (eg. a Reactor-Relay board).  I have verbose logging enabled (permanently) so, as you can imagine, I have a bunch of logging output flying by at any moment.



Given your description though, I'm a little puzzled.  If you have an Alarm system, why do you need this board with a few extra Zones?  If you don't have an Alarm system, then I'd certainly get one of those over one of these boards, since it's not intended to be an Alarm system, more of an input monitoring system (which is what I have it wired up for, "Is my Garage open" type stuff)

Offline The-Source

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #13 on: December 04, 2011, 03:33:01 pm »
I got a honeywell Galaxy G2-44 alarm panel and this type of panel doesn't have a rs232 connection. And the cheapest option to get a rs232 programming cable is spending about 60euro for just the cable and then its stil the question if i can set the system with it.

But I can program outputs of the panel to close/open on certain moments, like the alarm is set etc.
So im planning to use such output as your "the garage door is open" ;)

But the board also has 2 relays which i could connect to the inputs of the alarm panel so that i could use it like a trigger for alarm (dis)arm

The IOrelay doesn't have to be a USB version, Ethernet is also a option for me if thats is better supported?
(WLAN is not necessary because router/ vera and alarm panel are all within 0.5 meters ;) )
there are only 10 types of people in the world those who understand binary and those who don't ;)

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Plugin for Relay Output / Analog Input Boards from iorelay.com
« Reply #14 on: December 04, 2011, 04:20:46 pm »
Ah, ok.  Your Alarm has PGM's, fair enough.

I'd alway's use Wired over Wireless, whenever you have a choice.  The USB Version will be fine.  I have one of these, it's just on the Second Relay board that I have, and I just haven't gotten around to using it yet. 

My second board happens to be a Reactor-Relay, that'll be connected directly to Vera over USB, so I had been setting up the code to handle either... hence the Polls on the Relay outputs, since it runs under it's own steam (and was intended to Reboot Vera if it didn't heartbeat in a certain timeframe, but other projects took over)