Cai Webcontrol Email notification

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.


Hello Lou,

Emails are set correctly, please see attached screen capture.

I turned the lights on manually, just now, OP1 is at 1, and no email.

When I turn lights Off, OP1 is at 0, I get two emails, however they are not the correct emails, please see attached.

Any idea?
 

Attachments

  • 1.jpg
    1.jpg
    28.5 KB · Views: 0
  • 2.jpg
    2.jpg
    20.5 KB · Views: 0
You could try using VAR1 and VAR2 instead of ram1 and ram2 so you can watch that the values change 0/1 as appropriate.

I don't know what all of those backwards "r" are. Never seen that.

I followed the logic of the program and it should work. Perhaps try a factory reset of the cai and copy/paste the program back in. That funky backward r thing makes me think something screw is going on.

Also, hit the "send test email" for each of the two emails and be sure you are getting what you should be getting. Keep in mind that email servers make take 5 minutes to pass things through to you.

I am assuming that the program you listed above is everything on the plc.
 
You could try using VAR1 and VAR2 instead of ram1 and ram2 so you can watch that the values change 0/1 as appropriate.

I don't know what all of those backwards "r" are. Never seen that.

I followed the logic of the program and it should work. Perhaps try a factory reset of the cai and copy/paste the program back in. That funky backward r thing makes me think something screw is going on.

Also, hit the "send test email" for each of the two emails and be sure you are getting what you should be getting. Keep in mind that email servers make take 5 minutes to pass things through to you.

I am assuming that the program you listed above is everything on the plc.


Hi Lou,

I don't know either,

When I hit the send email Test, both emails come instantaneously, both correct.

Program listed is correct, please see below again just to make sure.So basically I should change RAM1 and RAM2 with VAR1 and VAR2 on all entries (where RAM is)? Where do I watch this code change then. Sorry kind of new to this programing and really appreciate your help.

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
 
Yes on the ram/var thing. On the status page you will see "32 bit signed var" and then a spot for 8 values. Assuming you have never used the variables before, they should all be zero right now. Then you can follow the variables change back and forth (values of variables can be seen where ram values are hidden).

As soon as you turn the light off, it should send an email and set var2 to 1 and set var1 to 0. The opposite should happen when you turn the light on.

I still think you should do a factory reset and redo all the network config page and email config page and then cut and paste the program back in. Those backward r's don't have any logical explaination.
 
Yes on the ram/var thing. On the status page you will see "32 bit signed var" and then a spot for 8 values. Assuming you have never used the variables before, they should all be zero right now. Then you can follow the variables change back and forth (values of variables can be seen where ram values are hidden).

As soon as you turn the light off, it should send an email and set var2 to 1 and set var1 to 0. The opposite should happen when you turn the light on.

I still think you should do a factory reset and redo all the network config page and email config page and then cut and paste the program back in. Those backward r's don't have any logical explaination.

Hello Lou

Chamged all RAM to VAR and all appears to behave as per what you mentioned hower emails still act the same way.
I should mention that a while back I fried all the digital inputs on this particular board, CAI knows about it and said that the board was protected from beng damanged by a chip, so only thing that don,t work at all on this board from what I was able to tell is the digital inputs, maybe this has something to do with my issues now? Perhaps the folks from Cai can assist here?

I'm on my way to work now but will reset the board tonight when I get home, as I would like to get this working if at all possible.

Thanks again for all your help.
 
At least we have confirmed the program logic is properly working.

Perhaps that "frying" event did something screwy. Another suggestion would be to try using different email slots, like maybe 3 and 4 instead of 1 and 2. You might just put em1, em2, em3, etc as the subject line for each email. Then try putting different numbers in your programs and see what shows up. It might be that the damage is causing the unit to address the wrong emails.
 
At least we have confirmed the program logic is properly working.

Perhaps that "frying" event did something screwy. Another suggestion would be to try using different email slots, like maybe 3 and 4 instead of 1 and 2. You might just put em1, em2, em3, etc as the subject line for each email. Then try putting different numbers in your programs and see what shows up. It might be that the damage is causing the unit to address the wrong emails.


Hello Lou,

I changed the email slots, from 1 and 2 to 7 and 8.

