PowerShell/Scripts/simulate-presence.ps1

25 lines
704 B
PowerShell
Raw Normal View History

2021-04-07 11:53:57 +02:00
#!/usr/bin/pwsh
2020-12-29 15:14:21 +01:00
<#
2021-04-07 15:17:49 +02:00
.SYNTAX simulate-presence.ps1 [<IP-address>]
2021-03-22 20:10:18 +01:00
.DESCRIPTION simulates the human presence against burglars
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
2020-12-29 15:14:21 +01:00
#>
2020-11-30 16:28:56 +01:00
2021-02-16 17:44:13 +01:00
param($IPaddress = "")
2021-04-07 15:17:49 +02:00
if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter IP address of Shelly1 device" }
2021-02-18 20:17:55 +01:00
2021-02-16 17:40:35 +01:00
try {
for ([int]$i = 0; $i -lt 1000; $i++) {
2021-04-07 14:45:10 +02:00
& "$PSScriptRoot/switch-shelly1.ps1" $IPaddress on 0
2021-02-16 17:40:35 +01:00
start-sleep -s 10
2021-04-07 14:45:10 +02:00
& "$PSScriptRoot/switch-shelly1.ps1" $IPaddress off 0
2021-02-16 17:40:35 +01:00
start-sleep -s 60
}
write-host -foregroundColor green "Done."
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
2020-11-30 16:28:56 +01:00
}