RuleAction
A RuleAction is an object that defines an action that can be performed when a Rule is triggered in the Hue Bridge.
There are a number of different types of RuleActions that can be built and to aid in this, the API provides a
fluent interface for building up the various RuleActionss for Rules.
Instantiating a RuleAction
A RuleAction can be built using the v3.model.ruleActions Object, currently this allows for the creation of actions
via the functions:
light: Creates aLightStateActionthat will set aLightStateon a specificLightgroup: Creates aGroupStateActionthat will set a stateGroupLightStateon aGroupsensor: Creates aSensorStateActionthat will set a state on aCLIPSensorObject
RuleAction
The base RuleAction class is a common base to all RuleAction types. It has the following properties and functions:
address:getthe address target for theRuleActionbody:getthe body payload for theRuleActionid:getthe id for the target of theRuleAction, e.g. the Light id, Group id, Sensor idmethod:getthe method of theRuleAction, in most cases this isPUTas the majority of actions are updateswithMethod(method): sets the method of theRuleActiontoString(): Obtains a String representation of theRuleActionpayload(): Obtains the payload that is set into the Hue Bridge for theRuleActionwhen theRuleis updated/created
LightStateAction
A LightStateAction is a RuleAction that will help in constructing the RuleAction for setting a LightState on a Light
when a rule is triggered.
It contains all the properties and functions for RuleAction above.
Instantiation
To get an instance of a LightStateAction use the function v3.rules.actions.light(id)
id: The id for the light or aLightinstance obtained from the bridge
The function will return an instance of a LightStateAction.
withState(state)
The withState(state) function allows you to specify the state that will be applied to the Light.
state: TheLightStateto apply to theLight, or a JSON payload of attributes that will be transformed in aLightState, e.g.{on: true}.
The function will return the instance of the LightStateAction so you can chain calls.
GroupStateAction
A GroupStateAction is a RuleAction that will help in constructing the RuleAction for setting a GroupLightState
on a Group when a rule is triggered.
It contains all the properties and functions for RuleAction above.
Instantiation
To get an instance of a GroupStateAction use the function v3.rules.actions.group(id)
id: The id for the group or aGroupinstance obtained from the bridge
The function will return an instance of a GroupStateAction.
withState(state)
The withState(state) function allows you to specify the state that will be applied to the Group.
state: TheGroupLightStateto apply to theGroup, or a JSON payload of attributes that will be transformed in aGroupLightState, e.g.{on: true}.
The function will return the instance of the GroupStateAction so you can chain calls.
SensorStateAction
A SensorStateAction is a RuleAction that will help in constructing the RuleAction for setting a Sensors state
attributes when a rule is triggered.
It contains all the properties and functions for RuleAction above.
Instantiation
To get an instance of a SensorStateAction use the function v3.rules.actions.sensor(id)
id: The id for the sensor or aSensorinstance obtained from the bridge
The function will return an instance of a SensorStateAction.
withState(state)
The withState(state) function allows you to specify the state that will be applied to the Sensor.
state: A JSON payload of attributes that will be modified on theSensor, e.g:{flag: true}
The function will return the instance of the SensorStateAction so you can chain calls.
SceneAction
A SceneAction is a RuleAction that will help to constructo a RuleAction for saving a Scene's state when triggered
It contains all the properties and functions for RuleAction above.
Instantiation
To get an instance of a SensotStateAction use the function v3.rules.actions.scene(id)
id: The id for the sensor or aSceneinstance obtained from the bridge
The function will return an instance of a SceneAction.
withState(state)
The withState(state) function allows you to specify the state that will be applied to the Scene.
state: A JSON payload of attributes that will be modified on theSensor, e.g:{storelightstate: true}
The function will return the instance of the SceneAction so you can chain calls.