Jump to content

need help with MS logic


Naptown

Recommended Posts

Posted

I'm learning, but I'm still bad with making the logic.  I have made this program so far:

 

Motion Emails - [iD 000B][Parent 0001]

If
        From    11:00:00PM
        To      Sunrise (next day)
    And (
             Control 'Motion Driveway - Sensor' is switched On
          Or Control 'Motion Patio - Sensor' is switched On
          Or Control 'Motion Front - Sensor' is switched On
        )
 
Then
        Send Notification to 'xxxxxxx@gmail.com'
 
Else
        Repeat Every  12 hours
 
 

 

1st question - what can I change so that it does this?  If motion is detected, wait 60 seconds, and check for motion again.  If motion for a minute, send me an email.  Otherwise disregard the single notification.  Last night I got 3 emails and I'm not sure if they were false alarms or what.  Thinking that if somebody is tripping the MS for 60 seconds (or maybe only 30), during those hours, then I need to know.  Is that what occupancy mode could be for?  Sorry, I'm bad at this.

 

2nd question - is the else good?  Or, should I do something else?  Or, just do nothing?

Posted (edited)

I'm learning, but I'm still bad with making the logic.  I have made this program so far:

 

Motion Emails - [iD 000B][Parent 0001]

 

If

        From    11:00:00PM

        To      Sunrise (next day)

    And (

             Control 'Motion Driveway - Sensor' is switched On

          Or Control 'Motion Patio - Sensor' is switched On

          Or Control 'Motion Front - Sensor' is switched On

        )

 

Then

        Send Notification to 'xxxxxxx@gmail.com'

 

Else

        Repeat Every  12 hours

 

 

 

1st question - what can I change so that it does this?  If motion is detected, wait 60 seconds, and check for motion again.  If motion for a minute, send me an email.  Otherwise disregard the single notification.  Last night I got 3 emails and I'm not sure if they were false alarms or what.  Thinking that if somebody is tripping the MS for 60 seconds (or maybe only 30), during those hours, then I need to know.  Is that what occupancy mode could be for?  Sorry, I'm bad at this.

 

2nd question - is the else good?  Or, should I do something else?  Or, just do nothing?

Your Else section does nothing.

Repeat is a construct that is found before the program lines to be repeated....like this

 

Repeat Every 12 hours

    do something

    do something more

    do anything

                                     <----nothing can execute after an infinitely running  loop

----------------------------------------------

 

For the second motion detection I would do tt with two programs. The first one would be the control program that sets the timing and enables a second program that can detect a second motion operation as well as sends the notifications.

 

Motion Emails - [iD 000B][Parent 0001]

 

If

        From    11:00:00PM

        To      Sunrise (next day)

    And (

             Control 'Motion Driveway - Sensor' is switched On

          Or Control 'Motion Patio - Sensor' is switched On

          Or Control 'Motion Front - Sensor' is switched On

        )

 Then

         Enable program 'Motion Notify'  <-----allow notifications on motion detection

         Wait 1 minute                             <----- your MS has t have the all motion option enabled

         Disable program 'Motion Notify'  <-----time frame over

Else

        Disable program 'Motion Notify'   <--- necessary for Sunrise (next day) which could interrupt Wait 1 min

 

 

 

Motion Notify (disabled)

If

Then

        Send Notification to 'xxxxxxx@gmail.com'

 

Else

        -----

 

 

Now this setup may notify you several times if motion ceases for over a minute so a further disable of program 1 may become necessary. At the moment this appears to require three programs. Some logical thinking may make two programs possible.

Edited by larryllix
Posted

Maybe I'm overthinking this, but does anyone else have some programs they can share regarding outdoor lights and motion sensors?  Since it's brand new to me, I like seeing the notifications.  But, I would like to reduce the false notifications if it's just a squirrel or something passing by.

 

I understand HA can do anything you want it to do, but I guess I'm just not completely sure of what I want.

Posted

I like LarryLix proposal, but suspect there might be one extra step to the proposed "Motion Notify" program necessary:

 

Motion Notify (disabled)

If

Control 'Motion Driveway - Sensor' is switched On <<<I would add these three lines so that, once enabled, the program will actually trigger
Or Control 'Motion Patio - Sensor' is switched On
Or Control 'Motion Front - Sensor' is switched On

 

