Device

Device

Control the device power state
Note: You must wait for the Agent to initialise before calling any of these methods.

Methods

(async) addDeviceOption(name, value) → {Promise}

Add a new Device Option or update an existing Device Option

Parameters:
Name Type Description
name string

The key/name of the option to add

value string

The value of the option to add

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Add a device option to this device
     await agent.Device.addDeviceOption('myDeviceOption', 'value');
};

(async) addOption(name, value, scopeIdopt) → {Promise}

Add a new Display Option or update an existing Display Option

Parameters:
Name Type Attributes Default Description
name string

The key/name of the option to add

value string

The value of the option to add

scopeId Number <optional>
CURRENT_DISPLAY

The id of the display (this is populated dynamically)

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Add the Display Option to the current display
     // Note: The scopeId will populated automatically for you (can be overriden).
     await agent.Device.addOption('myOption', 'myOptionValue');
};

(async) deleteDeviceOption(name) → {Promise}

Delete a Device Option

Parameters:
Name Type Description
name String

The key/name of the option to delete

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Delete a device option from this device
     await agent.Device.deleteDeviceOption('myDeviceOption');
};

(async) deleteOption(name, scopeIdopt) → {Promise}

Delete a Display Option

Parameters:
Name Type Attributes Default Description
name String

The key/name of the option to delete

scopeId Number <optional>
CURRENT_DISPLAY

The display this option will be delete from (this is populated dynamically)

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Delete the Display Option from the current display
     // Note: The scopeId will populated automatically for you (can be overriden).
     await agent.Device.deleteOption('myOption');
};

(async) getDeviceOptions(scopeIdopt) → {Promise}

Get the Options for this Device

Parameters:
Name Type Attributes Default Description
scopeId Number <optional>
CURRENT_DISPLAY

The display this option will be delete

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Get the device options for this device
     const deviceOptions = await agent.Device.getDeviceOptions();

     console.log('Here are the device options', deviceOptions);
};

(async) getOptions(scopeIdopt) → {Promise}

Get the Options for this Display

Parameters:
Name Type Attributes Default Description
scopeId Number <optional>
CURRENT_DISPLAY

The id of the display (this is populated dynamically)

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Get the Display Options for the current display
     const options = await agent.Device.getOptions();
};

(async) properties() → {Promise.<module:Device~DeviceProperties>}

Retrieve Device properties

Example

Example requesting properties. Example result: 1

import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Get the properties from this device
     const properties = await agent.Device.properties();
     console.log(properties);
};

(async) reboot() → {Promise}

Request the AgentM application to Reboot the Device.

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();
     await agent.Device.reboot();
     console.log('Rebooting the device');
};

init();

(async) reload() → {Promise}

Request the AgentM application to Reload Note: This is not the same as a reboot

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();
     await agent.Device.reload();
     console.log('Reloading the device');
};

init();

(async) sleep() → {Promise}

Request the device to sleep the displays

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();
     await agent.Device.sleep();
     console.log('The device will now go to sleep');
};

(async) updateDeviceOption(name, value) → {Promise}

Update an existing Device Option

Parameters:
Name Type Description
name String

The key/name of the option to update

value String

The value of the option to update

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Update a device option on this device
     await agent.Device.updateDeviceOption('myDeviceOption', 'updatedValue');
};

(async) updateOption(name, value, scopeId) → {Promise}

Update an existing Display Option

Parameters:
Name Type Description
name String

The key/name of the option to update

value String

The value of the option to update

scopeId Integer

The id of the display (this is populated dynamically)

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();

     // Update the Display Option on the current display
     // Note: The scopeId will populated automatically for you (can be overriden).
     await agent.Device.updateOption('myOption', 'myOptionValue');
};

(async) wake() → {Promise}

Request the device to wake the displays

Example
import Agent from '@meldcx/agent';

const agent = new Agent();

const init = async() => {
     await agent.onReadyAsync();
     await agent.Device.wake();
     console.log('The device should be awake now');
};

init();