Skip to content

Commit 14453b1

Browse files
committed
Improved simulate-presence.ps1
1 parent 55dcaec commit 14453b1

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

Scripts/simulate-presence.ps1

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66
.NOTES Author: Markus Fleschutz / License: CC0
77
#>
88

9-
param([string]IPaddress)
9+
param(IPaddress = "")
1010

11-
for ([int]$i = 0; $i -lt 1000; $i++) {
12-
./switch-shelly1 $IPaddress on 0
13-
sleep 60
14-
./switch-shelly1 $IPaddress off 0
15-
sleep 10
11+
try {
12+
if ($IPaddress -eq "" ) {
13+
$IPaddress = read-host "Enter IP address of Shelly1 device"
14+
}
15+
for ([int]$i = 0; $i -lt 1000; $i++) {
16+
& ./switch-shelly1.ps1 $IPaddress on 0
17+
start-sleep -s 10
18+
& ./switch-shelly1.ps1 $IPaddress off 0
19+
start-sleep -s 60
20+
}
21+
write-host -foregroundColor green "Done."
22+
exit 0
23+
} catch {
24+
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
25+
exit 1
1626
}
17-
exit 0

0 commit comments

Comments
 (0)