Author |
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 13 2005 at 04:06 | IP Logged
|
|
|
Oh, a second question: What happens when A1 Off stays away and when there is a REAL firealarm.... (when the smokedetectors no longer see smoke they send an A1 Off...read: A1 on is sent when smoke is detected and only when the sky is clear an A1 off will be sent...) I am not sure I am reading this sql correctly...
Peter
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 13 2005 at 14:25 | IP Logged
|
|
|
Hmmmm...let me see if I have it right. When a real firealarm is detected, A1 On is sent (smokedetector detects smoke). After the smoke clears, an A1 Off is sent (no smoke).
So in your earlier situation with the ghost alarm, an A1 On was sent and within two seconds, an A1 Off was sent (Basically not a real situation hence the ghost alarm).
If this is the case, you don't want to fire the alarm macro unless A1 has been On for more than two seconds.
In this situation, I would just create a trigger for A1 on. I would have it fire the Alarm macro. The first line of the macro would be Wait for 2 seconds. The next line would then check the status of A1. If it's off (an A1 off was received within two seconds of the A1 on), then I would just exit the macro. If A1 is ON (has been on for at least 2 seconds) then continue with the rest of the macro which sounds an alarm, sends email, etc.
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 14 2005 at 04:54 | IP Logged
|
|
|
dhoward wrote:
Hmmmm...let me see if I have it right. When a real firealarm is detected, A1 On is sent (smokedetector detects smoke). After the smoke clears, an A1 Off is sent (no smoke). |
|
|
Yes, that is right... I like your previous sql-post and hope I am able adapt this into a situation where first a check is done to see if A1ON and an A1OFF is received and then the alarm is handled as an entry in the log being a ghost or test... If A1OFF stays away, a real alarm will be the case...
Quote:
So in your earlier situation with the ghost alarm, an A1 On was sent and within two seconds, an A1 Off was sent (Basically not a real situation hence the ghost alarm).
|
|
|
Yes, that is right... when smoke is detected, an A1ON is sent and only after the sky clears, an A1OFF is sent, so nothing is sent in between....
Quote:
If this is the case, you don't want to fire the alarm macro unless A1 has been On for more than two seconds.
In this situation, I would just create a trigger for A1 on. I would have it fire the Alarm macro. The first line of the macro would be Wait for 2 seconds. The next line would then check the status of A1. If it's off (an A1 off was received within two seconds of the A1 on), then I would just exit the macro. If A1 is ON (has been on for at least 2 seconds) then continue with the rest of the macro which sounds an alarm, sends email, etc.
|
|
|
Yes, I have been trying this however in the time the macro waits, the status of A1 is not updated... I think this has to do with the fact that my PC where PH runs on is actually too slow for this job... I have a spare PIII at 500 mHz so I think I am going to transfer PH to this machine. It Should not be difficult because there is e new version so i think if is best to install the new version on the PIII and copy the INI and the Database.. Hopefully the regitration information will be taken along with it... I don't think I have a registration for more than 1 PC....
Peter
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 14 2005 at 11:03 | IP Logged
|
|
|
Peter,
Check out the SQL below, I think it's close to what you want:
insert into triggers values ('A1ON','A1ON','FIREALARM',4,'A',1,2,'1',1,0,0);
insert into macroheader values ('FIREALARM','FIRE ALARM',0,0,1);
insert into macrodetail values ('FIREALARM',1,31,'',NULL,'5',0);
insert into macrodetail values ('FIREALARM',2,27,'',NULL,'if(ph_getx10stat("A",1) = 1,"GHOST","ALARM")',0);
insert into macrodetail values ('FIREALARM',3,26,'',NULL,'GHOST',0);
insert into macrodetail values ('FIREALARM',4,36,'',NULL,'"Fire Alarm ghost alarm detected."',0);
insert into macrodetail values ('FIREALARM',5,39,'',NULL,'',0);
insert into macrodetail values ('FIREALARM',6,26,'',NULL,'ALARM',0);
insert into macrodetail values ('FIREALARM',7,37,'',NULL,'Do whatever is necessary for the fire alarm after this comment.',0);
It consists of a trigger and a macro. When an A1 ON signal is received, it triggers the FIREALARM macro. The macro immediately waits for 5 seconds (waits vs delay...a delay pauses all processing including receiving X-10 commands...a wait doesnt). I upped the time from 2 seconds to 5 seconds because each X-10 command takes almost a second. Also, depending upon the controller you're using, it may buffer received commands before sending them (which may also be contributing to your problem).
After waiting for 5 seconds, the macro checks the status of A1. If it is off (an A1 off was received within 5 seconds of being turned on), then a message is posted to the eventlog that this is a "ghost" alarm and the macro exits. If the status of A1 is still ON (or unknown), then the macro continues to normal fire alarm processing.
It's probably not necessary to upgrade your PC (but...faster is always better) as your problem is most likely related to the inherent slowness of X-10 commands and possible some controller delay (CM11A). However, if you wish to do so, then just copy your pwrhome.db and pwrhome.ini files. The registration will move along with the database.
HTH,
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 15 2005 at 01:23 | IP Logged
|
|
|
Dave,
Hey I like this one... it was similar to what I have been brewing yesterday but I held on to these 2 seconds... as well as the fact that in some strange way I could not get the status to update inside the macro but that also traces back to these 2 seconds.... I am going to test this macro Saturdaymorning....
Peter
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 15 2005 at 13:16 | IP Logged
|
|
|
Let us know how it goes.
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 16 2005 at 05:18 | IP Logged
|
|
|
Dave,
I have some more info: When A firealarm is given, the file still exists (templcd.txt) however, I can't make any changes to PH.... I can make changes again only when I have restarted PH... I am going to transfer PH (new version 44) onto my spare PIII... The Pentium it runs on now is becoming too slow... As soon as it is finished, I'll let you know
Peter
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 19 2005 at 07:16 | IP Logged
|
|
|
Hey you formula wizards out there!!!
Could this formula work or do you 2 wizz have a shortcut?
case (len (mid("{SENSOR3}",1 ,4)) when 3 then ph_setglobal_s("S3",{SENSOR3}/10) when 2 then ph_setglobal_s("S3",{SENSOR3}) when 1 then ph_setglobal_s("S3",{SENSOR3}) else ph_setglobal_s("S3",{SENSOR3}/100))
Peter
Edited by krommetje
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 19 2005 at 11:13 | IP Logged
|
|
|
Well, it's pretty concise now...but you could tighten it up a little.
ph_setglobal_a("S3",case(len("{SENSOR3}") when 1,2 then {SENSOR3} when 3 then {SENSOR3} / 10 else {SENSOR3} / 100))
I tried to come think of a way to do it mathematically, but nothing really came to mind.
Since you're only concerned with values 1,2,3 and anything else, I pulled out the mid statement. You'll also see that since every case you're setting the global S3, I pulled it out in front. The other thing is with the case statement, you have a wide range comparisons that can be mixed and matched so I used the 1,2.
The last thing I did was use ph_setglobal_a instead of ph_setglobal_s. I didnt actually check your formula to see if it would work, but since you are using math, the result should be numeric and the ph_setglobal_s shouldnt work.
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 20 2005 at 08:50 | IP Logged
|
|
|
dhoward wrote:
Well, it's pretty concise now...but you could tighten it up a little. |
|
|
The Idea behind this formula is, due to an earlier discussed flaw in the gameporttemp.exe webserver, to check when a value is returned if it is 2, 3 or 4 digits. When the value is X digits long then a math function is performed to have it returned as a numeric value as xx.xx
To have this stored as a GV I can easily make rules with them concerning how high a certain temperature may reach and when this limit has been reached a mail being sent or an action is performed...
Peter
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 27 2005 at 07:46 | IP Logged
|
|
|
Hi all,
I have thought of a plan to assign virtualX10 devices to 2 devices in my home in which the temperatures are meassured.
The temperatures are stored as described earlier in this thread, but now I want to calculate the difference between the temperatures and when a temperature is rising the virtualX10 device its status has to be set to On... when the temperature is lower, then the Status has to be set to off, however.. if the difference is lower then 3 degrees celcius then nothing is done... for this I have been brewing on some formulas... please think with me....
ph_setglobal_a("S0HIST", "{S0}") Here a GV S0HIST is set just before the new value is stored...
ph_setglobal_a("S0DIFF", "{S0}"-"{S0HIST}") Here a GV is set as S0DIFF...the diffence between the two temps
case (sign("{SODIFF}" when 1 then case("{S0DIFF}" > 3 then ph_x10setstat(2,"V", 1, 0, 0) when -1 then case("{S0DIFF}" < 3 then ph_x10setstat(1,"V", 1, 0, 0))
The meaning of this code is that when the temp is rising, thus being the sign a + then the status has to be set to on when the value of S0DIFF is above 3, when the temp is falling and the sign being a - the status has to be set to Off when the value is above 3
However: If the status is already the same the status that has to be set, then nothing has to be done...
How can I combine all of this into one formula for 2 VirtualX10 devices being V1 and V2?
Am I on the right track here?
Peter
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 29 2005 at 13:18 | IP Logged
|
|
|
Peter,
Im sure I can help with the formulas, but don't think I quite understand the problem enough.
What I understand so far...you're going to monitor one of your temperatures. If the temperature is rising and the difference is greater than 3 degrees, then set a virtual X10 on. If the temperature is falling and the difference is greater than 3 degrees, then set the vitual X10 off. Basically, you're going to monitor two temperatures with two virtual X10 devices and you want it all combined into 1 formula.
The problem that I see with what you have so far is measuring the differences. You've got a variable that stores the last measured value and you're returning the difference between that and the current measured value. The problem here is that if the temperature changes slowly (less than 3 degrees between readings) you'll never change the status. Is this what you want?
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 29 2005 at 13:46 | IP Logged
|
|
|
dhoward wrote:
What I understand so far...you're going to monitor one of your temperatures. If the temperature is rising and the difference is greater than 3 degrees, then set a virtual X10 on. If the temperature is falling and the difference is greater than 3 degrees, then set the vitual X10 off. Basically, you're going to monitor two temperatures with two virtual X10 devices and you want it all combined into 1 formula. |
|
|
Yes that is right; once the temp is rising and above 3 degrees, then the virt.x10 must be set to on.... When the temp is falling above 3 degrees, the VirtX10 must be set to off.... preferably in 2 seperate formulas for S0 and S3. The formula-parts I have so far work great but it seems I am unable to substract 2 GV's directly (or at least I don't know how, let's keep it at that) The 3 degrees is not an isue, if you think it is better with 1 then we'll make it 1....
Quote:
The problem that I see with what you have so far is measuring the differences. You've got a variable that stores the last measured value and you're returning the difference between that and the current measured value. The problem here is that if the temperature changes slowly (less than X degrees between readings) you'll never change the status. Is this what you want? |
|
|
Well, the temps measured are from the solar-collector and the centrale heating system, so if these temps change it'll be with degrees per minute and not to have any large amount status-changes within a minute......
Do my brewings help you in any way?
Peter
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: April 30 2005 at 07:41 | IP Logged
|
|
|
Hi you all,
I have been brewing on some formulas and haven't got this working ... I wanted to make a difference between a negative and a positive number using the following piece of sql:
Code:
insert into macrodetail values ('TEST-TEMP',8,38,'',0,'ph_setglobal_a("S0HIST", "{S0}")',0);
insert into macrodetail values ('TEST-TEMP',9,38,'',0,'ph_setglobal_a("S0",case(len("{SENSO R0}") when 1,2 then {SENSOR0} when 3 then {SENSOR0} / 10 else {SENSOR0} / 100)) ',0);
insert into macrodetail values ('TEST-TEMP',10,38,'',0,'ph_setglobal_a("S0DIFF", dec("{S0}")- dec("{S0HIST}"))',0);
insert into macrodetail values ('TEST-TEMP',11,38,'',0,'case(sign(number("{S0DIFF}")) when -1 then ph_x10setstat(1,"V", 1, 0, 0))',0);
insert into macrodetail values ('TEST-TEMP',12,38,'',0,'case(sign(number("{S0DIFF}")) when 1 then ph_x10setstat(2,"V", 1, 0, 0))',0);
|
|
|
but this is not watertight.... a rising temperature is detected however a falling temperature is not.... sometimes the difference between the temperatures are as low as 0.02 degrees....or sometimes a difference is detected but the Status of the virtual X10 devices is not updated...
Peter
Edited by krommetje
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: May 01 2005 at 07:21 | IP Logged
|
|
|
here is a small update:
I have been programming some code when the actual temperatures are monitored, when the solar-collector and the central heating reach 30 degrees or higher then the 2 corresponding virtual-x10 are switched on. As soon as they reach below 30 degrees they are switched off.... i've been doing this with the case statement:
case (dec("{S0}") when is 30 to 90 then ph_x10setstat(2,"V", 1,0,0))
and for the central heating the same but then for Virtual-X10 W1
the formulas are executed every 15 minutes...
This is however not as precise as I would like... It takes about 3 hrs to cool down when the status is ON when it should be off.. Also the actual switching off of the virutalX10 is not always done and the status stays ON....
Peter
Edited by krommetje
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: May 02 2005 at 15:13 | IP Logged
|
|
|
Peter,
I know you're in the process of making changes to your code and such so Im not sure where you're currently at. From your last post though, you say you use a "CASE" statement to turn the virtual X-10 off and further state that the status always stays ON. Can you post the code that turns the virtual off? (The case statement you posted only turns it on).
Also, you state the formulas are executed every 15 minutes. Are you doing this with timed events, wait statements, etc?
Also, how often are you refreshing the temperatures (and what method)? I would probably execute the formulas based upon the temperatures at the same time that I update the temperatures.
I also imported your macro from the post before last. One thing you should make sure of is that when using the - (minus sign), you should ALWAYS have a space preceeding and a space after. PowerBuilder (the language PowerHome is written in) is quirky concerning the minus sign in formulas since the language allows you to include the dash character in identifiers and variables. So always use a statement like - 1 instead of -1 and also ,- 1 should be , - 1. Sometimes it works even without the spaces but I can tell you from past experience tracing the most perplexing problems for hours on end and then finding that adding the single space before fixes everything.
Also, on the macro...one error I did catch was the statement ph_x10setstat(1,"V", 1, 0, 0). The command you're using here is 1 which equates to X-10's "All Lights On". If you were wanting to set the status to "OFF", then the proper command would be a value of 3.
Hope this helps,
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: May 02 2005 at 17:34 | IP Logged
|
|
|
dhoward wrote:
I know you're in the process of making changes to your code and such so Im not sure where you're currently at. |
|
|
I am currently testing some things out, however to get an accurate status change, I think I still have to remain with my original idea to check the difference in the temperatures...
where I am at is this:
For my solar collector the whole thing works, every 15 minutes the things are done as you can read in the following part of this post...
For my Central Heating system I can't get the same to work. For a strange reason the status is not updated...
It is like the formula is executed once and then ignored
The temps are imported OK and shown OK in PH...
Quote:
From your last post though, you say you use a "CASE" statement to turn the virtual X-10 off and further state that the status always stays ON. Can you post the code that turns the virtual off? (The case statement you posted only turns it on). |
|
|
yes, you are right, I forgot to include the off statement as well... The solar collector (SC) is switched off OK... However, the cooling down period is several hours so to get an acurate status this doesn't have "enough resolution" When the SC is switched off it keeps on pumping it's water into the system to get the most out of the restheat....
Quote:
Also, you state the formulas are executed every 15 minutes. Are you doing this with timed events, wait statements, etc? Also, how often are you refreshing the temperatures (and what method)? I would probably execute the formulas based upon the temperatures at the same time that I update the temperatures. |
|
|
yes, that is what is happening, by executing timed event every 15 minutes however the actual temps are updated every 3 minutes, just before the temps are updated, the HIST GV is set, then the new temps are set and then the formula's (like setting the difference e.g.) are executed. However any help on my first idea to measure the difference and then change the status when the difference is - or + indicating rising temp or lowering temp is welcome... the 3 degrees-story, I'll forget because the solar-collector e.g. takes about 5 hrs to cool down so that doesn't go with degrees per minute.. the solar-heat is stored in GEL in the device itself... Measuring the incoming water-temp is a better reading because the temp of the gel is in the morning still 50 to 60 degrees...
Quote:
I also imported your macro from the post before last. One thing you should make sure of is that when using the - (minus sign), you should ALWAYS have a space preceeding and a space after. |
|
|
thanks for the advice...
Quote:
Also, on the macro...one error I did catch was the statement ph_x10setstat(1,"V", 1, 0, 0). The command you're using here is 1 which equates to X-10's "All Lights On". If you were wanting to set the status to "OFF", then the proper command would be a value of 3.
|
|
|
I found that out just this morning when browsing through the help-file... dumb error on my part...
Peter
Edited by krommetje
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: May 03 2005 at 13:38 | IP Logged
|
|
|
Peter,
Ok, Ive slightly reworked the SQL for your TEST-TEMP macro above and have the new SQL below:
insert into macroheader values ('TEST-TEMP','TEST',0,0,1);
insert into macrodetail values ('TEST-TEMP',1,38,'',0,'ph_setglobal_a("S0HIST", "{S0}")',0);
insert into macrodetail values ('TEST-TEMP',2,38,'',0,'ph_setglobal_a("S0",case(len("{SENSO R0}") when 1,2 then {SENSOR0} when 3 then {SENSOR0} / 10 else {SENSOR0} / 100)) ',0);
insert into macrodetail values ('TEST-TEMP',3,38,'',0,'ph_setglobal_a("S0DIFF", dec("{S0}") - dec("{S0HIST}"))',0);
insert into macrodetail values ('TEST-TEMP',4,38,'',0,'case(sign(dec("{S0DIFF}")) when - 1 then ph_x10setstat(3,"V", 1, 0, 0) when 1 then ph_x10setstat(2,"V", 1, 0, 0) else 0)',0);
I also caught one more error in the first macro detail line where you misspelled the GV with an extra space character:
Quote:
case(len("{SENSO R0}") when |
|
|
.
I checked the above macro and it works no problem for me on both negative and positive S0DIFF values.
Dave.
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: May 04 2005 at 12:27 | IP Logged
|
|
|
I have been mindbreaking over some more code... What I want to do is use your enhanced sql but then check wether to see that if the S0DIFF is in the range between -1 and 1 first the status of the device is checked, and when then the current status only has to be updated.... Could the following code work?
case (dec("{S0DIFF}") when -1 to 1 then if( [X10STATV1] = 1, 'ph_x10setstat(3,"V",1,0,0)', 'ph_x10setstat(2,"V",1,0,0)'else case(sign(dec("{S0DIFF}")) when - 1 then ph_x10setstat(3,"V", 1, 0, 0)
when 1 then ph_x10setstat(2,"V", 1, 0, 0) else 0))
Do you understand what I want and could the above code work?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: May 04 2005 at 15:43 | IP Logged
|
|
|
Peter,
Im couldnt quite get the gist of what you were saying . In any event, I checked the formula and some things didnt make sense (to me).
1. When the "SODIFF" is in the range of - 1 to 1, then execute the "if" statement that checks the current status. In your "if" statement, you check if the current status is OFF, then set the status to "OFF", else set the status to "ON".
You're probably wanting to switch the setstat statements (turn it on if off and turn it off if on). If this is want you were trying for, I probably wouldnt fool with it. The ph_x10setstat statement directly updates the database and bypasses any triggers so you wouldnt really gain anything by only setting the stat if it's different. This is probably the part I don't understand...Im not sure why you would want to toggle the status if the difference (whether rising or falling) is the same or within 1 degree.
Another important point is that in the "if" statement, the true and false actions should not "strings". The statement should look like:
if([X10STATV1] = 1,ph_x10setstat(2,"V",1,0,0),ph_x10setstat(3,"V",1,0,0))
Dave.
|
Back to Top |
|
|
|
|