diff --git a/.github/workflows/RunEZOut.yml b/.github/workflows/RunEZOut.yml deleted file mode 100644 index e4ba23a..0000000 --- a/.github/workflows/RunEZOut.yml +++ /dev/null @@ -1,17 +0,0 @@ - -name: Run EZOut -on: - push: -jobs: - RunEZOut: - runs-on: ubuntu-latest - if: ${{ success() }} - steps: - - name: Check out repository - uses: actions/checkout@v2 - - name: UseEZOut - uses: StartAutomating/EZOut@master - - name: Push Changes - shell: pwsh - run: git push; exit 0 - diff --git a/.github/workflows/TestAndPublish.yml b/.github/workflows/TestAndPublish.yml index b5fda7d..2e3bc58 100644 --- a/.github/workflows/TestAndPublish.yml +++ b/.github/workflows/TestAndPublish.yml @@ -448,9 +448,9 @@ jobs: if (-not $imported) { return } - $foundModule = try { Find-Module -Name $imported.Name -ErrorAction SilentlyContinue } catch {} + $foundModule = try { Find-Module -Name $imported.Name -ErrorAction SilentlyContinue} catch {} - if ($foundModule -and $foundModule.Version -ge $imported.Version) { + if ($foundModule -and (([Version]$foundModule.Version) -ge ([Version]$imported.Version))) { "::warning::Gallery Version of $moduleName is more recent ($($foundModule.Version) >= $($imported.Version))" | Out-Host } else { @@ -485,4 +485,18 @@ jobs: } } } @Parameters + BuildModule: + runs-on: ubuntu-latest + if: ${{ success() }} + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: BuildPipeScript + uses: StartAutomating/PipeScript@main + - name: UseEZOut + uses: StartAutomating/EZOut@master + - name: UsePiecemeal + uses: StartAutomating/Piecemeal@main + - name: UseHelpOut + uses: StartAutomating/HelpOut@master diff --git a/.github/workflows/UpdateDocs.yml b/.github/workflows/UpdateDocs.yml deleted file mode 100644 index b030e0c..0000000 --- a/.github/workflows/UpdateDocs.yml +++ /dev/null @@ -1,14 +0,0 @@ - -name: Run HelpOut -on: - push: -jobs: - HelpOut: - runs-on: ubuntu-latest - if: ${{ success() }} - steps: - - name: Check out repository - uses: actions/checkout@v2 - - name: UseHelpOut - uses: StartAutomating/HelpOut@master - diff --git a/Add-HueLight.ps1 b/Add-HueLight.ps1 new file mode 100644 index 0000000..af5fe44 --- /dev/null +++ b/Add-HueLight.ps1 @@ -0,0 +1,122 @@ +function Add-HueLight { + + [CmdletBinding(SupportsShouldProcess)] + + + + param( +# One or more Device Identifiers (serial numbers ). + # Use this parameter when adding lights that have already been assigned to another bridge. + [Alias('SerialNumber')] + [string[]] + $DeviceID + ) + begin { + $hueBridge = Get-HueBridge + $invokeParams = @{} + $invokeParams.IPAddress = $hueBridge.IPAddress + $invokeParams.HueUserName = $hueBridge.HueUserName + + function ConvertRestInput { + param([Collections.IDictionary]$RestInput = @{}, [switch]$ToQueryString) + foreach ($ri in @($RestInput.GetEnumerator())) { + + $restParameterValue = $ri.Value + $restParameterValue = + if ($restParameterValue -is [DateTime]) { + $restParameterValue.Tostring('o') + } + elseif ($restParameterValue -is [switch]) { + $restParameterValue -as [bool] + } + else { + if ($ToQueryString -and + $restParameterValue -is [Array] -and + $JoinQueryValue) { + $restParameterValue -join $JoinQueryValue + } else { + $restParameterValue + } + } + + $RestInput[$ri.Key] = $restParameterValue + } + $RestInput + + } + +} +process { + $InvokeCommand = 'Send-HueBridge' + $invokerCommandinfo = + $ExecutionContext.SessionState.InvokeCommand.GetCommand('Send-HueBridge', 'All') + $method = 'POST' + $contentType = 'application/json' + $bodyParameterNames = @('DeviceID') + $queryParameterNames = @('') + $joinQueryValue = '' + $uriParameterNames = @('') + $endpoints = @("lights") + $ForEachOutput = { + + } + if ($ForEachOutput -match '^\s{0,}$') { + $ForEachOutput = $null + } + if (-not $invokerCommandinfo) { + Write-Error "Unable to find invoker '$InvokeCommand'" + return + } + if (-not $psParameterSet) { $psParameterSet = $psCmdlet.ParameterSetName} + if ($psParameterSet -eq '__AllParameterSets') { $psParameterSet = $endpoints[0]} + $uri = $endpoints[0] + + $invokeSplat = @{} + $invokeSplat.Uri = $uri + if ($method) { + $invokeSplat.Method = $method + } + if ($ContentType -and $invokerCommandInfo.Parameters.ContentType) { + $invokeSplat.ContentType = $ContentType + } + if ($InvokeParams -and $InvokeParams -is [Collections.IDictionary]) { + $invokeSplat += $InvokeParams + } + $completeBody = [Ordered]@{} + foreach ($bodyParameterName in $bodyParameterNames) { + if ($bodyParameterName) { + if ($PSBoundParameters.ContainsKey($bodyParameterName)) { + $completeBody[$bodyParameterName] = $PSBoundParameters[$bodyParameterName] + } else { + $bodyDefault = $ExecutionContext.SessionState.PSVariable.Get($bodyParameterName).Value + if ($null -ne $bodyDefault) { + $completeBody[$bodyParameterName] = $bodyDefault + } + } + } + } + $completeBody = ConvertRestInput $completeBody + $bodyContent = + if ($ContentType -match 'x-www-form-urlencoded') { + @(foreach ($bodyPart in $completeBody.GetEnumerator()) { + "$($bodyPart.Key.ToString().ToLower())=$([Web.HttpUtility]::UrlEncode($bodyPart.Value))" + }) -join '&' + } elseif ($ContentType -match 'json' -or -not $ContentType) { + ConvertTo-Json $completeBody + } + if ($bodyContent -and $method -ne 'get') { + $invokeSplat.Body = $bodyContent + } + Write-Verbose "$($invokeSplat.Uri)" + if ($ForEachOutput) { + if ($ForEachOutput.Ast.ProcessBlock) { + & $invokerCommandinfo @invokeSplat | & $ForEachOutput + } else { + & $invokerCommandinfo @invokeSplat | ForEach-Object -Process $ForEachOutput + } + } else { + & $invokerCommandinfo @invokeSplat + } +} +} + diff --git a/Add-HueLight.ps1.ps1 b/Add-HueLight.ps1.ps1 new file mode 100644 index 0000000..063a3f0 --- /dev/null +++ b/Add-HueLight.ps1.ps1 @@ -0,0 +1,27 @@ +function Add-HueLight +{ + [Rest("lights", + Invoker="Send-HueBridge", + Method='POST', + ContentType='application/json', + BodyParameter={ +{ + param( + # One or more Device Identifiers (serial numbers ). + # Use this parameter when adding lights that have already been assigned to another bridge. + [Alias('SerialNumber')] + [string[]] + $DeviceID + ) +} + })] + [CmdletBinding(SupportsShouldProcess)] + param() + + begin { + $hueBridge = Get-HueBridge + $invokeParams = @{} + $invokeParams.IPAddress = $hueBridge.IPAddress + $invokeParams.HueUserName = $hueBridge.HueUserName + } +} diff --git a/Add-HueRoom.ps1 b/Add-HueRoom.ps1 index 9283e77..65f0d97 100644 Binary files a/Add-HueRoom.ps1 and b/Add-HueRoom.ps1 differ diff --git a/CHANGELOG.md b/CHANGELOG.md index cf251e9..3685882 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.2.4 +* Adding Add-HueLight (#18) +* Adding Get-HueLight -New (#21) +* Fixing Rename-HueLight (#19) +* Building LightScript with PipeScript (#20) +--- + ## 0.2.3 * Set-NanoLeaf: Fixing #17 * Send-HueBridge: Adding logging diff --git a/Get-HueLight.ps1 b/Get-HueLight.ps1 index 3e6f124..e50edc9 100644 Binary files a/Get-HueLight.ps1 and b/Get-HueLight.ps1 differ diff --git a/LightScript.ps1.psm1 b/LightScript.ps1.psm1 new file mode 100644 index 0000000..caae43e --- /dev/null +++ b/LightScript.ps1.psm1 @@ -0,0 +1,20 @@ +[include("*-*.ps1")]$PSScriptRoot + +if ($home) { + $Script:KnownResources = + @( + Get-HueLight + Get-HueRoom + Get-NanoLeaf + ) + + foreach ($resource in $Script:KnownResources) { + if ($resource.pstypenames -contains 'Hue.Light') { + Set-Alias -Name ($resource.Name -replace '\s') -Value Set-HueLight + } + if ($resource.pstypenames -contains 'Hue.Group' -or + $resource.pstypenames -contains 'Hue.LightGroup') { + Set-Alias -Name ($resource.Name -replace '\s') -Value Set-HueLight + } + } +} diff --git a/LightScript.psd1 b/LightScript.psd1 index 8748213..88175cf 100644 --- a/LightScript.psd1 +++ b/LightScript.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '0.2.3' + ModuleVersion = '0.2.4' RootModule = 'LightScript.psm1' Description = 'Smarter Lighting with PowerShell' FormatsToProcess = 'LightScript.format.ps1xml' @@ -14,6 +14,13 @@ LicenseURI = 'https://github.com/StartAutomating/LightScript/blob/main/LICENSE' IconURI = 'https://github.com/StartAutomating/LightScript/blob/main/Assets/LightScript.png' ReleaseNotes = @' +## 0.2.4 +* Adding Add-HueLight (#18) +* Adding Get-HueLight -New (#21) +* Fixing Rename-HueLight (#19) +* Building LightScript with PipeScript (#20) +--- + ## 0.2.3 * Set-NanoLeaf: Fixing #17 * Send-HueBridge: Adding logging diff --git a/LightScript.psm1 b/LightScript.psm1 index 6861285..4f5dee2 100644 Binary files a/LightScript.psm1 and b/LightScript.psm1 differ diff --git a/README.md b/README.md index 484a77b..d49f36f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,14 @@ Add-HueSchedule -In '00:10:00' -Command (Set-HueLight -Alert lselect -OutputInpu ~~~ +You can also add new lights to a bridge: + +~~~PowerShell +Add-HueLight + +Get-HueLight -New +~~~ + ### Hue Devices and Smart Aliases Set-HueLight supports smart aliasing. diff --git a/Rename-HueLight.ps1 b/Rename-HueLight.ps1 index 2f9605c..e0a90f1 100644 Binary files a/Rename-HueLight.ps1 and b/Rename-HueLight.ps1 differ diff --git a/Send-HueBridge.ps1 b/Send-HueBridge.ps1 index 8a52896..e7dc603 100644 --- a/Send-HueBridge.ps1 +++ b/Send-HueBridge.ps1 @@ -11,7 +11,7 @@ function Send-HueBridge Get-HueBridge #> [OutputType([PSObject])] - [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')] + [CmdletBinding(SupportsShouldProcess,ConfirmImpact='Low')] param( # The IP address of the hue bridge. [Parameter(Mandatory,ValueFromPipelineByPropertyName)] @@ -26,14 +26,16 @@ function Send-HueBridge # The command being sent to the bridge. This is a partial URI. [Parameter(ValueFromPipelineByPropertyName)] + [Alias('Uri','Url')] [string] $Command, # The data being sent to the Hue Bridge. # If this data is not a string, it will be converted to JSON. [Parameter(ValueFromPipelineByPropertyName)] + [Alias('Data')] [PSObject] - $Data, + $Body, # The HTTP method. By default, Get. [Parameter(ValueFromPipelineByPropertyName)] @@ -67,17 +69,17 @@ function Send-HueBridge method = $Method } - if ($Data) { - if ($data -is [string]){ - $splat.body = $data + if ($Body) { + if ($Body -is [string]){ + $splat.body = $Body } else { - $splat.body = ConvertTo-Json -Compress -Depth 100 -InputObject $Data + $splat.body = ConvertTo-Json -Compress -Depth 100 -InputObject $Body } } #endregion Construct the Message Body if ($OutputInput -or $WhatIfPreference) { # If -OutputInput or -WhatIf was passed - if ($Data) { $splat.body = $Data } + if ($Body) { $splat.body = $Body } $splat.address = ([uri]$splat.uri).LocalPath # Make an address property with a relative URI $splat.Remove('uri') # and remove URI $splat diff --git a/Set-NanoLeaf.ps1 b/Set-NanoLeaf.ps1 index 9602964..3b00a9a 100644 --- a/Set-NanoLeaf.ps1 +++ b/Set-NanoLeaf.ps1 @@ -34,6 +34,8 @@ delayTime = 1 transTime = 1 } + .Example + Set-NanoLeaf -Palette "#123456", "#654321", "#abcdef", "#fedcba" -PluginType Rhythm -PluginName 'Dancing Duo' .Link Get-NanoLeaf .Link diff --git a/docs/Add-HueLight.md b/docs/Add-HueLight.md new file mode 100644 index 0000000..70717af --- /dev/null +++ b/docs/Add-HueLight.md @@ -0,0 +1,54 @@ + +Add-HueLight +------------ +### Synopsis + +Add-HueLight [[-DeviceID] ] [-WhatIf] [-Confirm] [] + + +--- +### Description +--- +### Parameters +#### **Confirm** +-Confirm is an automatic variable that is created when a command has ```[CmdletBinding(SupportsShouldProcess)]```. +-Confirm is used to -Confirm each operation. + +If you pass ```-Confirm:$false``` you will not be prompted. + + +If the command sets a ```[ConfirmImpact("Medium")]``` which is lower than ```$confirmImpactPreference```, you will not be prompted unless -Confirm is passed. + +#### **DeviceID** + +|Type |Requried|Postion|PipelineInput| +|----------------|--------|-------|-------------| +|```[string[]]```|false |0 |false | +--- +#### **WhatIf** +-WhatIf is an automatic variable that is created when a command has ```[CmdletBinding(SupportsShouldProcess)]```. +-WhatIf is used to see what would happen, or return operations without executing them +--- +### Inputs +None + + +--- +### Outputs +System.Object + + +--- +### Syntax +```PowerShell +syntaxItem +``` +```PowerShell +---------- +``` +```PowerShell +{@{name=Add-HueLight; CommonParameters=True; parameter=System.Object[]}} +``` +--- + + diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cf251e9..3685882 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.2.4 +* Adding Add-HueLight (#18) +* Adding Get-HueLight -New (#21) +* Fixing Rename-HueLight (#19) +* Building LightScript with PipeScript (#20) +--- + ## 0.2.3 * Set-NanoLeaf: Fixing #17 * Send-HueBridge: Adding logging diff --git a/docs/Get-HueLight.md b/docs/Get-HueLight.md index 89a007c..eda58dc 100644 --- a/docs/Get-HueLight.md +++ b/docs/Get-HueLight.md @@ -71,6 +71,16 @@ The light ID. |-------------|--------|-------|---------------------| |```[Int32]```|true |named |true (ByPropertyName)| --- +#### **New** + +If set, will get recently added lights. + + + +|Type |Requried|Postion|PipelineInput | +|--------------|--------|-------|---------------------| +|```[Switch]```|true |named |true (ByPropertyName)| +--- ### Outputs System.Management.Automation.PSObject @@ -89,6 +99,9 @@ Get-HueLight [-RegularExpression] [-ExactMatch] -Room [ [] ``` +```PowerShell +Get-HueLight [-RegularExpression] [-ExactMatch] -New [] +``` --- diff --git a/docs/README.md b/docs/README.md index 41542a8..d49f36f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -63,7 +63,7 @@ Set-HueLight -RoomName Kitchen -RGBColor "#1245ab" Set-HueLight -Name Nightstand1 -Off # Make all of the lights blink once -Set-HueLight -Effect select +Set-HueLight -Alert select # Make all of the lights loop color Set-HueLight -Effect colorloop @@ -74,7 +74,7 @@ Set-HueLight -Effect none Bridges also coordinate schedules, read and write sensors, and process rules. -~~~ +~~~PowerShell # Get all of the sensors Get-HueSensor @@ -87,6 +87,14 @@ Add-HueSchedule -In '00:10:00' -Command (Set-HueLight -Alert lselect -OutputInpu ~~~ +You can also add new lights to a bridge: + +~~~PowerShell +Add-HueLight + +Get-HueLight -New +~~~ + ### Hue Devices and Smart Aliases Set-HueLight supports smart aliasing. @@ -177,7 +185,7 @@ Register-EngineEvent -SourceIdentifier NanoLeaf.Touch.Down -Action { $event.MessageData | Out-Host } -~~~PowerShell +~~~ ## Twinkly @@ -260,3 +268,31 @@ Set-Pixoo -Timer "00:01:00" # Set a timer for one minute Set-Pixoo -RedScore 1 -BlueScore 0 # Keep a scoreboard ~~~ + +## Elgato Key Lighting + +Elgato makes Key Lighting for video recording and streaming. + +The Elgato Control Center will show you the IP Address of your Key Lights from the Accessories' settings. + +Once you know this, run: + +~~~PowerShell +Connect-KeyLight -IPAddress $TheKeyLightIPAddress +~~~ + +Once authenticated, you can: + +~~~PowerShell +# Get information about your lights +Get-KeyLight + +# Turn on your Key Light: +Set-KeyLight -On + +# Change the brightness and ColorTemperature: +Set-KeyLight -ColorTemperature 270 -Brightness 0.25 + +# Turn on and change the brightness at the same time: +Set-KeyLight -On -Brightness 0.25 +~~~ diff --git a/docs/Send-HueBridge.md b/docs/Send-HueBridge.md index a18626a..92f3ade 100644 --- a/docs/Send-HueBridge.md +++ b/docs/Send-HueBridge.md @@ -51,7 +51,7 @@ The command being sent to the bridge. This is a partial URI. |--------------|--------|-------|---------------------| |```[String]```|false |3 |true (ByPropertyName)| --- -#### **Data** +#### **Body** The data being sent to the Hue Bridge. If this data is not a string, it will be converted to JSON. @@ -114,7 +114,7 @@ System.Management.Automation.PSObject --- ### Syntax ```PowerShell -Send-HueBridge [-IPAddress] [-HueUserName] [[-Command] ] [[-Data] ] [[-Method] ] [-OutputInput] [[-PSTypeName] ] [-WhatIf] [-Confirm] [] +Send-HueBridge [-IPAddress] [-HueUserName] [[-Command] ] [[-Body] ] [[-Method] ] [-OutputInput] [[-PSTypeName] ] [-WhatIf] [-Confirm] [] ``` --- diff --git a/docs/Set-NanoLeaf.md b/docs/Set-NanoLeaf.md index d44c3db..6540362 100644 --- a/docs/Set-NanoLeaf.md +++ b/docs/Set-NanoLeaf.md @@ -74,6 +74,11 @@ Set-NanoLeaf -Palette "#ff0000", "#00ff00", "#0000ff", "#000000" -PluginName Fir } ``` +#### EXAMPLE 11 +```PowerShell +Set-NanoLeaf -Palette "#123456", "#654321", "#abcdef", "#fedcba" -PluginType Rhythm -PluginName 'Dancing Duo' +``` + --- ### Parameters #### **Off** diff --git a/en-us/about_LightScript.help.txt b/en-us/about_LightScript.help.txt index 41542a8..d49f36f 100644 --- a/en-us/about_LightScript.help.txt +++ b/en-us/about_LightScript.help.txt @@ -63,7 +63,7 @@ Set-HueLight -RoomName Kitchen -RGBColor "#1245ab" Set-HueLight -Name Nightstand1 -Off # Make all of the lights blink once -Set-HueLight -Effect select +Set-HueLight -Alert select # Make all of the lights loop color Set-HueLight -Effect colorloop @@ -74,7 +74,7 @@ Set-HueLight -Effect none Bridges also coordinate schedules, read and write sensors, and process rules. -~~~ +~~~PowerShell # Get all of the sensors Get-HueSensor @@ -87,6 +87,14 @@ Add-HueSchedule -In '00:10:00' -Command (Set-HueLight -Alert lselect -OutputInpu ~~~ +You can also add new lights to a bridge: + +~~~PowerShell +Add-HueLight + +Get-HueLight -New +~~~ + ### Hue Devices and Smart Aliases Set-HueLight supports smart aliasing. @@ -177,7 +185,7 @@ Register-EngineEvent -SourceIdentifier NanoLeaf.Touch.Down -Action { $event.MessageData | Out-Host } -~~~PowerShell +~~~ ## Twinkly @@ -260,3 +268,31 @@ Set-Pixoo -Timer "00:01:00" # Set a timer for one minute Set-Pixoo -RedScore 1 -BlueScore 0 # Keep a scoreboard ~~~ + +## Elgato Key Lighting + +Elgato makes Key Lighting for video recording and streaming. + +The Elgato Control Center will show you the IP Address of your Key Lights from the Accessories' settings. + +Once you know this, run: + +~~~PowerShell +Connect-KeyLight -IPAddress $TheKeyLightIPAddress +~~~ + +Once authenticated, you can: + +~~~PowerShell +# Get information about your lights +Get-KeyLight + +# Turn on your Key Light: +Set-KeyLight -On + +# Change the brightness and ColorTemperature: +Set-KeyLight -ColorTemperature 270 -Brightness 0.25 + +# Turn on and change the brightness at the same time: +Set-KeyLight -On -Brightness 0.25 +~~~