PaulG Posted November 18, 2013 Posted November 18, 2013 I am trying to turn on some lights when my phone's bluetooth mac is detected from a PC. I have the PC detecting the phone and setting a variable in the ISY via REST. The problem I having is that the bluetooth detection can drop out and come back in a few seconds. I need to de-bounce the running of the program only after the last detection was an hour ago. Hence my phone has to be out of range for an hour before it can trigger the ISY program to turn on the lights. Also I'd like the program to only trigger when it's between sunset and sunrise. Anyone able to help me out with the logic? Thanks, Paul
LeeG Posted November 18, 2013 Posted November 18, 2013 Assumptions: $SVar1 is a State variable set to 1 when timing should start. If a drop out occurs the variable will be set to something else and back to 1 when new timing should start. Program 1 If $SVar1 is 1 And From Sunset To Sunrise (next day) Then Run Program 'Program 2' (Then Path) Else Stop program 'Program 2' Program 2 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 1 hour Set 'SwitchLinc Dimmer DB' On Else - No Actions - (To add one, press 'Action')
PurdueGuy Posted November 18, 2013 Posted November 18, 2013 Assuming you set the variable to 0 when it is not detected, something like this? ProgramA: If From Sunset To Sunrise (next day) And $PhoneDetected is 0 Then Wait 60 minutes Run Program 'ProgramB' (Then) Else - No Actions - (To add one, press 'Action') ProgramB: If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Else - No Actions - (To add one, press 'Action')
oberkc Posted November 18, 2013 Posted November 18, 2013 I may understand your needs a bit differently (and, perhaps, wrongly) than the others. It seems to me that some of these suggested programs may not trigger the lights until 60 minutes after the phone is detected, or perhaps 60 minutes after the phone has last been detected. Is this what you wanted? Be aware that I am generally unfamiliar with REST commands, so I am assuming you have that working, and that your variable is a state variable (will trigger a program). For the purposes of this suggestion, I will follow the lead of the others and assume the state variable is 1 when detected and something else when not. Obviously, you cannot use directly the value of the current variable as an indication of being home (because of the intermittent dropouts). I would, thus, create a second state variable, calling it $athome. I will define the values for this variable to be 0=away, 1= at home. timer program: if $statevairable = 1 then set $athome = 1 else wait 60 minutes set $athome = 0 From there, it would be a relatively simple task to create a light program based on the $athome variable if time is from sunset to sunrise (next day) and $athome = 1 then turn on lights else do whatever you want done when having left home
PaulG Posted November 19, 2013 Author Posted November 19, 2013 Thanks oberkc, your solution works great! I am using a program called "BTProx" on my PC and am triggering two VBScript files for when my phone is detect and goes away. Here is the VB script that sets the variable on detect: Option Explicit Dim restReq, url, userName, password Set restReq = CreateObject("Microsoft.XMLHTTP") ' REST command to set state (2) variable ID 1 to value 1 url = "http://isy/rest/vars/set/2/1/1" ' If auth is required, replace the userName and password values ' with the ones you use on your ISY userName = "admin" password = "admin" restReq.open "GET", url, false, userName, password restReq.send ' WScript.echo restReq.responseText I then used your examples and it works beautifully! Thanks, Paul
oberkc Posted November 19, 2013 Posted November 19, 2013 One of these days I am goong to learn to take advantage of the REST interface.
Recommended Posts