lgilsenberg Posted November 20, 2020 Posted November 20, 2020 I've been working with motion sensors throughout my house (with lots of advice from the forum - thank you). Now I'd like to figure out a way to have a variable length motion timeout. I've been able to get Alexa to pass a number to a variable LR_Motion_Countdown. I thought I'd write it like this: LR Motion If LR_Motion_Sensor_1 is switch off AND LR_Motion_Sensor_2 is switched off Then Run LR_Countdown (IF) LR Countdown If LR_Motion_Countdown > 0 then LR_Motion_Countdown =- 1 Wait 1 minute else set scene LR off I'd concerned this won't work because i want the motion sensor to restart the countdown every time it senses motion and this method won't do that. I started playing around with the following program. Do you think it will work? First Floor Motion - [ID 003D][Parent 003C] If Status '1 - First Floor / Kitchen / Kitchen Sensor Motion' is Off And Status '1 - First Floor / Living Room / Living Room Binary Sensor' is Off And $Motion is not $OFF Then $Hold_For_Living_Room_Motion = $Motion Repeat Every 1 minute $Motion -= 1 Repeat 1 times Set Scene '1 - First Floor / First Floor' Off Run Program 'First Floor Motion' (Else Path) Else $Motion = $Hold_For_Living_Room_Motion **** this is done to reset motion countdown to original value The problem I see with this program is $Hold_For_Living_Room_Motion should be reset every time i change $Motion. I don't know how to do that. Also I'd like to have the ability to turn off motion sensor timer by setting it to 0. Does anybody have any suggestions? I'm beginning to lose my own train of thought.
larryllix Posted November 21, 2020 Posted November 21, 2020 7 hours ago, lgilsenberg said: I've been working with motion sensors throughout my house (with lots of advice from the forum - thank you). Now I'd like to figure out a way to have a variable length motion timeout. I've been able to get Alexa to pass a number to a variable LR_Motion_Countdown. I thought I'd write it like this: LR Motion If LR_Motion_Sensor_1 is switch off AND LR_Motion_Sensor_2 is switched off Then Run LR_Countdown (IF) LR Countdown If LR_Motion_Countdown > 0 then LR_Motion_Countdown =- 1 Wait 1 minute else set scene LR off I'd concerned this won't work because i want the motion sensor to restart the countdown every time it senses motion and this method won't do that. I started playing around with the following program. Do you think it will work? First Floor Motion - [ID 003D][Parent 003C] If Status '1 - First Floor / Kitchen / Kitchen Sensor Motion' is Off And Status '1 - First Floor / Living Room / Living Room Binary Sensor' is Off And $Motion is not $OFF Then $Hold_For_Living_Room_Motion = $Motion Repeat Every 1 minute $Motion -= 1 Repeat 1 times Set Scene '1 - First Floor / First Floor' Off Run Program 'First Floor Motion' (Else Path) Else $Motion = $Hold_For_Living_Room_Motion **** this is done to reset motion countdown to original value The problem I see with this program is $Hold_For_Living_Room_Motion should be reset every time i change $Motion. I don't know how to do that. Also I'd like to have the ability to turn off motion sensor timer by setting it to 0. Does anybody have any suggestions? I'm beginning to lose my own train of thought. 1
lgilsenberg Posted November 21, 2020 Author Posted November 21, 2020 Thank you @larryllix. This was a great solution. I made a couple of mods that I'll share below. I was wondering if there is a way to set a variable to it's initial value programmatically without using another variable? Some Notes up front LR.K is Living Room and Kitchen. $LR.K_Motion is set by Alexa (Off = 1440 which is number of minutes in a day, On = 10 which is the default timeout for motion sensors) $FINISHED = 0 $LR.K_Motion is reset to 10 every sunrise LR.K Motion Stopped - [ID 003D][Parent 003C] If Status '1 - First Floor / Kitchen / Kitchen Sensor Motion' is On Or Status '1 - First Floor / Living Room / Living Room Motion Sensor' is On Then $LR.K_Motion_Countdown = $LR.K_Motion LR.K Countdown - [ID 0044][Parent 003C] If $LR.K_Motion_Countdown > $FINISHED Then Wait 1 minute $LR.K_Motion_Countdown -= 1 LR.K Turn off lights - [ID 004B][Parent 003C] If $LR.K_Motion_Countdown is $FINISHED Then Set Scene '1 - First Floor / First Floor' Off $LR.K_Motion = $LR.K_MOTION_INIT This is why I'm looking to find a way to set a variable to it's initial state. When the lights finally turn off, I want to reset the motion timer to 10 (until I change my mind). To keep it simple on the changes, I want to change it in only one place - INIT value on the variable page if possible.
larryllix Posted November 21, 2020 Posted November 21, 2020 (edited) 4 hours ago, lgilsenberg said: Thank you @larryllix. This was a great solution. I made a couple of mods that I'll share below. I was wondering if there is a way to set a variable to it's initial value programmatically without using another variable? Some Notes up front LR.K is Living Room and Kitchen. $LR.K_Motion is set by Alexa (Off = 1440 which is number of minutes in a day, On = 10 which is the default timeout for motion sensors) $FINISHED = 0 $LR.K_Motion is reset to 10 every sunrise LR.K Motion Stopped - [ID 003D][Parent 003C] If Status '1 - First Floor / Kitchen / Kitchen Sensor Motion' is On Or Status '1 - First Floor / Living Room / Living Room Motion Sensor' is On Then $LR.K_Motion_Countdown = $LR.K_Motion LR.K Countdown - [ID 0044][Parent 003C] If $LR.K_Motion_Countdown > $FINISHED Then Wait 1 minute $LR.K_Motion_Countdown -= 1 LR.K Turn off lights - [ID 004B][Parent 003C] If $LR.K_Motion_Countdown is $FINISHED Then Set Scene '1 - First Floor / First Floor' Off $LR.K_Motion = $LR.K_MOTION_INIT This is why I'm looking to find a way to set a variable to it's initial state. When the lights finally turn off, I want to reset the motion timer to 10 (until I change my mind). To keep it simple on the changes, I want to change it in only one place - INIT value on the variable page if possible. I haven't been able to follow what you are trying to do but.... the init_to version of the variable is write only to the user...so far. IIRC that has been requested previously but more requests and case uses examples always helps. Search in the future features thread. Use Michel's tag to alert him BTW: I use a prefix like this $cTRUE , $cFALSE for fixed Integer variables that never change. Edited November 21, 2020 by larryllix
Recommended Posts