Hi everyone,
I've just came up with a solution to my problem. There are other ways to do it but i've just wanted to share my solution.
I've tested the solution with alternating changes in the trigger signal and it works great.
System that monitors an electronic circuit and sends a notification when it changes state.The problems is that sometimes changes are too rapid and too many in a short term but usually the system changes state few times a day.
The rapids changes are probably due to switches bouncing or undesirable states.
Program that checks the reception of an On/OFF X10 command and send a Notification of the new status
after sending the notification, a debounce window prevents further notification but the current status is still updated
After the debounce timer the current status, if changed will trigger another Notification with its debounce period
Programs 1 &2 keep the current status in a state variable $s_HQ_Cur_Status
State variable $s_HQ_Debounce_TmrON is a flag that when 1 prevents the THEN clause of program#3 to run. It is set to 1 by program#3 indicating that a notification was sent and reset to 0 when timer $s_HQ_Timer reaches 0
Program#3 compares current signal status $s_HQ_Cur_Status with its previous status $i_HQ_Prev_status. This previous status is updated only when a notification sequence is executed.
Adjust Wait period (Program#4) and $s_HQ_Timer (Program#3) to get the desired debounce period (here the debounce period is 15sec.)
------------------------------------------------------
Program#1: Detect_sig HQ_OFF is received
If
X10 'K2/Off (11)' is Received
Then $s_HQ_Cur_Status = 0
$s_HQ_Cur_Status Init To 0
Else
- No Actions - (To add one, press 'Action')
Every time an X10 command OFF is received update Current status
s_HQ_Cur_status is State variable in order to trigger program "Test if HQ status changed
------------------------------------------------------
Program#2: Detect_sig HQ_ON is received
If
X10 'K2/On (3)' is Received
Then
$s_HQ_Cur_Status = 1
$s_HQ_Cur_Status Init To 1
Else
- No Actions - (To add one, press 'Action')
Every time an X10 command ON is received update Current status
------------------------------------------------------
Program#3: Test if HQ status changed
If
$s_HQ_Debounce_TmrON is 0
And $i_HQ_Prev_status is not $s_HQ_Cur_Status
Then
Run Program 'xmit HQ status' (If)
Disable Program 'HQ_Timer_pgm'
$s_HQ_Timer = 15
$i_HQ_Prev_status = $s_HQ_Cur_Status
Enable Program 'HQ_Timer_pgm'
$s_HQ_Debounce_TmrON = 1
Else
- No Actions - (To add one, press 'Action')
Test if HQ status changed while debouncetimer OFF
Only when debounce timer is OFF AND HQ status as changed from its previous status
A notification is sent
And Debounce timer is started and the timer value initialized
------------------------------------------------------
Program#4: HQ_Timer_pgm
If
$s_HQ_Timer is not 0
Then
Wait 1 second
$s_HQ_Timer -= 1
Else
$s_HQ_Debounce_TmrON = 0
------------------------------------------------------
Program#5: xmit HQ status
If
$i_HQ_Prev_status is 1
Then
Run Program 'Mac_X10_HOT' (Then Path)
Send Notification to 'SMS xyz' content 'system Hot'
Else
Run Program 'Mac_X10_HOT' (Else Path)
Send Notification to ' SMS xyz' content 'system Cold'
Always disabled, Run by tst
Every comments/suggestions would be appreciated
thanks