cap:audio-feedback - if thing emits audio feedback

audio-feedback is used by things that can report if they emit audio feedback or not. Such feedback can be as simple as beeping when certain buttons are pressed or when certain actions are performed. It may also be more advanced audio such as spoken commands. This capability is commonly paired with adjustable-audio-feedback if the the thing support toggling audio feedback on and off.

if(thing.matches('cap:audio-feedback')) {
        console.log('Audio feedback on:', await thing.audioFeedback());

        thing.on('audioFeedbackChanged', on => console.log('Audio feedback is now:', on));
}

API

audioFeedback()

Get if the thing emits audio feedback.

Returns:Promise that resolves to a boolean representing if audio feedback is enabled.

Example:

thing.audioFeedback()
        .then(on => ...)
        .catch(...);

const on = await thing.audioFeedback();

Events

audioFeedbackChanged

The current audio feedback state has changed. Payload will be if the feedback is enabled.

thing.on('audioFeedbackChanged', on => ...)

Protected methods

updateAudioFeedback(enabled)

Update if audio feedback is currently enabled.

Arguments:
  • enabled (boolean) – If the feedback is enabled.

Implementing capability

This capability requires that the implementors calls updateAudioFeedback when changes are detected.

Example:

const { Thing, AudioFeedback } = require('abstract-things');

class Example extends Thing.with(AudioFeedback) {

}