cap:adjustable-target-humidity
- change the target humidity¶
The adjustable-target-humidity
capability is an extension to
target-humidity that in addition to reporting the
target humidity also supports setting it.
if(thing.matches('cap:changeable-target-humidity')) {
const humidity = await thing.targetHumidity();
console.log('Target humidity:', humidity);
// Set the target humidity
await thing.targetHumidity(20);
}
API¶
-
targetHumidity
([target])¶ Get or set the current target humidity.
Arguments: - target (percentage) – Optional target humidity to set as a percentage. If specified the thing will update the target humidity.
Returns: Promise that resolves to the current or set target humidity as a percentage.
Example:
const target = await thing.targetHumidity(); await thing.targetHumidity(55);
-
setTargetHumidity
(target)¶ Set the target humidity.
Arguments: - target (percentage) – The target humidity as a percentage.
Returns: Promise that resolves to the set target humidity.
Example:
await thing.setTargetHumidity(40);
Protected methods¶
-
changeTargetHumidity
(target)¶ Abstract. Change the current target humidity.
Arguments: - target (percentage) – The new target humidity as a percentage.
Returns: Promise if asynchronous.
Example:
changeTargetHumidity(target) { return actuallySetTargetHumidity(target); }
Implementing capability¶
When implementing this capability the implementor needs to call
updateTargetHumidity
whenever a change in target humidity is detected.
The changeTargetHumidity
method must also be implemented.
const { Thing } = require('abstract-things');
const { AdjustableTargetHumidity } = require('abstract-things/climate');
class Example extends Thing.with(AdjustableTargetHumidity) {
changeTargetHumidity(target) {
return actuallySetTargetHumidity(target);
}
}