Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
f351606
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
061e767
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
60333ab
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
ca9b02e
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
04b0b78
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
7732594
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
8cf5f54
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
01637e8
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
2f60cca
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
ca46a1b
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
761d24a
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
c2ec8f2
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
819aacf
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
55ec1d6
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
119c5e5
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
8ef41af
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
3587ffe
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
ba1319e
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
6b9e545
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
a09ce4c
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
5e42eab
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
e6d2513
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
dc3a2d6
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
4033965
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
ab1d021
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
d4dcfd6
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
dc04ad4
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
0c90ec6
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
18754dc
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
f1becf1
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
e22faed
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
58968cf
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
8329ef1
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
77c3798
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
b0377b4
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
fcce4de
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
a4c41b7
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
78737b1
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
9dfc330
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
4d0cc6b
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
fcb97e4
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
1f6696e
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
7429770
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
c68685f
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
fd64fc5
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
8ef49ce
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
e7eafd6
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
4d9ab4f
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
230e61a
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
0c856fe
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
bbd70a2
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
86a1b31
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
9219417
Add-HueSensor: Adding -New (Fixes #25)
Oct 3, 2022
8f244e8
Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
Oct 3, 2022
59cf826
Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
Oct 3, 2022
a5aac3b
Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
Oct 3, 2022
9c80249
Set-HueLight: Fixing -Brightness/SaturationIncrement (Fixes #29)
Oct 3, 2022
a39811c
Get-HueBridge: SupportShouldProcess (Fixes #30)
Oct 3, 2022
dd6f320
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
f48ea14
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
9193877
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
40667d8
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
d363a01
Adding Rename-HueSensor (Fixes #26). Adding [Alias('ID')] to -OldNam…
Oct 3, 2022
4c36ea1
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
231b004
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
178858e
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
ce01fd6
Merge branch 'HueSensorImprovement' of https://github.com/StartAutoma…
Oct 3, 2022
9e7ad4c
Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes…
Oct 3, 2022
3d96e34
Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes…
Oct 3, 2022
5fe9405
Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes…
Oct 3, 2022
0a087b2
Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes…
Oct 3, 2022
f88cc29
Organizing functions into subdirectories (Fixes #32)
Oct 3, 2022
c1f4f97
Organizing functions into subdirectories (Fixes #32)
Oct 3, 2022
cbfc5a8
Organizing functions into subdirectories (Fixes #32)
Oct 3, 2022
16e8b18
Adding /functions/README.ps1.md (re #32)
Oct 3, 2022
784d5e3
Adding /functions/README.ps1.md (re #32)
Oct 3, 2022
fbca6c7
Adding /functions/README.ps1.md (re #32)
Oct 3, 2022
ffd108d
Adding /functions/README.ps1.md (re #32)
Oct 3, 2022
1901692
Adding /functions/README.ps1.md (re #32)
Oct 3, 2022
be1b1a4
Adding more /functions/README.ps1.md (re #32)
Oct 3, 2022
20b9ddc
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
40e169a
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
b528ed8
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
84750e7
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
c459da2
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
78ad611
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
9a6fb5a
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
c9b07d8
Fixing README.ps1.md imports (re #32)
Oct 3, 2022
c5b4824
Updating Module Version [0.2.5] and CHANGELOG
Oct 3, 2022
760bf1a
Updating Module Version [0.2.5] and CHANGELOG
Oct 3, 2022
d6ed219
Updating Module Version [0.2.5] and CHANGELOG
Oct 3, 2022
014e5bd
Updating Module Version [0.2.5] and CHANGELOG
Oct 3, 2022
1d7892b
Updating Module Version [0.2.5] and CHANGELOG
Oct 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Add-HueSensor.ps1
Binary file not shown.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
## 0.2.5:
* Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes #31)
* Adding Rename-HueSensor (Fixes #26).
* Rename-HueLight: Adding [Alias('ID')] to -OldName (Fixes #27)
* Get-HueBridge: SupportShouldProcess (Fixes #30)
* 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)
Expand Down
8 changes: 3 additions & 5 deletions Add-HueLight.ps1 → Functions/Hue/Add-HueLight.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Add-HueLight {
<#
<#
.SYNOPSIS
Adds lights to Hue
.DESCRIPTION
Expand All @@ -15,12 +15,10 @@ function Add-HueLight {
Get-HueLight
.LINK
Set-HueLight
#>

[CmdletBinding(SupportsShouldProcess)]


#>

[CmdletBinding(SupportsShouldProcess)]
param(
# One or more Device Identifiers (serial numbers ).
# Use this parameter when adding lights that have already been assigned to another bridge.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
110 changes: 110 additions & 0 deletions Functions/Hue/Add-HueSensor.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
function Add-HueSensor
{
<#
.Synopsis
Adds a sensor to a Hue Bridge.
.Description
Adds sensors to a Hue Bridge.
Sensors can be physical sensors, such as a motion detector, or virtual sensors, such as GenericFlag.
.Link
Get-HueSensor
.Example
Add-HueSensor -Name "ChaseStatus1" -SensorType GenericStatus
#>
[OutputType([PSObject])]
[CmdletBinding(SupportsShouldProcess)]
param(
# The name of the sensor.
[Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName,ParameterSetName='CustomSensor')]
[string]
$Name,

<#

The sensor type.

Sensors can be:

* Switches
* OpenClose
* Presence (motion detectors)
* Temperature
* Humidity
* LightLevel
* GenericFlag (used for virtual sensors)
* GenericStatus (used for virtual sensors)
#>
[Parameter(Mandatory,Position=1,ValueFromPipelineByPropertyName,ParameterSetName='CustomSensor')]
[ValidateSet('Switch','OpenClose','Presence','Temperature','Humidity','LightLevel', 'GenericFlag', 'GenericStatus')]
[string]
$SensorType,

# The sensor ModelID
[Parameter(Position=2,ValueFromPipelineByPropertyName,ParameterSetName='CustomSensor')]
[string]
$ModelID = "ABCD-12345",

# The sensor manufacturer
[Parameter(Position=2,ValueFromPipelineByPropertyName,ParameterSetName='CustomSensor')]
[string]
$Manufacturer = "ACME LTD",

# The sensor unique ID.
[Parameter(Position=3,ValueFromPipelineByPropertyName,ParameterSetName='CustomSensor')]
[string]
$UniqueID= [guid]::NewGuid().tostring('n'),

# The sensor version.
[Parameter(Position=4,ValueFromPipelineByPropertyName,ParameterSetName='CustomSensor')]
[Version]
$Version = '0.1',

# If set, will search for new sensors to add.
[Parameter(Mandatory,ParameterSetName='NewSensor')]
[Alias('Find','Discover')]
[switch]
$New
)

begin {
$myCmd = $MyInvocation.MyCommand
}

process {
#region Prepare REST Input
$sensorRest =
if ($PSCmdlet.ParameterSetName -eq 'CustomSensor') {
if ($SensorType) {
$sensorType =
foreach ($_ in $myCmd.Parameters['SensorType'].Attributes) {
if (-not $_.ValidValues) { continue }
$_.ValidValues -eq $SensorType
break
}
}

@{
name = $Name
modelid = $ModelID
swversion = "$Version"
type = 'CLIP' + $SensorType
uniqueid = $UniqueID
manufacturername = $Manufacturer
recycle = $false
}
} elseif ($New) {
$name = "new"
}
#endregion Prepare REST Input


if ($WhatIfPreference) {
return $sensorRest
}

if ($PSCmdlet.ShouldProcess("Add-HueSensor $name")) {
Get-HueBridge |
Send-HueBridge -Method POST -Data $sensorRest -Command "sensors"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions Get-HueBridge.ps1 → Functions/Hue/Get-HueBridge.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
.Example
Get-HueBridge
#>
[CmdletBinding(DefaultParameterSetName='ConnectionInfo')]
[OutputType([PSObject])]
[CmdletBinding(DefaultParameterSetName='ConnectionInfo',SupportsShouldProcess)]
[OutputType([PSObject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="Parameters used as hints for Parameter Sets")]
param(
# If set, will get the schedules defined on the Hue bridge
Expand Down Expand Up @@ -131,6 +131,7 @@
$bridges | # Get all bridges
Send-HueBridge -Command $PSCmdlet.ParameterSetName.ToLower() | # get the set of data we want from the bridge.
ForEach-Object {
if ($WhatIfPreference) { return $_ }
if ('Config', 'Capabilities' -contains $psCmdlet.ParameterSetName) {
return $_ # config and capabilities are directly returned.
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions Functions/Hue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
This directory contains LightScript's functions for [Philips Hue Bridges](https://www.philips-hue.com/).


|Name |Verb |Noun |Source |
|--------------------|----------|-----------|----------------------------------------------------|
|Add-HueLight |Add |HueLight |[Add-HueLight.ps1](Add-HueLight.ps1) |
|Add-HueRoom |Add |HueRoom |[Add-HueRoom.ps1](Add-HueRoom.ps1) |
|Add-HueSchedule |Add |HueSchedule|[Add-HueSchedule.ps1](Add-HueSchedule.ps1) |
|Add-HueSensor |Add |HueSensor |[Add-HueSensor.ps1](Add-HueSensor.ps1) |
|Connect-HueBridge |Connect |HueBridge |[Connect-HueBridge.ps1](Connect-HueBridge.ps1) |
|Disconnect-HueBridge|Disconnect|HueBridge |[Disconnect-HueBridge.ps1](Disconnect-HueBridge.ps1)|
|Find-HueBridge |Find |HueBridge |[Find-HueBridge.ps1](Find-HueBridge.ps1) |
|Get-HueBridge |Get |HueBridge |[Get-HueBridge.ps1](Get-HueBridge.ps1) |
|Get-HueLight |Get |HueLight |[Get-HueLight.ps1](Get-HueLight.ps1) |
|Get-HueResource |Get |HueResource|[Get-HueResource.ps1](Get-HueResource.ps1) |
|Get-HueRoom |Get |HueRoom |[Get-HueRoom.ps1](Get-HueRoom.ps1) |
|Get-HueRule |Get |HueRule |[Get-HueRule.ps1](Get-HueRule.ps1) |
|Get-HueScene |Get |HueScene |[Get-HueScene.ps1](Get-HueScene.ps1) |
|Get-HueSchedule |Get |HueSchedule|[Get-HueSchedule.ps1](Get-HueSchedule.ps1) |
|Get-HueSensor |Get |HueSensor |[Get-HueSensor.ps1](Get-HueSensor.ps1) |
|Read-HueSensor |Read |HueSensor |[Read-HueSensor.ps1](Read-HueSensor.ps1) |
|Remove-HueResource |Remove |HueResource|[Remove-HueResource.ps1](Remove-HueResource.ps1) |
|Remove-HueRoom |Remove |HueRoom |[Remove-HueRoom.ps1](Remove-HueRoom.ps1) |
|Remove-HueRule |Remove |HueRule |[Remove-HueRule.ps1](Remove-HueRule.ps1) |
|Remove-HueScene |Remove |HueScene |[Remove-HueScene.ps1](Remove-HueScene.ps1) |
|Remove-HueSchedule |Remove |HueSchedule|[Remove-HueSchedule.ps1](Remove-HueSchedule.ps1) |
|Remove-HueSensor |Remove |HueSensor |[Remove-HueSensor.ps1](Remove-HueSensor.ps1) |
|Rename-HueLight |Rename |HueLight |[Rename-HueLight.ps1](Rename-HueLight.ps1) |
|Rename-HueSensor |Rename |HueSensor |[Rename-HueSensor.ps1](Rename-HueSensor.ps1) |
|Send-HueBridge |Send |HueBridge |[Send-HueBridge.ps1](Send-HueBridge.ps1) |
|Set-HueLight |Set |HueLight |[Set-HueLight.ps1](Set-HueLight.ps1) |
|Set-HueRule |Set |HueRule |[Set-HueRule.ps1](Set-HueRule.ps1) |
|Write-HueSensor |Write |HueSensor |[Write-HueSensor.ps1](Write-HueSensor.ps1) |


15 changes: 15 additions & 0 deletions Functions/Hue/README.ps1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This directory contains LightScript's functions for [Philips Hue Bridges](https://www.philips-hue.com/).

~~~PipeScript {
Import-Module ../../LightScript.psd1 -Global
[PSCustomObject]@{
Table = Get-Command -Module LightScript |
Where-Object { $_.ScriptBlock.File -like "$pwd*" } |
.Name .Verb .Noun .Source {
$relativePath = $_.ScriptBlock.File.Substring("$pwd".Length) -replace '^[\\/]'
"[$relativePath]($relativePath)"
}
}

}
~~~
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions Rename-HueLight.ps1 → Functions/Hue/Rename-HueLight.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ function Rename-HueLight
[OutputType([PSObject])]
param(
# The old name of the light. This can be a wildcard or regular expression.
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Alias('ID')]
[string]
$OldName,

# The new name of the light. A number sign will be replaced with the match number.
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]
$NewName
)
Expand Down
55 changes: 55 additions & 0 deletions Functions/Hue/Rename-HueSensor.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function Rename-HueSensor
{
<#
.Synopsis
Renames Hue Sensors
.Description
Renames one or more Hue Sensors.
.Example
Rename-HueSensor
.Link
Get-HueBridge
.Link
Get-HueSensor
#>
[OutputType([PSObject])]
param(
# The old name of the Sensor. This can be a wildcard or regular expression.
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Alias('ID')]
[string]
$OldName,

# The new name of the Sensor. A number sign will be replaced with the match number.
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]
$NewName
)

begin {
$Sensors = Get-HueSensor
$bridges = Get-HueBridge
}

process {
$Sensors |
Where-Object {
#region Find matching Sensors
($_.Id -eq $oldName) -or
($_.Name -like $OldName) -or
($oldName -as [regex] -and $_.Name -match $oldName)
#endregion Find matching Sensors
} |
ForEach-Object -Begin {
$matchCount = 0
} -Process {
#region Rename the Sensors
$MatchCount++
$realNewName = $NewName -replace '#', $MatchCount
$SensorToRename = $_
$bridges | Send-HueBridge -Command "sensors/$($SensorToRename.id)" -Method PUT -Data @{name=$realNewName}
#endregion Rename the Sensors
}
}
}

File renamed without changes.
30 changes: 28 additions & 2 deletions Set-HueLight.ps1 → Functions/Hue/Set-HueLight.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,42 @@ function Set-HueLight
[float[]]
$XY,

# The increment in saturation. This will adjust the intensity of the color
# The increment in saturation. This will adjust the intensity of the color.
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('sat_inc')]
[ValidateRange(-1,1)]
[ComponentModel.AmbientValue({
if ($_ -lt 0) {
[Math]::max(-254,
([int][Math]::Floor(([Math]::Abs($_) / 1) * [byte]::maxValue)) * -1
)
} elseif ($_ -gt 0) {
[Math]::min(254,
[int][Math]::Floor(($_ / 1) * [byte]::maxValue)
)
} else {
0
}
})]
[float]
$SaturationIncrement,

# An increment in luminance. This will adjust the brightness of the light
# An increment in luminance. This will adjust the brightness of the light.
[Parameter(ValueFromPipelineByPropertyName)]
[ComponentModel.DefaultBindingProperty('bri_inc')]
[ComponentModel.AmbientValue({
if ($_ -lt 0) {
[Math]::max(-254,
([int][Math]::Floor(([Math]::Abs($_) / 1) * [byte]::maxValue)) * -1
)
} elseif ($_ -gt 0) {
[Math]::min(254,
[int][Math]::Floor(($_ / 1) * [byte]::maxValue)
)
} else {
0
}
})]
[Alias('LuminanceIncrement')]
[ValidateRange(-1,1)]
[float]
Expand Down
Loading