PowerShell/Scripts/simulate-presence.ps1

32 lines
725 B
PowerShell
Raw Normal View History

2021-08-26 10:46:12 +02:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
simulate-presence.ps1 [<IP-address>]
.DESCRIPTION
2021-08-29 17:50:03 +02:00
Simulates the human presence against burglars.
2021-07-13 21:10:02 +02:00
.EXAMPLE
PS> .\simulate-presence.ps1 192.168.100.100
2021-08-29 17:50:03 +02:00
.NOTES
Author: Markus Fleschutz · License: CC0
2021-07-13 21:10:02 +02:00
.LINK
https://github.com/fleschutz/PowerShell
2020-12-29 15:14:21 +01:00
#>
2020-11-30 16:28:56 +01:00
2021-07-15 15:51:22 +02:00
param([string]$IPaddress = "")
2021-02-18 20:17:55 +01:00
2021-02-16 17:40:35 +01:00
try {
2021-07-15 15:51:22 +02:00
if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter IP address of Shelly1 device" }
2021-02-16 17:40:35 +01:00
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
}
2021-08-24 20:46:03 +02:00
"✔️ Done."
2021-02-16 17:40:35 +01:00
exit 0
} catch {
2021-05-02 21:30:48 +02:00
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-02-16 17:40:35 +01:00
exit 1
2020-11-30 16:28:56 +01:00
}