I no longer get the reversed RRRRRRRRRRRRRRRRRRRRRRRRRRRR

However, still not working properly,

When I have OP 1 to 1 no email is being sent.

Minutes later when I set OP1 to 0 I get two emails. But both emails are from Email 7 (the one that has the text Building Light ON

Looking at 1st email it appears that this email was generated when the OP1 was set to 1

Second email shows that was generated when OP1 is set to 0.

Both emails are being sent at the same time.

It appears that the first email is being generated correctly, as it is being created as it should when OP1 is set to 1, but not being sent.

The second email is not correct, as it should be sent from email 8 the OFF email, but still email 7 the ON is being sent.

Could it be something in the code, it could be that it never reaches email 8 the off email, and email 7 the ON email gets triggered twice for some reason.

again I'm just reporting what I'm seeing like I said before this is all new to me and trying to learn, and want to thank you for your help, and understanding.
 
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 var2 0
TSTEQ var1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM1
set var3 1
SET var1 1
RET

MAILOFF:
SET var1 0
TSTEQ var2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM2
set var4 1
SET var2 1
RET

I added a flag in the program above. It will set var3 to 1 when "mailon1" is executed and var4 will become 1 when "mailoff1" is executed. After turning the lights on/off once you should see both of those turn to 1 (they will stay one so you only get to do this test once) I don't know what firmware you have, but if it isn't the latest, the only way to reset the variables to 0 is by writing plc code to do it. The latest version you can type in the following:

http: //your.ip.address//api/setvar.cgi?varid=1&value=23456789

where the underlined numbers are the variable you want to change and the value you want to make it. Please note: I added a space between http: and the slashes so that the forum wouldn't alter it.

First, turn the lihgt off. Don't restart your cai unit, just copy/paste the code from above in. Your var1 and var2 should still read 0 and 1. var3 and var4 should both read zero. Then turn the lihgt on. Var3 should become 1. Then turn the light off, var4 should become 1. If this happened, then there is something wrong with the email part of your cai since in both cases the very next line is to send an email.

The only other thing could be that somewhere along the line, cai changed the language you use to send emails. If you have an older firmware, you may need to use the different commands.
 
Hi siafu,


Could you please set email first by saying subject1, messagebody1, subject2, message body2, etc, in all 8 of thememail message setup screen. Then try to send test email one by one, wait to receive the first one, then send next one, to see which one was being sent. You then watch them sending in PLC program. In some older version firmware, the EM1 was not interpreted correctly. So that when you specify in PLC code "EMAIL 1" you would get the first email. "EMAIL EM1" may give you email #8.

In the latest firmware, we have changed to match the user manual and usage. For any new firmware, should always use "EMAIL EMx" format. For older boards, using "EMAIL x" format.
 
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 var2 0
TSTEQ var1 0
GOTO MAILON1
RET

MAILON1:
EMAIL EM1
set var3 1
SET var1 1
RET

MAILOFF:
SET var1 0
TSTEQ var2 0
GOTO MAILOFF1
RET

MAILOFF1:
EMAIL EM2
set var4 1
SET var2 1
RET

I added a flag in the program above. It will set var3 to 1 when "mailon1" is executed and var4 will become 1 when "mailoff1" is executed. After turning the lights on/off once you should see both of those turn to 1 (they will stay one so you only get to do this test once) I don't know what firmware you have, but if it isn't the latest, the only way to reset the variables to 0 is by writing plc code to do it. The latest version you can type in the following:

http: //your.ip.address//api/setvar.cgi?varid=1&value=23456789

where the underlined numbers are the variable you want to change and the value you want to make it. Please note: I added a space between http: and the slashes so that the forum wouldn't alter it.

First, turn the lihgt off. Don't restart your cai unit, just copy/paste the code from above in. Your var1 and var2 should still read 0 and 1. var3 and var4 should both read zero. Then turn the lihgt on. Var3 should become 1. Then turn the light off, var4 should become 1. If this happened, then there is something wrong with the email part of your cai since in both cases the very next line is to send an email.

The only other thing could be that somewhere along the line, cai changed the language you use to send emails. If you have an older firmware, you may need to use the different commands.

Hello Lou,

This is the version I have

Version: v03.01.03

Can it be reset with the http link?
 
Hello Lou,

This is the version I have

Version: v03.01.03

Can it be reset with the http link?

I get this error when try to reset via the http method.

404: File not found
Use MPFS Upload to program web pages

404: File not found
Use MPFS Upload to program web pages
 
I don't think so. I have the latest which is 3.01.07 and I believe that it is the first version with that feature. Won't hurt to try.

You can use get commands on that firmware however.

http:// your.ip.address/getall.cgi or instead of getall you can do getvar1, gett1, and that sort of stuff.

The older language for emails was

EMAIL 1 (to send email from 1 location) not
EMAIL EM1 (as it is in the newer firmware)

You can try that.
 
I don't think so. I have the latest which is 3.01.07 and I believe that it is the first version with that feature. Won't hurt to try.

You can use get commands on that firmware however.

http:// your.ip.address/getall.cgi or instead of getall you can do getvar1, gett1, and that sort of stuff.

The older language for emails was

EMAIL 1 (to send email from 1 location) not
EMAIL EM1 (as it is in the newer firmware)

You can try that.


BINGO IT WORKS now, it was the EMAIL format as you said.

So now if I wanted to upgrade to the latest and greatest firmware what are the benefits?

If I upgrade to the latest firmware, will it reset VAR 3 and 4 to zero automatically?

Thank you for your help with this greatly appreciate it.
 
BINGO IT WORKS now, it was the EMAIL format as you said.

So now if I wanted to upgrade to the latest and greatest firmware what are the benefits?

If I upgrade to the latest firmware, will it reset VAR 3 and 4 to zero automatically?

Thank you for your help with this greatly appreciate it.

Good to hear. I don't know why they changed the language for emails, but it screwed me up as well but in the opposite way (I was writing for the old firmware and I actually had the new firmware).

The newer firmware fixes some problems with using "state inverted" mode and it adds the ability to set variables using a rest interface. It may have other changes, but that is all I know of. You probably don't need the upgrade as I don't think you will be using either of those things.

Variables and Ram values never "automatically" reset. You wouldn't want that. They are meant to store a value for future use, so resetting them would be something that you would want to specifically ask for, not an automatic event. If you look at the program, I have written in the "reset" when it sets the value back to zero after the light gets flipped to the other state. You should go ahead and delete the var3 and var4 stuff I added, that was just for diagnostics. If you want to set them back to zero, just put two lines in after start
set var3 0
set var4 0

save it
then go back and delete those two lines.

RAM values stay in memory for as long as power is on and variables survive power cycles. If you aren't needing the variables for anything else, then I would continue to use them instead of ram values just for the power cycle thing.

EDIT: I think I might be wrong on teh power cycle. I think you lose var values as well. I think the only advantage to var values is that you can see them and query them from a rest interface.
 
Good to hear. I don't know why they changed the language for emails, but it screwed me up as well but in the opposite way (I was writing for the old firmware and I actually had the new firmware).

The newer firmware fixes some problems with using "state inverted" mode and it adds the ability to set variables using a rest interface. It may have other changes, but that is all I know of. You probably don't need the upgrade as I don't think you will be using either of those things.

Variables and Ram values never "automatically" reset. You wouldn't want that. They are meant to store a value for future use, so resetting them would be something that you would want to specifically ask for, not an automatic event. If you look at the program, I have written in the "reset" when it sets the value back to zero after the light gets flipped to the other state. You should go ahead and delete the var3 and var4 stuff I added, that was just for diagnostics. If you want to set them back to zero, just put two lines in after start
set var3 0
set var4 0

save it
then go back and delete those two lines.

RAM values stay in memory for as long as power is on and variables survive power cycles. If you aren't needing the variables for anything else, then I would continue to use them instead of ram values just for the power cycle thing.

EDIT: I think I might be wrong on teh power cycle. I think you lose var values as well. I think the only advantage to var values is that you can see them and query them from a rest interface.

Hello Lou,

I rest unplugged and re plugged in the board, but the VAR stayed the same, so it appears that it holds in memory.

I removed the SET VAR 3 and 4 from the program, but set them to 0 before removing them.

Everything appears to work as intended now, thank you very much for all your help.
 
Back
Top