drmacro Posted May 17, 2018 Posted May 17, 2018 I have the following program: Motion Handle Daytime - [ID 0019][Parent 0001] If From Sunrise + 30 minutes To Sunset - 30 minutes (same day) And $MotionDetected > 0 Then Send Notification to 'TextMsg' content 'DrivewayMotion' $MotionDetected = 0 Else - No Actions - (To add one, press 'Action') MotionDetected is a state variable. If I go by hand to the variables tab in UDA and set it MotionDetected to 1, I get one text message. (The Notify is set up to send an email to the text message email for my phone provider) If I enable this code: MotionSense - [ID 0018][Parent 0001] If Status 'Driveway Motion Sensor' is On And $MotionDetected <= 0 Then $MotionDetected = 1 Else - No Actions - (To add one, press 'Action') (In this test case "Driveway Motion Sensor" is just a switch that I turn on by hand) When I toggle "Driveway Motion Sensor", I get 40 text messages. I watch MotionDetected and it never goes to 1 more than once. (Guessing that the gui may not update fast enough to catch it I also changed the Then to: MotionSense - [ID 0018][Parent 0001] If Status 'Driveway Motion Sensor' is On And $MotionDetected <= 0 Then $MotionDetected += 1 Else - No Actions - (To add one, press 'Action') But never see anything but 0 or 1. What am I missing? I'm just not comfortable with this programming paradigm...yet. ?
drmacro Posted May 18, 2018 Author Posted May 18, 2018 So I wasn't satisfied that my test of missing changes in the gui display of variables was valid. So I implemented a blocking variable (not state variable) that is checked as well as the on state of the "sensor". MotionSense - [ID 0018][Parent 0001] If Status 'Driveway Motion Sensor' is On And $sMotionDetected <= 0 And $MotionRetriggerBlock <= 0 Then $MotionRetriggerBlock = 1 $sMotionDetected = 1 Else - No Actions - (To add one, press 'Action') If the status of the switch activated by the sensor is on and state var sMotionDetected is 0 and MotionRetriggerBlock is 0 (i.e.motion has not been detected before) Then set sMotionDetected and MotionRetriggerBlock = 1 The state change of sMotionDetect triggers program "Motion Handle Daytime'. After the Then executes this code won't execute until MotionRetriggerBlock is set back to 0. To indicate there has been motion detected and handled: Motion Handle Daytime - [ID 0019][Parent 0001] If From Sunrise + 30 minutes To Sunset - 30 minutes (same day) And $sMotionDetected > 0 Then $sMotionDetected = 0 Send Notification to 'TextMsg' content 'DrivewayMotion' Else - No Actions - (To add one, press 'Action') In order to reset so another motion can be detected: MotionSense Unblock - [ID 001E][Parent 0001] If Status 'Driveway Motion Sensor' is Off And $MotionRetriggerBlock > 0 Then $MotionRetriggerBlock = 0 Else - No Actions - (To add one, press 'Action') Once the "sensor switch" goes back to off, clear the block so another motion can be detected. This sends only one text message. There are probably better ways to do this, possibly with Insteon rather than zwave devices. But, as I noted I already have the PR511 (it is designed for outdoor conditions) and zwave devices. And I have no Insteon devices. (I could monitor for X10 output from the PR511, but the ultimate goal is to X10 do away with all the crap I've added to the electrical for X10 signals, etc. Which even with the bridges and repeaters, fail miserably when the electric dryer or spa is running. ? )
Recommended Posts
Archived
This topic is now archived and is closed to further replies.