Improved simulate-presence.ps1

This commit is contained in:
Markus Fleschutz 2021-02-16 17:40:35 +01:00
parent 55dcaec249
commit 14453b14b6

View File

@ -6,12 +6,21 @@
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]IPaddress)
param(IPaddress = "")
for ([int]$i = 0; $i -lt 1000; $i++) {
./switch-shelly1 $IPaddress on 0
sleep 60
./switch-shelly1 $IPaddress off 0
sleep 10
try {
if ($IPaddress -eq "" ) {
$IPaddress = read-host "Enter IP address of Shelly1 device"
}
for ([int]$i = 0; $i -lt 1000; $i++) {
& ./switch-shelly1.ps1 $IPaddress on 0
start-sleep -s 10
& ./switch-shelly1.ps1 $IPaddress off 0
start-sleep -s 60
}
write-host -foregroundColor green "Done."
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
exit 0