Then
        Send Notification to 'xxxxxxx@gmail.com'
 
Else
        -----

 

but does anyone else have some programs they can share regarding outdoor lights and motion sensors?

 

I do not, because I don't desire to have notifications.  If I did, however, I would take an approach like suggested by LarryLix. 

Posted

If
        From    11:00:00PM
        To      Sunrise (next day)
    And (
             Control 'Motion Driveway - Sensor' is switched On
          Or Control 'Motion Patio - Sensor' is switched On
          Or Control 'Motion Front - Sensor' is switched On
        )
 Then

         Wait 1 minute     <----Motion starts the wait

         Run Program 'Notify'  (If)

 

  Else

 

Program Notify (disabled)

 

If
        Control 'Motion Driveway - Sensor' is switched On
     Or Control 'Motion Patio - Sensor' is switched On
     Or Control 'Motion Front - Sensor' is switched On
      
 Then

         Send Notification to 'xxxxxxx@gmail.com'  <---If motion is detected 1 minute after the original motion, a notice is sent

 

  Else

Posted

 Then

         Wait 1 minute     <----Motion starts the wait

         Run Program 'Notify'  (If)

 

  Else

This is just going to wait a minute to notify me.

 

I guess I'm saying I want to give the first ON signal (my MS are currently sending ON only) a 1 minute time out, then..

check again for motion.  If motion, notify.  If no motion, carry on with no notification.

Posted

The first program will not notify you at all--ever. After 1 minute the Notify program will run. In particular, if motion is detected, then the first program waits a minute and the second program runs and checks for motion again after 1 minute has elapsed. If motion is detected a second time after 1 minute has passed, then you'll be notified. If there's no motion after 1 minute, the If section of the Notify program will be false and no notification is sent.

Posted

I guess I'm saying I want to give the first ON signal (my MS are currently sending ON only) a 1 minute time out, then..

check again for motion.

 

Point of clarification...do you want it to wait for one minute before checking again, or to send a notification if motion is sensed a second time, within 60 seconds of the prior motion detection.

 

I am not sure that there is a way to "check again" for motion.  The sensors will send out motion when detected and the odds of motion being detected EXACTLY after sixty seconds are next to impossible.  The thing one can watch for is whether motion is sensed within certain time ranges or intervals.

 

If motion is detected a second time after 1 minute has passed

 

so...if motion is detected 70 seconds later, you want a notification?  If 90 seconds?  A half hour? 

 

Better, in my mind, is to see if you have multiple detections within a short period (minute sounds good), rather than random detections many minute or hours apart. 

Posted

Point of clarification...do you want it to wait for one minute before checking again, or to send a notification if motion is sensed a second time, within 60 seconds of the prior motion detection.   I want to wait 60 seconds and check again.

 

I am not sure that there is a way to "check again" for motion.  The sensors will send out motion when detected and the odds of motion being detected EXACTLY after sixty seconds are next to impossible.  The thing one can watch for is whether motion is sensed within certain time ranges or intervals.  This is something I hadn't thought about.

 

so...if motion is detected 70 seconds later, you want a notification?  If 90 seconds?  A half hour?  Great question.  I guess I want a single notification.

 

Better, in my mind, is to see if you have multiple detections within a short period (minute sounds good), rather than random detections many minute or hours apart. Yes, I agree this is going to be the way I tackle it.

Posted (edited)

These programs will send you notification if Motion Sensor sends On Command three or more times and resets after 60 seconds.

 

You need to have your motion sensor in "Sensing Mode" (as motion is sensed checked) and "On commands only."

 

Also, you need to create a two State Variables, one for count and the other as a call.

Variable Test - [ID 00D2][Parent 00CC]

If
        'Motion Sensors / Media Room / #3 Motion Sensor-Sensor' is switched On
 
Then
        $s.Test += 1
        $s.Test.Place  = 1
 
Else
   - No Actions - (To add one, press 'Action')
 

--------------------

Variable Test b - [ID 00DA][Parent 00CC]

If
        $s.Test.Place is 1
 
