Jump to content


Photo
- - - - -

Cai Webcontrol Email notification


  • Please log in to reply
30 replies to this topic

#1 siafu

siafu

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 123 posts

Posted 25 August 2011 - 01:33 PM

Hello everyone.

I have a couple Cai Webcontrol boards, I use them for several things like to remotely open my front door, control lights inside via the x10 features, control lights outside via a photo resistor.

I've been able to do this with the help of the great folks at CAI networks.

Unfortunately I've ran into a snag, I've been trying to figure a way to also be notified when some events happen, such as when the lights go on and off outside, I would like to set it up to send me an email. I have some basic understanding of this, but can't figure out how to get it to work properly.

What I need to have happen is this.

When OP1 is set to 1 (on) I want one email (email 1 to be sent)

When OP1 is set to 0 (off)I want one email (email 2 to be sent)

The folks at Cai tried to help, but the explanation was to complicated for me.

Can someone here with a lot more experience with the programing of this device help me with the above setup?

Below is what i have set up now, but the email part does not work.

START
TSTLT AIP1 20
CALLSUB LIGHT_ON
TSTGT AIP1 30
CALLSUB LIGHT_OFF
NOP
SET RAM2 0
LOOP:
TSTGT OP1 0 RAM1
TSTGT RAM1 0 RAM1
GOTO SEND
SET RAM2 0
GOTO LOOP
END

LIGHT_ON:
SET OP1 1
RET

LIGHT_OFF:
SET OP1 0
RET

SEND:
BNZ RAM2 LOOP
SET RAM2 1
EMAIL EM1
GOTO LOOP


Thank you in advance for any help.

#2 CAI_Support

CAI_Support

    Cocoonut

  • Manufacturers
  • PipPipPipPip
  • 1357 posts

Posted 25 August 2011 - 02:11 PM

It seems you have already read the example from WebControl user guide. The example in User Guide was for sending one email. If you want to send two different emails, you should have two separate sub-routines.

TSTGT OP1 0
CALLSUB sendmailON

TSTEQ OP1 0
CALLSUB sendmailOFF

The first test to check if OP1 is ON. If it is one, the TSTGT (Test Greater Than) will execute next line, which is CALLSUB sendmail1; If not, it will skip that CALLSUB line and move to next line.

Now the logic will constantly checking the OP1 status and sending emails out. To make WebControl only send one email when the OP1 change state, you will need to have two variables to remember the state of each sending email. You can use RAM1 and RAM2 as the flag varaible for that purpose. In your two sendemail routines, you can put them in this way:

SENDMAILON:
BNZ RAM1 LOOP
SET RAM1 1
EMAIL EM1
GOTO LOOP
RET

SENDMAILOFF:
BNZ RAM2 LOOP
SET RAM2 1
EMAIL EM2
GOTO LOOP
RET


You can see once the subroutine is called, it first check if flag RAM1 and RAM2 already set. If set, then just braches to LOOP.
Next line will set the flag. This will prevent more than one email being sent.

Now, you will need to reset the flag, so that it will send next email when OP1 changing state. In the example in the user guide, the reset was done in the main loop.
In this situation, you want to send one email at the OP1 on and one email at OP1 off. You will need to find a place where you know the OP1 is on to reset the RAM2 and where you know OP1 is OFF to reset RAM1. One place will be in the sendmail routines, where you can be sure the state changed.

SENDMAILON:
BNZ RAM1 LOOP
SET RAM1 1
EMAIL EM1
SET RAM2 0
GOTO LOOP
RET

SENDMAILOFF:
BNZ RAM2 LOOP
SET RAM2 1
EMAIL EM2
SET RAM1 0
GOTO LOOP
RET

At the begining, you may also want to set RAM1 and RAM2 to zero. Hope this helps.

CAI Support

#3 Lou Apo

Lou Apo

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2614 posts
  • Location:Austin TX
  • Experience:average
  • Hardware:ISY-99
  • Tech:INSTEON
  • Audio:Custom
  • Video:Windows Media Center
  • CCTV:analog, dvr

