What is a RuleCondition and how to build them
typescriptA RuleCondition is an object that defines the criteria used to trigger a Rule on the Hue Bridge. The API provides a fluent interface via v3.model.ruleConditions to build these conditions. Currently, you can build conditions for two types of entities:
- Sensors: Using
v3.model.ruleConditions.sensor(sensor) - Groups: Using
v3.model.ruleConditions.group(id)
To finalize the builder and obtain a valid RuleCondition object, you must call .getRuleCondition() at the end of your fluent chain. If the configuration is invalid, this method will throw an ApiError.
const v3 = require('node-hue-api').v3;
const conditions = v3.model.ruleConditions;
// Example pattern for building a condition
const ruleCondition = conditions.sensor(mySensor)
.when('attribute')
.equals(value)
.getRuleCondition();