-
Notifications
You must be signed in to change notification settings - Fork 3
/
elgato.psm1
169 lines (128 loc) · 4.18 KB
/
elgato.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
function Set-ElgatoKeyLight {
<#
.Synopsis
Configures an Elgato Key Light Air that's connected to the local network. Control Center and Stream Deck software not required.
.Parameter Hostname
DNS Hostname or IP address of the target light.
.Parameter Brightness
The brightness of the light that you are configuring. Valid values: 3 to 100.
.Parameter Temperature
The color temperature (7000K to 2900K) to set the light to. Valid values: 2900 to 7000.
.Parameter On
If not specified, the light will be shut off. If specified, the light will be turned on.
.Example
Set a key light air to full brightness, and coolest color temperature.
PS > Set-ElgatoKeyLight -On -Host 10.0.0.231 -Brightness 100 -Temperature 7000
.Example
Set a key light air to half brightness with warmest color temperature (2)
PS > Set-ElgatoKeyLight -On -Host 10.0.0.231 -Brightness 50 -Temperature 2900
.Example
Set two key light airs to half brightness with warmest color temperature (3)
PS > Set-ElgatoKeyLight -On -Host 10.0.0.231, 10.0.0.232 -Brightness 50 -Temperature 2900
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string[]] $Hostname
, [ValidateRange(3,100)]
[int] $Brightness
, [ValidateRange(2900, 7000)]
[int] $Temperature
, [switch] $On
)
$Body = @{
NumberOfLights = 1
Lights = @(
@{
Brightness = $Brightness
Temperature = 1000000 / $Temperature -as [int]
On = $On ? 1 : 0
}
)
} | ConvertTo-Json
$HostName | ForEach-Object {
Invoke-RestMethod -Method Put -Uri http://$_`:9123/elgato/lights -Body $Body
}
}
function Get-ElgatoKeyLight {
<#
.Synopsis
Gets information about an Elgato Key Light Air that's connected to the local network. Control Center and Stream Deck software not required.
.Parameter Hostname
DNS Hostname or IP address of the target light, supports multiple objects
.Example
Get the current key light air settings
PS > Get-ElgatoKeyLight -Host 10.0.0.231
.Example
Get the current key light air settings of both key light airs
PS > Get-ElgatoKeyLight -Host 10.0.0.231, 10.0.0.232
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string[]] $Hostname
)
$HostName | ForEach-Object {
Invoke-RestMethod -Method Get -Uri http://$_`:9123/elgato/lights
}
}
function Start-ElgatoKeyLight {
<#
.Synopsis
Turns on an Elgato Key Light Air that's connected to the local network. Control Center and Stream Deck software not required.
.Parameter Hostname
DNS Hostname or IP address of the target light, supports multiple objects
.Example
Turn on a key light air
PS > Start-ElgatoKeyLight -Host 10.0.0.231
.Example
Turn on both key light airs
PS > Start-ElgatoKeyLight -Host 10.0.0.231, 10.0.0.232
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string[]] $Hostname
)
$Body = @{
NumberOfLights = 1
Lights = @(
@{
On = 1
}
)
} | ConvertTo-Json
$HostName | ForEach-Object {
Invoke-RestMethod -Method Put -Uri http://$_`:9123/elgato/lights -Body $Body
}
}
function Stop-ElgatoKeyLight {
<#
.Synopsis
Turns off an Elgato Key Light Air that's connected to the local network. Control Center and Stream Deck software not required.
.Parameter Hostname
DNS Hostname or IP address of the target light, supports multiple objects
.Example
Turn off a key light air
PS > Stop-ElgatoKeyLight -Host 10.0.0.231
.Example
Turn off both key light airs
PS > Stop-ElgatoKeyLight -Host 10.0.0.231, 10.0.0.232
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string[]] $Hostname
)
$Body = @{
NumberOfLights = 1
Lights = @(
@{
On = 0
}
)
} | ConvertTo-Json
$HostName | ForEach-Object {
Invoke-RestMethod -Method Put -Uri http://$_`:9123/elgato/lights -Body $Body
}
}