The Hue Bridge supports Rules to define complex automation activities. The Rule
object can be built up to support a
number of RuleConditions
which when all evaluating to true
will trigger one or more RuleActions
to modify states
of Lights, Groups, CLIP Sensors or Schedules.
- Creating a New Rule
- Rule Properties
- addCondition()
- removeConditionAt(idx)
- clearConditions()
- addAction()
- removeActionAt(idx)
- clearActions()
You can create a Rule
by using the new
operator.
const Rule = require('node-hue-api').v3.rules.Rule;
const myRule = new Rule();
All Rules MUST have at least one RuleCondition
and RuleAction
associated with them for the Bridge to consider them
valid. You can add these to a Rule
using the addAction(action)
and addCondition(condition)
functions on the Rule
.
Consult the RuleAction
and RuleCondition
documentation for creating the
various types of Actions and Conditions for a Rule.
- id
- name
- owner
- lasttriggered
- timestriggered
- status
- recycle
- conditions
- actions
- toString()
- toStringDetailed()
Get the id
for the Scene.
get
Get/Set a name for the Scene.
get
set
Gets the owner of the Scene.
get
Gets the last triggered time for the Rule.
get
Gets the number of times that the Rule has been triggered
get
Gets the status of the Rule, which can be enabled
, resourcedeleted
and possibly other states, but these are not
documented via the Hue API.
get
Get/Set the recyle
attribute of the Rule. This is used to flag scenes that can be automatically deleted by the bridge.
If the recycle
state is set to false
the Hue bridge will keep the scene until an application removes it.
get
set
Gets the RuleCondition
s that are set on the Rule. These are the conditions that all must evaluate to true
to
trigger the rule's RuleAction
s.
get
Gets the RuleAction
s that are set on the Rule. These are the actions that will be triggered if the all the RuleCondtion
s
evaluate to true
.
get
The toString()
function will obtain a simple String
representation of the Scene.
The toStringDetailed()
function will obtain a more detailed representation of the Scene object.
The addCondition(condition)
function will add a new RuleCondition
to the existing conditions on the Rule
.
condition
: The newRuleCondition
to be added.
Consult the RuleCondition documentation on creating a RuleCondition
instance.
The removeConditionAt(idx)
function will remove the RuleCondition
that is at the specified index idx
from the Array
of RuleConditions
on the Rule
.
idx
: The index of theRuleCondition
in the Rule to remove.
The clearConditions()
function will reset all the conditions on the Rule to an empty Array
. You will need to add at
least one RuleCondition
after do this for the Rule to be valid.
The AddAction(action)
function will add a new RuleAction
to the existing actions on the Rule
.
action
: The newRuleAction
to be added.
Consult the RuleAction documentation on creating a RuleAction
instance.
The removeActionAt(idx)
function will remove the RuleAction
at the specified idx
index value from the
RuleActions
on the Rule
.
idx
: The index of theRuleAction
in the Rule to remove.
The clearActions()
function will reset all the actions on the Rule to an empty Array
. You will need to add at least
one RuleAction
after this for the Rule to be valid.