Posted 25 August 2011 - 02:25 PM

Welcome siafu. I hope you get as much out of this site as I do.

Hopefully the answer above settles your email issue as I am going to take it off topic.

How exactly have you got the cai running x10 devices? What interface are you using and how did you wire it up?

#4 CAI_Support

CAI_Support

    Cocoonut

  • Manufacturers
  • PipPipPipPip
  • 1357 posts

Posted 25 August 2011 - 03:15 PM

Hi Lou,

You can control X10 by attaching a RF transmitter, like X10 keychain, or remote, or firecracker.
http://www.cainetwor...bControlX10.pdf

It will act like palm remote, with no limit to a single house code.
You can call it from PLC logic, wget command line, or integrate with Homeseer system.

CAI_Support

Edited by CAI_Support, 25 August 2011 - 03:16 PM.


#5 Lou Apo

Lou Apo

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2614 posts
  • Location:Austin TX
  • Experience:average
  • Hardware:ISY-99
  • Tech:INSTEON
  • Audio:Custom
  • Video:Windows Media Center
  • CCTV:analog, dvr

Posted 25 August 2011 - 03:45 PM

Hi Lou,

You can control X10 by attaching a RF transmitter, like X10 keychain, or remote, or firecracker.
http://www.cainetworks.com/products/webcontrol/WebControlX10.pdf

It will act like palm remote, with no limit to a single house code.
You can call it from PLC logic, wget command line, or integrate with Homeseer system.

CAI_Support


Thanks, exact wiring photos, perfect.

#6 CAI_Support

CAI_Support

    Cocoonut

  • Manufacturers
  • PipPipPipPip
  • 1357 posts

Posted 25 August 2011 - 03:53 PM

Some newer X10 keychain remote inside looks different. But I don't know how to insert picture in this forum.

#7 Lou Apo

Lou Apo

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2614 posts
  • Location:Austin TX
  • Experience:average
  • Hardware:ISY-99
  • Tech:INSTEON
  • Audio:Custom
  • Video:Windows Media Center
  • CCTV:analog, dvr

Posted 25 August 2011 - 03:57 PM