Then
        Wait  60 seconds
        Run Program 'Variable Test c' (If)
        Wait  5 seconds
        $s.Test.Place  = 0
        $s.Test  = 0
 
Else
   - No Actions - (To add one, press 'Action')
 

-------------------------

Variable Test c - [ID 00D3][Parent 00CC]

If
        $s.Test is 3
 
Then
        Send Notification 
 
Else
   - No Actions - (To add one, press 'Action')
 


EDIT:  had to make a few changes

 

 

 

Jon...

Edited by jerlands
Posted

Jon - I like this.  I'm hitting the sack now but will likely work on this tomorrow!  Looks very promising and very close to what I have been describing.

Posted (edited)

I like LarryLix proposal, but suspect there might be one extra step to the proposed "Motion Notify" program necessary:

 

Motion Notify (disabled)

If

Control 'Motion Driveway - Sensor' is switched On <<<I would add these three lines so that, once enabled, the program will actually trigger

Or Control 'Motion Patio - Sensor' is switched On

Or Control 'Motion Front - Sensor' is switched On

 

Then

        Send Notification to 'xxxxxxx@gmail.com'

 

Else

        -----

 

I do not, because I don't desire to have notifications.  If I did, however, I would take an approach like suggested by LarryLix. 

Thanks oberkc.!

 

That is what I had in mind but missed the If section copy over.

 

A simple Wait 1 minute before the program enable would delay the "watching" for the second event but this may introduce retrigger problems.

 

IMHO, This is going to take three programs.

- a trigger program,

- a lock out the trigger program (for one, and only one, logic), also enables second trigger detection  program,

- a second trigger detection program.

Edited by larryllix
Posted

If

        From    11:00:00PM

        To      Sunrise (next day)

    And (

             Control 'Motion Driveway - Sensor' is switched On

          Or Control 'Motion Patio - Sensor' is switched On

          Or Control 'Motion Front - Sensor' is switched On

        )

 Then

         Wait 1 minute     <----Motion starts the wait

         Run Program 'Notify'  (If)

 

  Else

 

Program Notify (disabled)

 

If

        Control 'Motion Driveway - Sensor' is switched On

     Or Control 'Motion Patio - Sensor' is switched On

     Or Control 'Motion Front - Sensor' is switched On

      

 Then

         Send Notification to 'xxxxxxx@gmail.com'  <---If motion is detected 1 minute after the original motion, a notice is sent

 

  Else

The second program will never test True. Notifications will never be sent while the program is disabled,

 

Switched triggers can be enabled and trigger from signals, but not tested for, as conditions. They always test false in the ISY logic engine, and will always run the Else section.

Posted

I doubt determining a difference between a dotting squirrel hauling his nuts and human things is not possible with an MS not focused to eliminate certain motion levels.

 

Security MS units have pet, blinding techniques to not see below a certain vertical level.

Posted

The second program will never test True. Notifications will never be sent while the program is disabled,

 

Switched triggers can be enabled and trigger from signals, but not tested for, as conditions. They always test false in the ISY logic engine, and will always run the Else section.

 

I have several disabled program that run only when called from another program. That's the reason I've disabled them.

Posted

I have several disabled program that run only when called from another program. That's the reason I've disabled them.

I think you missed that point.

 

It doesn't matter if the program is called from another program. 'switched' triggers never present a true result from a conditional test. My guess would be the ISY engine doesn't even run those lines of code to test them.

 

The program can not function.

Posted

Sunset - [iD 007E][Parent 0043]

If
        From    Sunset  +  5 minutes
        To      Sunrise -  5 minutes (next day)
 
Then
        Set Scene 'EX / Scenes / EX Dusk to Dawn' On
        Run Program 'Sunset Lighting' (If)   <--This statement causes my disabled Sunset Lighting program to run. Works correctly every time.
        Run Program 'Sunset Shading' (Then Path)  <--This program is disabled, too.
 
Else
   - No Actions - (To add one, press 'Action')

 

 

Sunset Lighting - [iD 001B][Parent 0043][Not Enabled]

If
        Status  'LR / Devices / LR Ceiling Light KPL 20' is Off
 
Then
        Set Scene 'LR / Scenes / LR Ceiling' On
 
