From 3d96e34d6a719f63ac9310041c9e7182f8cd12d4 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Mon, 3 Oct 2022 05:36:18 +0000 Subject: [PATCH] Set-HueRule: Easier conditions (Fixes #28) and plural aliases (Fixes #31) --- docs/Set-HueRule.md | 91 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/docs/Set-HueRule.md b/docs/Set-HueRule.md index 96bf0c2..9aa100c 100644 --- a/docs/Set-HueRule.md +++ b/docs/Set-HueRule.md @@ -30,6 +30,79 @@ Set-HueRule -Condition { } -Name BrightenRoom ``` +#### EXAMPLE 2 +```PowerShell +# Set a rule that when +Set-HueRule -Condition { + "/sensors/61/state/buttonevent" -eq "4002" +} -Action { + Set-HueLight -RoomName "Sunroom" -Brightness 0.01 +} -Name SunroomDimmerTap +``` + +#### EXAMPLE 3 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "4003" +} -Action { + Set-HueLight -RoomName "Sunroom" -Off +} -Name SunroomDimmerHoldDownToTurnOff +``` + +#### EXAMPLE 4 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "1003" +} -Action { + Set-HueLight -RoomName "Sunroom" -On +} -Name SunroomDimmerHoldUpToTurnOn +``` + +#### EXAMPLE 5 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "1002" +} -Action { + Set-HueLight -RoomName "Sunroom" -On -Brightness .8 +} -Name SunroomDimmerTapOn +``` + +#### EXAMPLE 6 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "2003" +} -Action { + Set-HueLight -RoomName "Sunroom" -BrightnessIncrement .1 +} -Name SunroomDimmerHoldBright +``` + +#### EXAMPLE 7 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "2002" +} -Action { + Set-HueLight -RoomName "Sunroom" -BrightnessIncrement .05 +} -Name SunroomDimmerTapBright +``` + +#### EXAMPLE 8 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "3002" +} -Action { + Set-HueLight -RoomName "Sunroom" -BrightnessIncrement -.05 +} -Name SunroomDimmerTapDarken +``` + +#### EXAMPLE 9 +```PowerShell +Set-HueRule -Condition { + "/sensors/SunroomDimmerSwitch/state/buttonevent" -eq "3003" +} -Action { + Set-HueLight -RoomName "Sunroom" -BrightnessIncrement -.1 +} -Name SunroomDimmerHoldDarken +``` + --- ### Parameters #### **Name** @@ -53,6 +126,9 @@ The name of the rule. The condition. If the value is a ScriptBlock, only operators and their surrounding conext will be accepted. +Each condition should take the form: `"/resource/id/restOfAddress" -operator "value"`. +Rules may have more than one condition. +If the address is not a resource followed by a digit, the resource will be looked up by name. @@ -142,6 +218,19 @@ If set, will disable the rule. +--- +#### **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 +#### **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. + --- ### Outputs * [Management.Automation.PSObject](https://learn.microsoft.com/en-us/dotnet/api/System.Management.Automation.PSObject) @@ -152,7 +241,7 @@ If set, will disable the rule. --- ### Syntax ```PowerShell -Set-HueRule [-Name] [-Condition] [-Action] [-DeviceID ] [-IPAddress ] [-Disable] [] +Set-HueRule [-Name] [-Condition] [-Action] [-DeviceID ] [-IPAddress ] [-Disable] [-WhatIf] [-Confirm] [] ``` ---