-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
60 lines (48 loc) · 1.65 KB
/
default.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
cls
#cd 'D:\GoogleDrive\PowerShell_detectPhoneOnWifi'
Set-Location $(get-location).Path;
start-service mysql
. “.\variables.ps1”
. “.\functions.ps1”
$a = 1
do
{
CheckSolarTimes
if($script:solartime -eq "evening")
{
#write-host "Solartime is evening.."
RunQuery "log" "Solartime is evening.."
DetectPhone
CheckCurrentState
if($script:engagedHue -eq 1 -and $script:currentState -eq 0)
{
#the Hue has been lit before, but current state is off. So it has to be shut down from another source.. Lets keep the lights off.
RunQuery "log" "Lights have been turned off, from an other source, lets keep the lights off."
sleep -s $WaitTimeIfNoDeviceOnline
}
elseif($script:phonefound -ne 0)
{
write-host "Activate HUE"
#activate
#waittime high
EngageHue
RunQuery "log" "Waiting $script:loopwaitcounterSec seconds after engaging the Hue."
sleep -s $script:loopwaitcounterSec
}
else
{
#deactivate
#no wait
ShutdownHue
RunQuery "log" "It is evening, but no devices are found online, shutting down the Hue lights."
sleep -s $WaitTimeIfNoDeviceOnline
RunQuery "log" "Waiting $WaitTimeIfNoDeviceOnline seconds, then retrying to find devices."
}
}
elseif($script:solartime -eq "morning")
{
ShutdownHue
RunQuery "log" "Solartime set to morning, disengaging the Hue lights."
sleep -s 60
}
}While ($a -eq 1)