PowerShell/Scripts/simulate-presence.ps1

28 lines
682 B
PowerShell
Raw Normal View History

2021-02-09 19:30:45 +01:00
#!/bin/powershell
2020-12-29 15:14:21 +01:00
<#
2021-03-22 20:10:18 +01:00
.SYNTAX ./simulate-presence.ps1 [<IP-address>]
.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 = "")
2020-11-30 16:28:56 +01:00
2021-02-18 20:17:55 +01:00
if ($IPaddress -eq "" ) {
$IPaddress = read-host "Enter IP address of Shelly1 device"
}
2021-02-16 17:40:35 +01:00
try {
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
2020-11-30 16:28:56 +01:00
}