Here is another program that would work (I didn't test it but I think it should be good)

START
TSTEQ OP1 1
CALLSUB MAILON
TSTEQ OP1 0
CALLSUB MAILOFF
END

MAILON:
SET RAM2 0
TSTEQ RAM1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM1
SET RAM1 1
RET

MAILOFF:
SET RAM1 0
TSTEQ RAM2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM2
SET RAM2 1
RET

I like doing it this way because it avoids loops. If the only thing this unit is doing is sending those two emails, then loops don't matter, but if you have other tasks, then you would prefer to keep the program flowing through everything. It uses ram1 and ram2 as flags (ram1 is the on flag and ram2 is the off flag). Whenever an email is sent, it flips the flag to the other value which blocks the email from being sent again until the light is switched to the other state. When the light turns to the other state, that flag gets reset so that the next time the light first becomes on/off, that email can be sent once.

NOTE: When you first power up the cai, both ram1 and ram2 will be zero, you will have to cycle the lights once before the program behaves properly.

Edited by Lou Apo, 25 August 2011 - 03:58 PM.


#8 CAI_Support

CAI_Support

    Cocoonut

  • Manufacturers
  • PipPipPipPip
  • 1357 posts

Posted 25 August 2011 - 04:20 PM

Yes, that will work, Lou.
He will only need to insert his original logic after START:

TSTLT AIP1 20
CALLSUB LIGHT_ON
TSTGT AIP1 30
CALLSUB LIGHT_OFF

also put those subroutines somewhere after END

LIGHT_ON:
SET OP1 1
RET

LIGHT_OFF:
SET OP1 0
RET

#9 siafu

siafu

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 123 posts

Posted 25 August 2011 - 04:31 PM

It seems you have already read the example from WebControl user guide. The example in User Guide was for sending one email. If you want to send two different emails, you should have two separate sub-routines.

TSTGT OP1 0
CALLSUB sendmailON

TSTEQ OP1 0
CALLSUB sendmailOFF

The first test to check if OP1 is ON. If it is one, the TSTGT (Test Greater Than) will execute next line, which is CALLSUB sendmail1; If not, it will skip that CALLSUB line and move to next line.

Now the logic will constantly checking the OP1 status and sending emails out. To make WebControl only send one email when the OP1 change state, you will need to have two variables to remember the state of each sending email. You can use RAM1 and RAM2 as the flag varaible for that purpose. In your two sendemail routines, you can put them in this way:

SENDMAILON:
BNZ RAM1 LOOP
SET RAM1 1
EMAIL EM1
GOTO LOOP
RET

SENDMAILOFF:
BNZ RAM2 LOOP
SET RAM2 1
EMAIL EM2
GOTO LOOP
RET


You can see once the subroutine is called, it first check if flag RAM1 and RAM2 already set. If set, then just braches to LOOP.
Next line will set the flag. This will prevent more than one email being sent.

Now, you will need to reset the flag, so that it will send next email when OP1 changing state. In the example in the user guide, the reset was done in the main loop.
In this situation, you want to send one email at the OP1 on and one email at OP1 off. You will need to find a place where you know the OP1 is on to reset the RAM2 and where you know OP1 is OFF to reset RAM1. One place will be in the sendmail routines, where you can be sure the state changed.

SENDMAILON:
BNZ RAM1 LOOP
SET RAM1 1
EMAIL EM1
SET RAM2 0
GOTO LOOP
RET

SENDMAILOFF:
BNZ RAM2 LOOP
SET RAM2 1
EMAIL EM2
SET RAM1 0
GOTO LOOP
RET

At the begining, you may also want to set RAM1 and RAM2 to zero. Hope this helps.

CAI Support



Hello Cai Suport, thank you for your help.

I entered the info you provided, but it didn't work, actually for some reason it even changed things after I saved it.

Please see below.

START
TSTLT AIP1 20
CALLSUB LIGHT_ON
TSTGT AIP1 30
CALLSUB LIGHT_OFF
NOP
TSTGT OP1 0
CALLSUB MAIL_ON
TSTEQ OP1 0
CALLSUB MAIL_OFF
END

MAIL_ON:
BNZ RAM1 MAIL_ON
SET RAM1 1
EMAIL EM1
SET RAM2 0
GOTO MAIL_ON
RET

MAIL_OFF:
BNZ RAM2 MAIL_ON
SET RAM2 1
EMAIL EM2
SET RAM1 0
GOTO MAIL_ON
RET

LIGHT_ON:
SET OP1 1
RET

LIGHT_OFF:
SET OP1 0
RET

#10 siafu

siafu

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 123 posts

Posted 25 August 2011 - 04:40 PM

Hi Lou,

You can control X10 by attaching a RF transmitter, like X10 keychain, or remote, or firecracker.


It will act like palm remote, with no limit to a single house code.
You can call it from PLC logic, wget command line, or integrate with Homeseer system.

CAI_Support



Hello,

X10 works great, have a key chain x10 remote with 3 wires coming from the remote hooked to the webcontrol board, 1 for power , 1 ground, and the other data all 3 wires are hooked to the Cai board and works great. There is a manual where it shows how to do it, CAi Team sent it to you, hope this helps. The only thing is that the codes are a bit different than what they are from x10, I can't remember them, but can get them for you, at least a couple that I use.

#11 siafu

siafu

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 123 posts

Posted 25 August 2011 - 04:57 PM

Yes, that will work, Lou.
He will only need to insert his original logic after START:

TSTLT AIP1 20
CALLSUB LIGHT_ON
TSTGT AIP1 30
CALLSUB LIGHT_OFF

also put those subroutines somewhere after END

LIGHT_ON:
SET OP1 1
RET

LIGHT_OFF:
SET OP1 0
RET


Hello Cai and Lou,

Thank you very much for your help, this is what I have programed now, and it appears to work from what I can tell. I'm not in front of the device, I'm updating this remotely, but as soon as I get in front of the board I will reset it and see if it will work. Will let you know.

START
TSTLT AIP1 20
CALLSUB LIGHT_ON
TSTGT AIP1 30
CALLSUB LIGHT_OFF
TSTEQ OP1 1
CALLSUB MAILON
TSTEQ OP1 0
CALLSUB MAILOFF
END

LIGHT_ON:
SET OP1 1
RET

LIGHT_OFF:
SET OP1 0
RET

MAILON:
SET RAM2 0
TSTEQ RAM1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM1
SET RAM1 1
RET

MAILOFF:
SET RAM1 0
TSTEQ RAM2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM2
SET RAM2 1
RET

#12 Lou Apo

Lou Apo

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2614 posts
  • Location:Austin TX
  • Experience:average
  • Hardware:ISY-99
  • Tech:INSTEON
  • Audio:Custom
  • Video:Windows Media Center
  • CCTV:analog, dvr

Posted 25 August 2011 - 04:58 PM

Hello,

X10 works great, have a key chain x10 remote with 3 wires coming from the remote hooked to the webcontrol board, 1 for power , 1 ground, and the other data all 3 wires are hooked to the Cai board and works great. There is a manual where it shows how to do it, CAi Team sent it to you, hope this helps. The only thing is that the codes are a bit different than what they are from x10, I can't remember them, but can get them for you, at least a couple that I use.


Yes, I would like any pearls of wisdom. Anything to avoid trial and error.

#13 siafu

siafu

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 123 posts

Posted 25 August 2011 - 06:52 PM

Yes, I would like any pearls of wisdom. Anything to avoid trial and error.


The codes I use are 0 and 0 for the first set of buttons on the remote and 0 and 1 for the second set of buttons on the remote.

Attached Files


Edited by siafu, 25 August 2011 - 06:52 PM.


#14 siafu

siafu

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 123 posts

Posted 26 August 2011 - 09:13 AM

Hello Cai and Lou,

Thank you very much for your help, this is what I have programed now, and it appears to work from what I can tell. I'm not in front of the device, I'm updating this remotely, but as soon as I get in front of the board I will reset it and see if it will work. Will let you know.

START
TSTLT AIP1 20
CALLSUB LIGHT_ON
TSTGT AIP1 30
CALLSUB LIGHT_OFF
TSTEQ OP1 1
CALLSUB MAILON
TSTEQ OP1 0
CALLSUB MAILOFF
END

LIGHT_ON:
SET OP1 1
RET

LIGHT_OFF:
SET OP1 0
RET

MAILON:
SET RAM2 0
TSTEQ RAM1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM1
SET RAM1 1
RET

MAILOFF:
SET RAM1 0
TSTEQ RAM2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM2
SET RAM2 1
RET



Hello,

When I got home yesterday, I reset the box but powering off and on. I received email right away saying lights were on, but in fact lights were not on as it was daylight. I left the unit alone. At night time when the lights came on, there was no email sent. This morning when lights went off, I received an email saying lights were on.

Any idea why the above code is not sending me the emails?

Thanks you again for all your help.

#15 Lou Apo

Lou Apo

    Cocoonut

  • Registered
  • PipPipPipPip
  • 2614 posts
  • Location:Austin TX
  • Experience:average
  • Hardware:ISY-99
  • Tech:INSTEON
  • Audio:Custom
  • Video:Windows Media Center
  • CCTV:analog, dvr

Posted 26 August 2011 - 09:43 AM

As I mentioned, you need to cycle the lights once before this program works properly.

Do you have em1 as the "on" email and em2 as the "off" email? It sounds like you have it backwards.

It would greatly shorten your testing phase if you would manually turn the lights on/off a few times to check behavior.

Edited by Lou Apo, 26 August 2011 - 09:45 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users