Skip to content

Commit

Permalink
Merge pull request #52 from StartAutomating/LightScripting-Pixoo
Browse files Browse the repository at this point in the history
Light scripting pixoo
  • Loading branch information
StartAutomating authored Oct 31, 2022
2 parents 9b348ad + 32915b7 commit dd7d1da
Show file tree
Hide file tree
Showing 59 changed files with 324 additions and 185 deletions.
41 changes: 30 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
## 0.2.7:

* Pixoo Improvements:
* Adding Find-Pixoo (Fixes #46)
* Connect-Pixoo: Carrying on DeviceID (Fixes #50)
* Get-Pixoo: Adding -Weather (Fixes #51)
* Set-Pixoo: -Rotation (Fixes #47)
* Set-Pixoo: Adding -Latitutde and -Longitude (Fixes #48)

---


## 0.2.6:
* Set-NanoLeaf:
* Fixing -SaturationIncrement (#35)
* Adding -BrightnessIncrement (#34)
* Fixing -Hue/-Saturation/-Brightness behavior to allow increment parameters to work. (#36)
* Making Parameter Aliases consistent with Set-HueLight (#38)
* Fixing -SaturationIncrement (#35)
* Adding -BrightnessIncrement (#34)
* Fixing -Hue/-Saturation/-Brightness behavior to allow increment parameters to work. (#36)
* Making Parameter Aliases consistent with Set-HueLight (#38)
* Now using [GitPub](https://github.com/StartAutomating/GitPub) to blog (#37).

---

## 0.2.5:
Expand All @@ -15,46 +28,52 @@
* Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
* Add-HueSensor: Adding -New (Fixes #25)
* Improved Repository Organization (Fixes #32)

---

## 0.2.4.1
## 0.2.4.1:
* Adding help for Add-HueLight (#23)
* Fixing other markdown documentation layout issues

---

## 0.2.4
## 0.2.4:
* Adding Add-HueLight (#18)
* Adding Get-HueLight -New (#21)
* Fixing Rename-HueLight (#19)
* Building LightScript with PipeScript (#20)

---

## 0.2.3
## 0.2.3:
* Set-NanoLeaf: Fixing #17
* Send-HueBridge: Adding logging
* Automatically documentating module (#13)
* Set-HueLight:
* Fixing Transition Time (#12)
* Adding examples
* Fixing -Hue/-HueIncrement (#15)

---

## 0.2.2
## 0.2.2:
Adding KeyLight: Connect-KeyLight, Get-KeyLight, Set-KeyLight, Disconnect-KeyLight
---

## 0.2.1
---

## 0.2.1:
* Set-NanoLeaf: Adding -EffectOption parameter help (#9). Adding examples.
* Set-NanoLeaf: Fixing Brightness (#7). Adding Tab Completion (#8). Adding Examples

---

## 0.2:
Adding: Disconnect-HueBridge, Disconnect-NanoLeaf, Disconnect-Twinkly (#2)
Adding Pixoo commands: Connect/Disconnect/Get/Set-Pixoo (#4)

---

## 0.1:
Initial Release of LightScript: Smarter Lighting with PowerShell

Script your Hue Bridge, NanoLeaf, or Twinkly lights.
Script your Hue Bridge, NanoLeaf, or Twinkly lights.
22 changes: 16 additions & 6 deletions Functions/Pixoo/Connect-Pixoo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ function Connect-Pixoo
.Description
Connects to a Pixoo over Wifi
.Example
Connect-Pixoo 1.2.3.4 -PassThru
Find-Pixoo | Connect-Pixoo
.Link
Get-Pixoo
#>
[OutputType([Nullable], [PSObject])]
param(
# The IP Address for the Twinkly device. This can be discovered thru the phone user interface.
# The IP Address for the Pixoo device.
# This can be discovered using Find-Pixoo.
[Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName)]
[Alias('PixooIPAddress')]
[Alias('PixooIPAddress','DevicePrivateIP')]
[IPAddress]
$IPAddress,

# If set, will output the connection information.
[switch]
$PassThru
$PassThru,

# The DeviceID. This can be provided by Find-Pixoo
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$DeviceId
)

begin {
Expand All @@ -38,7 +44,6 @@ function Connect-Pixoo
)
#endregion Attempt to Contact the Device


if ($pixooConf) {
$macAddress =
if ($PSVersionTable.Platform -like 'Win*' -or -not $PSVersionTable.Platform) {
Expand All @@ -60,10 +65,15 @@ function Connect-Pixoo
if (-not $createLightScriptDir) { return }
}


$pixooDataFile = Join-Path $lightScriptRoot ".$($macAddress).pixoo.clixml"
$pixooConf.pstypenames.clear()
$pixooConf.pstypenames.add('Pixoo')

# If the -DeviceID was provided
if ($DeviceId) {
# add it to the configuration data.
$pixooConf | Add-Member NoteProperty DeviceID $DeviceId -Force
}
$pixooConf |
Add-Member NoteProperty IPAddress $IPAddress -Force -PassThru |
Add-Member NoteProperty MACAddress $macAddress -Force -PassThru |
Expand Down
19 changes: 19 additions & 0 deletions Functions/Pixoo/Find-Pixoo.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function Find-Pixoo
{
<#
.SYNOPSIS
Finds Pixoo devices
.DESCRIPTION
Finds Pixoo devices on the local network.
.EXAMPLE
Find-Pixoo
.LINK
https://lightscript.start-automating.com/Find-Pixoo/
.LINK
https://app.divoom-gz.com/Device/ReturnSameLANDevice
#>
param()

Invoke-RestMethod -Uri "https://app.divoom-gz.com/Device/ReturnSameLANDevice" |
Select-Object -ExpandProperty DeviceList
}
23 changes: 20 additions & 3 deletions Functions/Pixoo/Get-Pixoo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ function Get-Pixoo
#>
[CmdletBinding(DefaultParameterSetName="ListDevices")]
param(
# The IP Address for the Twinkly device. This can be discovered thru the phone user interface.
# The IP Address for the Pixoo device.
# This can be discovered thru the phone user interface or by using Find-Pixoo.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('PixooIPAddress')]
[IPAddress[]]
$IPAddress
$IPAddress,

# If set, will get the local weather.
[Parameter(Mandatory,ParameterSetName='Weather')]
[switch]
$Weather
)

begin {
Expand All @@ -34,7 +40,7 @@ function Get-Pixoo
#region Default to All Devices
if (-not $IPAddress) { # If no -IPAddress was passed
if ($home) {
# Read all .twinkly.clixml files beneath your LightScript directory.
# Read all .pixoo.clixml files beneath your LightScript directory.
Get-ChildItem -Path $lightScriptRoot -ErrorAction SilentlyContinue -Filter *.pixoo.clixml -Force |
Import-Clixml |
ForEach-Object {
Expand All @@ -54,5 +60,16 @@ function Get-Pixoo
if ($PSCmdlet.ParameterSetName -eq 'ListDevices') {
return $script:PixooCache.Values
}
if ($PSCmdlet.ParameterSetName -eq 'Weather') {
foreach ($ip in $script:PixooCache.Keys) {
Invoke-RestMethod -uri "http://$ip/post" -Method Post -Body (
@{Command="Device/GetWeatherInfo"} | ConvertTo-Json
) |
& { process {
$_.pstypenames.insert(0,'Pixoo.Weather')
$_
} }
}
}
}
}
1 change: 1 addition & 0 deletions Functions/Pixoo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This directory contains LightScript's functions for Divoom's [Pixoo64](https://w
|----------------|----------|-----|--------------------------------------------|
|Connect-Pixoo |Connect |Pixoo|[Connect-Pixoo.ps1](Connect-Pixoo.ps1) |
|Disconnect-Pixoo|Disconnect|Pixoo|[Disconnect-Pixoo.ps1](Disconnect-Pixoo.ps1)|
|Find-Pixoo |Find |Pixoo|[Find-Pixoo.ps1](Find-Pixoo.ps1) |
|Get-Pixoo |Get |Pixoo|[Get-Pixoo.ps1](Get-Pixoo.ps1) |
|Set-Pixoo |Set |Pixoo|[Set-Pixoo.ps1](Set-Pixoo.ps1) |

Expand Down
48 changes: 46 additions & 2 deletions Functions/Pixoo/Set-Pixoo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,25 @@ function Set-Pixoo
[Parameter(ValueFromPipelineByPropertyName)]
[ValidatePattern('#(?>[a-f0-9]{6}|[a-f0-9]{3})')]
[string]
$RGBColor
$RGBColor,

# The latitude for the device. Must be provided with -Longitude
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('Lat')]
[double]
$Latitude,

# The longitude for the device. Must be provided with -Latitude
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('Long')]
[double]
$Longitude,

# Set the device rotation.
[Parameter(ValueFromPipelineByPropertyName)]
[ValidateSet(0,90,180,270)]
[int]
$Rotation
)

begin {
Expand All @@ -114,6 +132,7 @@ function Set-Pixoo
if ($home) {
$lightScriptRoot = Join-Path $home -ChildPath LightScript
}
$SetPixooCmd = $myInvocation.MyCommand
}

process {
Expand Down Expand Up @@ -206,6 +225,19 @@ function Set-Pixoo
}
}

if ($Latitude -and $longitude) {
$invokeSplat.Body = (@{
Command = "Sys/LogAndLat"
Longitude = $longitude
Latitude = $Latitude
} | ConvertTo-Json -Compress)
if ($whatIfPreference) {
$invokeSplat
} elseif ($psCmdlet.ShouldProcess("$($invokeSplat.Command)")) {
Invoke-RestMethod @invokeSplat
}
}

if ($RGBColor) {
$r,$g,$b =
if ($RGBColor.Length -eq 7) {
Expand Down Expand Up @@ -289,6 +321,18 @@ function Set-Pixoo
}
}

if ($PSBoundParameters.ContainsKey("Rotation")) {
$invokeSplat.Body = (@{
Command = "Device/SetScreenRotationAngle"
Mode = $Rotation / 90
} | ConvertTo-Json -Compress)
if ($whatIfPreference) {
$invokeSplat
} elseif ($psCmdlet.ShouldProcess("$($invokeSplat.Command)")) {
Invoke-RestMethod @invokeSplat
}
}

if ($psBoundParameters.ContainsKey("CustomPlaylist")) {
$invokeSplat.Body = (@{
Command = "Channel/SetCustomPageIndex"
Expand All @@ -299,7 +343,7 @@ function Set-Pixoo
} elseif ($psCmdlet.ShouldProcess("$($invokeSplat.Command)")) {
Invoke-RestMethod @invokeSplat
}
}
}

if ($psBoundParameters.ContainsKey("CloudChannel")) {
$invokeSplat.Body = (@{
Expand Down
1 change: 1 addition & 0 deletions Functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This directory and it's subdirectories contain the functions defined in LightScr
|Disconnect-Twinkly |Disconnect|Twinkly |[Twinkly/Disconnect-Twinkly.ps1](Twinkly/Disconnect-Twinkly.ps1) |
|Find-HueBridge |Find |HueBridge |[Hue/Find-HueBridge.ps1](Hue/Find-HueBridge.ps1) |
|Find-NanoLeaf |Find |NanoLeaf |[NanoLeaf/Find-NanoLeaf.ps1](NanoLeaf/Find-NanoLeaf.ps1) |
|Find-Pixoo |Find |Pixoo |[Pixoo/Find-Pixoo.ps1](Pixoo/Find-Pixoo.ps1) |
|Get-HueBridge |Get |HueBridge |[Hue/Get-HueBridge.ps1](Hue/Get-HueBridge.ps1) |
|Get-HueLight |Get |HueLight |[Hue/Get-HueLight.ps1](Hue/Get-HueLight.ps1) |
|Get-HueResource |Get |HueResource|[Hue/Get-HueResource.ps1](Hue/Get-HueResource.ps1) |
Expand Down
24 changes: 23 additions & 1 deletion LightScript.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.2.6'
ModuleVersion = '0.2.7'
RootModule = 'LightScript.psm1'
Description = 'Smarter Lighting with PowerShell'
FormatsToProcess = 'LightScript.format.ps1xml'
Expand All @@ -14,13 +14,26 @@
LicenseURI = 'https://github.com/StartAutomating/LightScript/blob/main/LICENSE'
IconURI = 'https://github.com/StartAutomating/LightScript/blob/main/Assets/LightScript.png'
ReleaseNotes = @'
## 0.2.7:
* Pixoo Improvements:
* Adding Find-Pixoo (Fixes #46)
* Connect-Pixoo: Carrying on DeviceID (Fixes #50)
* Get-Pixoo: Adding -Weather (Fixes #51)
* Set-Pixoo: -Rotation (Fixes #47)
* Set-Pixoo: Adding -Latitutde and -Longitude (Fixes #48)
---
## 0.2.6:
* Set-NanoLeaf:
* Fixing -SaturationIncrement (#35)
* Adding -BrightnessIncrement (#34)
* Fixing -Hue/-Saturation/-Brightness behavior to allow increment parameters to work. (#36)
* Making Parameter Aliases consistent with Set-HueLight (#38)
* Now using [GitPub](https://github.com/StartAutomating/GitPub) to blog (#37).
---
## 0.2.5:
Expand All @@ -31,18 +44,21 @@
* Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
* Add-HueSensor: Adding -New (Fixes #25)
* Improved Repository Organization (Fixes #32)
---
## 0.2.4.1:
* Adding help for Add-HueLight (#23)
* Fixing other markdown documentation layout issues
---
## 0.2.4:
* Adding Add-HueLight (#18)
* Adding Get-HueLight -New (#21)
* Fixing Rename-HueLight (#19)
* Building LightScript with PipeScript (#20)
---
## 0.2.3:
Expand All @@ -53,20 +69,26 @@
* Fixing Transition Time (#12)
* Adding examples
* Fixing -Hue/-HueIncrement (#15)
---
## 0.2.2:
Adding KeyLight: Connect-KeyLight, Get-KeyLight, Set-KeyLight, Disconnect-KeyLight
---
## 0.2.1:
* Set-NanoLeaf: Adding -EffectOption parameter help (#9). Adding examples.
* Set-NanoLeaf: Fixing Brightness (#7). Adding Tab Completion (#8). Adding Examples
---
## 0.2:
Adding: Disconnect-HueBridge, Disconnect-NanoLeaf, Disconnect-Twinkly (#2)
Adding Pixoo commands: Connect/Disconnect/Get/Set-Pixoo (#4)
---
## 0.1:
Initial Release of LightScript: Smarter Lighting with PowerShell
Expand Down
Loading

0 comments on commit dd7d1da

Please sign in to comment.