Else
   - No Actions - (To add one, press 'Action')

 

 

Sunset Shading - [iD 0027][Parent 0043][Not Enabled]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Run Program 'Sunset LR Deck' (If)  <-- Runs disabled program
        Wait  4 seconds
        Run Program 'Sunset CR Pathway' (If)  <-- Runs disabled program
        Wait  4 seconds
        Resource 'Nighttime-CR-LR'
        Wait  4 seconds
        Resource 'Nighttime-MR-DR'
        Wait  20 minutes
        Run Program 'Sunset BR Courtyard' (If)  <-- Runs disabled program
        Repeat 2 times
           Wait  4 seconds
           Resource 'Nighttime-BR'
 
Else
   - No Actions - (To add one, press 'Action')
 

Sunset LR Deck - [iD 0028][Parent 0049][Not Enabled]

If
        $sLR_Deck_Status is 1
 
Then
        Run Program 'LR Deck.B1 Pre1' (Then Path)
 
Else
        Resource 'LR Deck Close'
 

Sunset CR Pathway - [iD 0034][Parent 0049][Not Enabled]

If
        $sCR_Pathway_Status is 1
 
Then
        Resource 'CR Pathway Stop'
 
Else
        Resource 'CR Pathway Close'

 

 
Sunset BR Courtyard - [iD 0035][Parent 0049][Not Enabled]

If
        $sBR_Courtyard_Status is 1
 
Then
        Resource 'BR Courtyard Stop'
 
Else
        Resource 'BR Courtyard Close'
 

Posted

.....

The point was about calling lines of code that are not conditions and only triggers.

 

These are lines containing 'switched'. They always test false.

 

Your programs, being called, are all status conditions. Those test True or false depending on the state.

Posted

 

 

 

Also, you need to create a two State Variables, one for count and the other as a call.


 


EDIT:  had to make a few changes

 

 

 

Jon...

 

 

OK, I have created 2 state variables and I'm working on the programs now.  Can you elaborate on the 2 variables?  I think I understand the count, but I don't understand the call.
Posted (edited)

 

OK, I have created 2 state variables and I'm working on the programs now.  Can you elaborate on the 2 variables?  I think I understand the count, but I don't understand the call.

 

 

The idea of the program is to count how many times the motion sensor sends an On command in a 60 second period and notify if that count equals 3.

 

There's probably other ways to do it but this is what I came up with...

 

$s.Test.Place is used as a trigger to initiate the On count and also set the timer (Wait 60 seconds) and prevents the wait from being interrupted.

 

You can play with this and get a feel for what it's doing by turning on Status icons to detailed (right click My Programs > Status Icons > Detailed) bring up a motion sensor to test and open Event Viewer to Level 3.  That way you can make changes and see the effects.

 

The problem with this particular program is that it will notify you twice if the On count doesn't exceed 3 during the 60 second period.  Also, it notifies you before the end of 60 seconds if the On count is 3.

 

 

Jon...

Edited by jerlands
Posted (edited)

 

OK, I have created 2 state variables and I'm working on the programs now.  Can you elaborate on the 2 variables?  I think I understand the count, but I don't understand the call.

 

 

You can play with the idea until it suits your needs...

Variable Test 1 - [ID 00E9][Parent 00CC]

If
        'Motion Sensors / Media Room / #3 Motion Sensor-Sensor' is switched On
 
Then
        $s.Test += 1
 
Else
   - No Actions - (To add one, press 'Action')
 

----------------

Variable Test 2 - [ID 00EA][Parent 00CC]

If
        $s.Test >= 1
 
Then
        Wait  60 seconds
        Run Program 'Variable Test c' (If)
        Wait  5 seconds
        $s.Test  = 0
 
Else
   - No Actions - (To add one, press 'Action')
 

------------------

Variable Test 3 - [ID 00EB][Parent 00CC]

If
        $s.Test is 3
 
Then
        Send Notification 
 
Else
   - No Actions - (To add one, press 'Action')
 


In this iteration every time $s.Test changes value "Variable Test 2" is re-triggered and the wait interrupted.

 

 

Jon...

Edited by jerlands
Guest
This topic is now closed to further replies.

×
×
  • Create New...