--- title: "Device" slug: "100-manage-device" updated: 2025-05-27T18:17:55Z published: 2025-05-27T18:17:55Z canonical: "docs.developer.comcast.com/100-manage-device" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.developer.comcast.com/llms.txt > Use this file to discover all available pages before exploring further. # Device **Device Module 1.0.0 | Manage SDK** ## Usage To use the Device module, you can import it into your project from the Firebolt SDK: ``` import { Device } from '@firebolt-js/manage-sdk' ``` ## Overview A module for querying about the device and it's capabilities. ## Methods ### listen To listen to a specific event pass the event name as the first parameter: ``` listen(event: string, callback: (data: any) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event to listen for, see [Events](/docs/100-manage-device#events). | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Device.clear(id)` | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-manage-device#events). | To listen to all events from this module pass only a callback, without specifying an event name: ``` listen(callback: (event: string, data: any) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see [Events](/docs/100-manage-device#events). | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event that has occured listen for, see [Events](/docs/100-manage-device#events). | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-manage-device#events). | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Device.clear(id)` | See [Listening for events](/docs/listening-for-events/) for more information and examples. ### name The human readable name of the device To get the value of `name` call the method like this: ``` function name(): Promise ``` Promise resolution: ``` string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:device:name | #### Examples Default example #1 JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.name() .then(value => { console.log(value) }) ``` Value of `value`: ``` "Living Room" ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.name", "params": {} } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": "Living Room" } ``` Default example #2 JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.name() .then(value => { console.log(value) }) ``` Value of `value`: ``` "Living Room" ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.name", "params": {} } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": "Kitchen" } ``` --- To set the value of `name` call the method like this: ``` function name(value: string): Promise ``` Parameters: | Param | Type | Required | Description | | --- | --- | --- | --- | | `value` | `string` | true | the device friendly-name | Promise resolution: ``` null ``` #### Examples Default example #1 JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.name("Living Room") .then(result => { console.log(result) }) ``` Value of `result`: ``` null ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.setName", "params": { "value": "Living Room" } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": null } ``` Default example #2 JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.name("Kitchen") .then(result => { console.log(result) }) ``` Value of `result`: ``` null ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.setName", "params": { "value": "Kitchen" } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": null } ``` --- To subscribe to notifications when the value changes, call the method like this: ``` function name(callback: (value) => string): Promise ``` Promise resolution: ``` number ``` #### Examples Default example #1 JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' name(value => { console.log(value) }).then(listenerId => { console.log(listenerId) }) ``` Value of `value`: ``` "Living Room" ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.onNameChanged", "params": { "listen": true } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": "Living Room" } ``` Default example #2 JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' name(value => { console.log(value) }).then(listenerId => { console.log(listenerId) }) ``` Value of `value`: ``` "Living Room" ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.onNameChanged", "params": { "listen": true } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": "Kitchen" } ``` --- ### once To listen to a single instance of a specific event pass the event name as the first parameter: ``` once(event: string, callback: (data: any) => void): Promise ``` The `once` method will only pass the next instance of this event, and then dicard the listener you provided. Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event to listen for, see [Events](/docs/100-manage-device#events). | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Device.clear(id)` | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-manage-device#events). | To listen to the next instance only of any events from this module pass only a callback, without specifying an event name: ``` once(callback: (event: string, data: any) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see [Events](/docs/100-manage-device#events). | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event that has occured listen for, see [Events](/docs/100-manage-device#events). | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-manage-device#events). | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Device.clear(id)` | See [Listening for events](/docs/listening-for-events/) for more information and examples. ### provision Used by a distributor to push provision info to firebolt. ``` function provision(accountId: string, deviceId: string, distributorId?: string): Promise ``` Parameters: | Param | Type | Required | Description | | --- | --- | --- | --- | | `accountId` | `string` | true | The id of the account that is device is attached to in the back office. | | , | `deviceId` | `string` | true | | , | `distributorId` | `string` | false | Promise resolution: ``` void ``` Capabilities: | Role | Capability | | --- | --- | | manages | xrn:firebolt:capability:account:id xrn:firebolt:capability:device:id xrn:firebolt:capability:device:distributor | #### Examples Default Example JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.provision("12345678910", "987654321111", null) .then(result => { console.log(result) }) ``` Value of `result`: ``` null ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.provision", "params": { "accountId": "12345678910", "deviceId": "987654321111" } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": null } ``` With distributor id JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.provision("12345678910", "987654321111", "global_partner") .then(result => { console.log(result) }) ``` Value of `result`: ``` null ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.provision", "params": { "accountId": "12345678910", "deviceId": "987654321111", "distributorId": "global_partner" } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": null } ``` --- ## Events ### deviceNameChanged ``` function listen('deviceNameChanged', (string) => void): Promise ``` See also: [listen()](/docs/100-manage-device#listen), [once()](/docs/100-manage-device#listen), [clear()](/docs/100-manage-device#listen). Event value: ``` string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:device:name | #### Examples Getting the device name JavaScript: ``` import { Device } from '@firebolt-js/manage-sdk' Device.listen('deviceNameChanged', value => { console.log(value) }) ``` Value of `value`: ``` "Living Room" ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Device.onDeviceNameChanged", "params": { "listen": true } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": "Living Room" } ``` --- ### nameChanged See: [name](/docs/100-manage-device#name)