Skip to content

Commit c7b20f5

Browse files
committed
Updated switch-shelly1.ps1
1 parent e1ffab5 commit c7b20f5

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

scripts/switch-shelly1.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
Switches a Shelly1 device
44
.DESCRIPTION
55
This PowerShell script switches a Shelly1 device in the local network.
6-
.PARAMETER Host
6+
.PARAMETER host
77
Specifies either the hostname or IP address of the Shelly1 device
8-
.PARAMETER TurnMode
8+
.PARAMETER turnMode
99
Specifies either 'on', 'off', or 'toggle'
10-
.PARAMETER Timer
10+
.PARAMETER timer
1111
Specifies the timer in seconds (0 = infinite)
1212
.EXAMPLE
1313
PS> ./switch-shelly1 192.168.100.100 toggle 10
@@ -17,16 +17,16 @@
1717
Author: Markus Fleschutz | License: CC0
1818
#>
1919

20-
param([string]$Host = "", [string]$TurnMode = "", [int]$Timer = -999)
20+
param([string]$host = "", [string]$turnMode = "", [int]$timer = -999)
2121

2222
try {
23-
if ($Host -eq "") { $Host = read-host "Enter hostname or IP address of the Shelly1 device" }
24-
if ($TurnMode -eq "") { $TurnMode = read-host "Enter turn mode (on/off/toggle)" }
25-
if ($Timer -eq -999) { [int]$Timer = read-host "Enter timer in seconds (0=endless)" }
23+
if ($host -eq "") { $host = Read-Host "Enter the hostname or IP address of the Shelly1 device" }
24+
if ($turnMode -eq "") { $turnMode = Read-Host "Enter the turn mode (on/off/toggle)" }
25+
if ($timer -eq -999) { [int]$timer = Read-Host "Enter the timer in seconds (0=endless)" }
2626

27-
$Result = Invoke-RestMethod "http://$($Host)/relay/0?turn=$($TurnMode)&timer=$($Timer)"
27+
$result = Invoke-RestMethod "http://$($host)/relay/0?turn=$($turnMode)&timer=$($timer)"
2828

29-
"✔️ switched Shelly1 device at $Host to $TurnMode for $Timer sec"
29+
"✔️ Switched Shelly1 device at $host to $turnMode for $timer sec."
3030
exit 0 # success
3131
} catch {
3232
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

0 commit comments

Comments
 (0)