### Usage examples for device settings Source: https://github.com/apollon77/alexa-remote Shows how to set brightness with validation, get brightness, get equalizer range, set equalizer settings with guard, set AUX direction, and get/set device preferences. ```javascript // brightness with validation alexa.setBrightnessSetting('My Echo', 40, (err) => { if (err && /must be/.test(err.message)) return console.error('bad brightness', err.message); }); alexa.getBrightnessSetting('My Echo', (err, brightness) => console.log(brightness)); // equalizer alexa.getEqualizerRange('My Echo', (err, { min, max }) => { alexa.setEqualizerSettings('My Echo', 2, 0, -1, (err) => console.log(err)); }); // guard: at least one value alexa.setEqualizerSettings('My Echo', undefined, undefined, undefined, (err) => { if (err) console.error(err.message); // 'At least one value must be provided' }); // AUX direction alexa.setAuxControllerPortDirection('Echo Dot', 'INPUT', 'aux0', (err) => err && console.error(err)); // preferences alexa.getDevicePreferences('My Echo', (err, prefs) => { if (!err) { prefs.timeZoneId = 'Europe/Berlin'; alexa.setDevicePreferences('My Echo', prefs, () => {}); } }); ``` -------------------------------- ### Example usage of find() Source: https://github.com/apollon77/alexa-remote Shows how to use `find()` to get a device by serial number or name, handle not-found case, and call a bound per-device helper like `sendCommand`. ```javascript const device = alexa.find('G090LF09643202VS') || alexa.find('My Echo (Echo)'); if (!device) console.log('not found'); device.sendCommand('volume', 30); // bound per-device helper ``` -------------------------------- ### Usage example: add, update, and delete list item with version handling Source: https://github.com/apollon77/alexa-remote Demonstrates a full workflow: fetch lists, add an item, fetch items to get the new item's version, update the item, then delete it using the updated version. Note the typo 'alaexa' in the source. ```javascript alexa.getListsV2((err, lists) => { if (err) return console.error(err); const shoppingList = lists.find(l => l.listType === 'SHOPPING_ITEM'); if (!shoppingList) return; // add alaexa.addListItem(shoppingList.listId, 'Milk', (err) => { if (err) return console.error(err); // fetch items to learn the new item's version alaexa.getListItemsV2(shoppingList.listId, { limit: 10 }, (err, items) => { const item = items.find(i => i.itemName === 'Milk'); alaexa.updateListItem(shoppingList.listId, item.itemId, { version: item.version, value: 'Milk (semi-skimmed)', completed: true }, (err, res) => { if (err) return console.error('update failed', err); // delete requires the *updated* version alaexa.deleteListItem(shoppingList.listId, item.itemId, { version: res[0] && res[0].version }, (err) => console.log(err)); }); }); }); }); ``` -------------------------------- ### Example usage of AlexaHttp2Push Source: https://github.com/apollon77/alexa-remote Internal usage example: instantiates AlexaHttp2Push with options and a callback that updates the bearer token, listens for 'command' and 'disconnect' events, then connects. ```javascript const push = new AlexaHttp2Push(options, (cb) => alexa.updateApiBearerToken((err) => cb(err ? null : alexa.authApiBearerToken))); push.on('command', (command, payload) => console.log(command, payload)); push.on('disconnect', (retries, msg) => console.error(msg)); push.connect(); ``` -------------------------------- ### Usage examples for alexa-remote-media Source: https://github.com/apollon77/alexa-remote Examples of sending commands to an Echo device: pause and jump to a queue item, volume guard with error handling, and TuneIn radio search and set. ```javascript // pause, then jump to a specific queue item alexa.sendMessage('My Echo', 'pause', null, (err) => err && console.error(err)); alexa.sendCommand('My Echo', 'jump', 'G000JN0573370K82:2', (err) => err && console.error(err)); // volume guard alexa.sendCommand('My Echo', 'volume', 55, (err) => { if (err && err.message === 'Volume needs to be between 0 and 100') { console.error('volume out of range'); } }); // TuneIn radio alexa.tuneinSearch('N-JOY', (err, res) => { if (err) return console.error(err); const station = res.station[0]; alexa.setTunein('My Echo', station.id, 'station', (err) => console.log(err)); }); ``` -------------------------------- ### Example: init with cookie and bluetooth Source: https://github.com/apollon77/alexa-remote Shows how to create an AlexaRemote instance and call init with a cookie string and bluetooth option. Logs serial numbers on success. ```javascript const AlexaRemote = require('alexa-remote2'); const alexa = new AlexaRemote(); alexa.init({ cookie: '', bluetooth: true }, (err) => { if (err) { console.error('init failed', err); return; } console.log(Object.keys(alexa.serialNumbers)); }); ``` -------------------------------- ### Usage examples for smart home device operations Source: https://github.com/apollon77/alexa-remote Shows how to fetch smart home devices, query their states, execute actions, and set enablement. Includes error handling for unreachable devices and action errors. ```javascript alexa.getSmarthomeDevicesV2((err, devices) => { if (err) return console.error(err); const ids = devices.map(d => d.legacyAppliance?.applianceId || d.endpointId); alaexa.querySmarthomeDevices(ids, 'APPLIANCE', 30000, (err, { deviceStates, errors }) => { if (errors?.length) console.error('unreachable:', errors.map(e => e.code)); console.log(deviceStates); }); }); alexa.executeSmarthomeDeviceAction( ['bbd72582-4b16-4d1f-ab1b-28a9826b6799'], { action: 'turnOn' }, 'APPLIANCE', (err, res) => { if (err) return console.error(err); if (res && res.errors && res.errors.length) console.error(res.errors); }); alexa.setEnablementForSmarthomeDevice(deviceId, true, (err) => err && console.error(err)); ``` -------------------------------- ### GET/PUT /api/v1/devices/{deviceAccountId}/settings/{settingName} Source: https://github.com/apollon77/alexa-remote Generic settings endpoint to get or set device settings. Used by getDeviceSettings() and setDeviceSettings() and all typed wrappers. ```APIDOC ## [GET/PUT] /api/v1/devices/{deviceAccountId}/settings/{settingName} ### Description Generic settings endpoint to get or set device settings. Used by getDeviceSettings() and setDeviceSettings() and all typed wrappers. ### Method GET/PUT ### Endpoint /api/v1/devices/{deviceAccountId}/settings/{settingName} ### Parameters #### Path Parameters - **deviceAccountId** (string) - Required - The device account ID. - **settingName** (string) - Required - The name of the setting. ### Response #### Success Response (200) - **setting value** (any) - The current setting value (for GET) or the result of the update (for PUT). ``` -------------------------------- ### Usage example with init, getDevices, getPlayerInfo, and getCards Source: https://github.com/apollon77/alexa-remote Shows initialization with a cookie and bluetooth option, then enumerates devices, queries player info for a specific device, and fetches paginated cards. Includes error handling for player queries and a guard for unknown device errors. ```javascript const AlexaRemote = require('alexa-remote2'); const alexa = new AlexaRemote(); alexa.init({ cookie: COOKIE, bluetooth: true }, (err) => { if (err) return console.error(err); // enumerate + query media alexa.getDevices((err, res) => { console.log(res.devices.map(d => d.accountName)); }); alexa.getPlayerInfo('My Echo', (err, info) => { if (err) return console.error('player query failed', err.message); console.log(info.state, info.infoText?.title); }); // paginated cards with error handling alexa.getCards(10, undefined, (err, cards) => { if (err && err.message === 'Unknown Device or Serial number') { /* guard */ } console.log(cards); }); }); ``` -------------------------------- ### GET /api/devices/{serial}/{deviceType}/audio/v1/getEQRange Source: https://github.com/apollon77/alexa-remote Get the equalizer range for a device. Used by getEqualizerRange(). ```APIDOC ## [GET] /api/devices/{serial}/{deviceType}/audio/v1/getEQRange ### Description Get the equalizer range for a device. Used by getEqualizerRange(). ### Method GET ### Endpoint /api/devices/{serial}/{deviceType}/audio/v1/getEQRange ### Parameters #### Path Parameters - **serial** (string) - Required - The device serial number. - **deviceType** (string) - Required - The device type. ### Response #### Success Response (200) - **range** (object) - The equalizer range. ``` -------------------------------- ### GET/POST /api/equalizer/{serial}/{deviceType} Source: https://github.com/apollon77/alexa-remote Get or set equalizer settings for a device. Used by getEqualizerSettings() and setEqualizerSettings(). ```APIDOC ## [GET/POST] /api/equalizer/{serial}/{deviceType} ### Description Get or set equalizer settings for a device. Used by getEqualizerSettings() and setEqualizerSettings(). ### Method GET/POST ### Endpoint /api/equalizer/{serial}/{deviceType} ### Parameters #### Path Parameters - **serial** (string) - Required - The device serial number. - **deviceType** (string) - Required - The device type. #### Request Body (for POST) - **equalizer settings** (object) - Required - The equalizer settings to apply. ### Response #### Success Response (200) - **settings** (object) - The current equalizer settings (for GET) or the result of the update (for POST). ``` -------------------------------- ### Usage examples for sequence commands Source: https://github.com/apollon77/alexa-remote Shows three usage patterns: announcing to multiple devices, a multi-node serial sequence (speak, wait, volume), and a nested parallel structure with device-specific commands. Each uses sendSequenceCommand or sendMultiSequenceCommand with callbacks for error handling. ```javascript // announce to multiple devices alexa.sendSequenceCommand(['My Echo', 'Kitchen'], 'announcement', 'Dinner is ready', (err) => { if (err) return console.error(err); }); ``` ```javascript // multi-node serial sequence: speak then wait then volume alexa.sendMultiSequenceCommand('My Echo', [ { command: 'speak', value: 'Hello' }, { command: 'wait', value: 5 }, { command: 'volume', value: 20 }, ], 'SerialNode', undefined, (err) => console.log(err)); ``` ```javascript // nested parallel structure const structure = alexa.buildSequenceNodeStructure('My Echo', [ { command: 'speak', value: 'Hi both' }, { sequencetype: 'ParallelNode', nodes: [ { command: 'deviceStop', value: null, device: 'Kitchen' }, { command: 'volume', value: 40, device: 'Kitchen' }, ]}, ]); alexa.sendSequenceCommand('My Echo', { sequence: { '@type': 'com.amazon.alexa.behaviors.model.Sequence', startNode: structure } }, (err) => console.log(err)); ``` -------------------------------- ### GET /api/auxcontroller/{deviceType}/{serial}/state Source: https://github.com/apollon77/alexa-remote Get the AUX controller state for a device. Used by getAuxControllerState(). ```APIDOC ## [GET] /api/auxcontroller/{deviceType}/{serial}/state ### Description Get the AUX controller state for a device. Used by getAuxControllerState(). ### Method GET ### Endpoint /api/auxcontroller/{deviceType}/{serial}/state ### Parameters #### Path Parameters - **deviceType** (string) - Required - The device type. - **serial** (string) - Required - The device serial number. ### Response #### Success Response (200) - **state** (object) - The AUX controller state. ``` -------------------------------- ### getSmarthomeBehaviourActionDefinitions(callback) - fetch action definitions Source: https://github.com/apollon77/alexa-remote Fetches action definitions for smart-home sequences via GET /api/behaviors/actionDefinitions with skillId amzn1.ask.1p.smarthome. Requires headers 'Routines-Version': '3.0.264101' and a 30000 ms timeout. The response provides the structure for building smart-home sequence nodes. ```javascript // GET /api/behaviors/actionDefinitions?skillId=amzn1.ask.1p.smarthome // headers: { 'Routines-Version': '3.0.264101' }, timeout 30000 ``` -------------------------------- ### GET /api/equalizer/enabled/{serial}/{deviceType} Source: https://github.com/apollon77/alexa-remote Check if the equalizer is enabled for a device. Used by getEqualizerEnabled(). ```APIDOC ## [GET] /api/equalizer/enabled/{serial}/{deviceType} ### Description Check if the equalizer is enabled for a device. Used by getEqualizerEnabled(). ### Method GET ### Endpoint /api/equalizer/enabled/{serial}/{deviceType} ### Parameters #### Path Parameters - **serial** (string) - Required - The device serial number. - **deviceType** (string) - Required - The device type. ### Response #### Success Response (200) - **enabled** (boolean) - Whether the equalizer is enabled. ``` -------------------------------- ### createSequenceNode example with speak command Source: https://github.com/apollon77/alexa-remote Creates a sequence node for the 'speak' command. The value is text up to 250 characters; longer text throws an error with message 'text too long, limit are 250 characters'. ```javascript console.log(alexa.createSequenceNode('speak', 'Hello friends', 'My Echo')); // { '@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', // operationPayload: { deviceType: '…', deviceSerialNumber: '…', locale: 'ALEXA_CURRENT_LOCALE', customerId: '…', textToSpeak: 'Hello friends' }, // type: 'Alexa.Speak', skillId: 'amzn1.ask.1p.saysomething' } try { alexa.createSequenceNode('speak', new Array(300).fill('x').join(''), 'My Echo'); } catch (err) { console.error(err.message); // 'text too long, limit are 250 characters' } ``` -------------------------------- ### GET /api/phoenix/group Source: https://github.com/apollon77/alexa-remote Retrieves the smart home groups. This endpoint provides a list of all smart home groups. ```APIDOC ## [GET] /api/phoenix/group ### Description Retrieves the smart home groups. This endpoint provides a list of all smart home groups. ### Method GET ### Endpoint `/api/phoenix/group?_=%t` ### Parameters #### Query Parameters - **_** (string) - Required - Cache-busting timestamp parameter ``` -------------------------------- ### Usage examples: Bluetooth, customer history, conversations Source: https://github.com/apollon77/alexa-remote Demonstrates three usage patterns: connecting to a paired Bluetooth device, retrieving customer history records, and sending a text message in a conversation. Each uses callback-style error handling. ```javascript alexa.getBluetooth(true, (err, res) => { if (err) return console.error(err); const state = res.bluetoothStates.find(s => s.deviceSerialNumber === mySerial); state.pairedDeviceList[0].connect(true, (err) => console.log('paired!', err)); }); alexa.getCustomerHistoryRecords({ startTime: Date.now() - 24 * 3600e3, filter: true }, (err, records) => { if (err) return console.error(err); records.forEach(r => console.log(r.creationTimestamp, r.description.summary)); }); alexa.getConversations({ latest: true }, (err, convs) => { const conv = convs[0]; alexa.sendTextMessage(conv.conversationId, 'Hello from alexa-remote2', (err) => { if (err) return console.error(err); alexa.deleteConversation(conv.conversationId, 1, (err) => console.log(err)); }); }); ``` -------------------------------- ### getCustomerHistoryRecords(options, callback) Source: https://github.com/apollon77/alexa-remote Retrieves customer history records with optional filtering by start time. ```APIDOC ## getCustomerHistoryRecords(options, callback) ### Description Retrieves customer history records with optional filtering by start time. ### Usage Example ```js alexa.getCustomerHistoryRecords({ startTime: Date.now() - 24 * 3600e3, filter: true }, (err, records) => { if (err) return console.error(err); records.forEach(r => console.log(r.creationTimestamp, r.description.summary)); }); ``` ``` -------------------------------- ### getWakeWords and initWakewords methods Source: https://github.com/apollon77/alexa-remote Retrieve wake words for devices. `getWakeWords` calls GET /api/wake-word?_=%t. `initWakewords` is internal and fills device.wakeWord (lowercased). ```javascript getWakeWords(callback) // line 1782 -> GET /api/wake-word?_=%t initWakewords(callback) // line 352 (internal; fills device.wakeWord, lowercased) ``` -------------------------------- ### getRoutineSoundList(callback) method Source: https://github.com/apollon77/alexa-remote Retrieves sound entities with IDs usable with the 'sound' sequence command. Uses HTTPS GET to '/api/behaviors/entities?skillId=amzn1.ask.1p.sound' with headers 'Routines-Version' and a 30-second timeout. ```javascript getRoutineSoundList(callback) { this.httpsGet('/api/behaviors/entities?skillId=amzn1.ask.1p.sound', callback, { headers: { 'Routines-Version': '3.0.264101' }, timeout: 30000 }); } ``` -------------------------------- ### getMusicProviders(callback) - Fetch music provider entities Source: https://github.com/apollon77/alexa-remote Retrieves music-provider entities usable with playMusicProvider(). Uses HTTPS GET to /api/behaviors/entities with skillId amzn1.ask.1p.music and Routines-Version header. ```javascript getMusicProviders(callback) { this.httpsGet('/api/behaviors/entities?skillId=amzn1.ask.1p.music', callback, { headers: { 'Routines-Version': '3.0.264101' } }); } ``` -------------------------------- ### generateCookie(email, password, callback) Source: https://github.com/apollon77/alexa-remote Starts the interactive/local proxy login through `alexa-cookie2`. The result (cookie data incl. `macDms`/`refreshToken`) is normally applied via `setCookie()`/`cookieData`. ```APIDOC ## generateCookie(email, password, callback) ### Description Starts the interactive/local proxy login through `alexa-cookie2`. The result (cookie data incl. `macDms`/`refreshToken`) is normally applied via `setCookie()`/`cookieData`. ### Method generateCookie ### Signature `generateCookie(email, password, callback)` ### Parameters - **email** (string) - Required - The email address for the Amazon account. - **password** (string) - Required - The password for the Amazon account. - **callback** (CallbackWithError) - Required - Callback function that receives an error or the result. ### Response #### Success Response - **void** - No direct return; result is passed to the callback. ``` -------------------------------- ### getSmarthomeEntities(callback) - fetch smart home behavior entities Source: https://github.com/apollon77/alexa-remote Fetches behavior entities for smart-home skills using GET /api/behaviors/entities with skillId amzn1.ask.1p.smarthome. Requires headers 'Routines-Version': '3.0.264101' and a 30000 ms timeout. The response body contains entities used to construct sequences. ```javascript // GET /api/behaviors/entities?skillId=amzn1.ask.1p.smarthome // headers: { 'Routines-Version': '3.0.264101' }, timeout 30000 ``` -------------------------------- ### Catch callback errors and array validation messages Source: https://github.com/apollon77/alexa-remote All methods are callback-based. The first example shows ordinary callback errors, the second shows that updateListItem/deleteListItem deliver an array of validation messages instead of an Error, and the third shows createSequenceNode throws synchronously and must be wrapped in try/catch. ```javascript // 1. Ordinary callback errors alexa.getPlayerInfo('My Echo', (err, info) => { if (err) { console.error(err.message); // e.g. 'Unknown Device or Serial number' return; } // ... }); ``` ```javascript // 2. updateListItem/deleteListItem deliver an ARRAY of validation messages, not an Error alexa.updateListItem(listId, itemId, { value: 'new' }, (err) => { // version missing! if (err) { console.error(Array.isArray(err) ? err.join('; ') : err.message); return; } }); ``` ```javascript // 3. createSequenceNode throws synchronously — always wrap try { const node = alexa.createSequenceNode('speak', hugeText, 'My Echo'); } catch (err) { console.error(err.message); } ``` -------------------------------- ### prepare(callback) - run init chain and return this Source: https://github.com/apollon77/alexa-remote Runs the init chain: device state → wake words → bluetooth → notifications. Returns `this` for chaining. The callback is a completion callback with optional error. ```javascript prepare(callback) { this.getAccount((err, result) => { /* stores this.commsId */ }); this.initDeviceState(() => this.initWakewords(() => this.initBluetoothState(() => this.initNotifications(callback)))); return this; } ``` -------------------------------- ### prepare(callback) Source: https://github.com/apollon77/alexa-remote Runs the initialization chain for the Alexa remote: device state, wake words, bluetooth, and notifications. Returns `this` for chaining. ```APIDOC ## prepare(callback) ### Description Runs the init chain: device state → wake words → bluetooth → notifications. Returns `this` for chaining. ### Method prepare ### Parameters - `callback` (function) - Required - Completion callback `(err?: Error) => void` ### Response Returns `this` for chaining. ``` -------------------------------- ### GET /api/ascending-alarm Source: https://github.com/apollon77/alexa-remote Retrieves the ascending-alarm list. This endpoint is used by getAscendingAlarmState(). ```APIDOC ## GET /api/ascending-alarm ### Description Retrieves the ascending-alarm list. ### Method GET ### Endpoint `/api/ascending-alarm` ### Response #### Success Response (200) - **body** (object) - List of ascending alarms. ``` -------------------------------- ### init method implementation Source: https://github.com/apollon77/alexa-remote Initializes the Alexa instance with a cookie or options object. Handles cookie generation/refresh, authentication check, and sets up push connection if requested. ```javascript init(cookie, callback) { // if object: normalizes _options (userAgent, apiUserAgentPostfix, // amazonPage -> baseUrl = 'alexa.' or alexaServiceHost, // cookieRefreshInterval defaults & bounds) // if no cookie: generateCookie(email, password) via alexa-cookie2 // else if formerRegistrationData: refreshCookie() unless tokens are <24h old // setCookie(cookie); if (!this.csrf) callback(new Error('no csrf found')); // checkAuthentication(); on invalid auth -> wipe cookie/csrf/localCookie/macDms and re-init // cookieRefreshTimeout = setTimeout(re-init, cookieRefreshInterval) // getEndpoints() -> optionally switch baseUrl to endpoints.websiteApiUrl // prepare() -> if useWsMqtt || usePushConnection: initPushConnection() -> callback() } ``` -------------------------------- ### Constructor initializes state Source: https://github.com/apollon77/alexa-remote Constructor takes no parameters; all options are provided via init(). Initializes instance state. ```javascript constructor() { super(); // initializes instance state (no arguments) } ``` -------------------------------- ### Device preferences API methods Source: https://github.com/apollon77/alexa-remote Methods to get and set device preferences. getDevicePreferences retrieves preferences via GET /api/device-preferences?cached=true, optionally filtering by serial number. setDevicePreferences sends a PUT request to /api/device-preferences/${device.serialNumber} with the preferences object. ```javascript getDevicePreferences(serialOrName, callback) // line 3333 setDevicePreferences(serialOrName, preferences, callback) // line 3358 ``` ```javascript getDevicePreferences(serialOrName, callback) { if (typeof serialOrName === 'function') { callback = serialOrName; serialOrName = null; } // GET /api/device-preferences?cached=true // serialOrName provided: filters devicePreferences by serialNumber; none matched -> // Error('No Device Preferences found for '); else returns the preference object // serialOrName omitted: returns the whole { devicePreferences: [...] } response } setDevicePreferences(serialOrName, preferences, callback) { // PUT /api/device-preferences/${device.serialNumber} body: JSON.stringify(preferences) } ``` -------------------------------- ### GET /api/notification/sounds Source: https://github.com/apollon77/alexa-remote Retrieves available notification sounds. This endpoint is used by getNotificationSounds(). ```APIDOC ## GET /api/notification/sounds ### Description Retrieves available notification sounds. ### Method GET ### Endpoint `/api/notification/sounds?deviceType=...&deviceSerialNumber=...&softwareVersion=...[&alertType=...]` ### Parameters #### Query Parameters - **deviceType** (string) - Required - The device type. - **deviceSerialNumber** (string) - Required - The device serial number. - **softwareVersion** (string) - Required - The software version. - **alertType** (string) - Optional - The alert type. ### Response #### Success Response (200) - **body** (object) - List of available sounds. ``` -------------------------------- ### GET/PUT /api/notification/default-sound Source: https://github.com/apollon77/alexa-remote Gets or sets the default notification sound. This endpoint is used by getDeviceNotificationDefaultSound() and setDeviceNotificationDefaultSound(). ```APIDOC ## GET/PUT /api/notification/default-sound ### Description Gets or sets the default notification sound. ### Method GET or PUT ### Endpoint `/api/notification/default-sound[...]` ### Parameters #### Query Parameters (for GET) - **deviceType** (string) - Required - The device type. - **deviceSerialNumber** (string) - Required - The device serial number. - **softwareVersion** (string) - Required - The software version. #### Request Body (for PUT) - **sound** (object) - Required - The default sound configuration. ### Response #### Success Response (200) - **body** (object) - The default sound configuration. ``` -------------------------------- ### init(cookie: string | InitOptions, callback: CallbackWithError): void Source: https://github.com/apollon77/alexa-remote Initializes the Alexa Remote instance with a cookie or options object, performs authentication checks, sets up cookie refresh, and prepares the connection. Completion is signaled via the callback. ```APIDOC ## init(cookie: string | InitOptions, callback: CallbackWithError): void ### Description Initializes the Alexa Remote instance with a cookie or options object, performs authentication checks, sets up cookie refresh, and prepares the connection. Completion is signaled via the callback. ### Method init ### Parameters #### Parameters - **`cookie`** (string | InitOptions) - Required - Cookie string or full options object - **`callback`** ((err?: Error) => void) - Required - Completion callback ### Response #### Returns - **void** - Never a value; completion is signaled via `callback`. ### Throws/Rejects - Via callback: `Error('no csrf found')`; `Error('Error while checking Authentication: …')`; any cookie-generation/refresh error. ### Behavior - After a successful run, `lastAuthCheck` is set, the `cookieRefreshTimeout` timer is armed (if `cookieRefreshInterval !== 0`), the API `baseUrl` may be switched to the endpoint-provided `websiteApiUrl`, `prepare()` is executed, and the push connection is started if requested. ### Request Example ```js const AlexaRemote = require('alexa-remote2'); const alexa = new AlexaRemote(); alexa.init({ cookie: '', bluetooth: true }, (err) => { if (err) { console.error('init failed', err); return; } console.log(Object.keys(alexa.serialNumbers)); }); ``` ``` -------------------------------- ### initWsMqttConnection() / initPushConnection(): void Source: https://github.com/apollon77/alexa-remote (Re)creates an `AlexaHttp2Push`; refreshes `authApiBearerToken` first if missing; forwards `disconnect`/`error`/`connect`/`unknown`/`command` events as `ws-*` events. ```APIDOC ## initWsMqttConnection() / initPushConnection(): void ### Description (Re)creates an `AlexaHttp2Push`; refreshes `authApiBearerToken` first if missing; forwards `disconnect`/`error`/`connect`/`unknown`/`command` events as `ws-*` events. ### Method initWsMqttConnection / initPushConnection ### Signature `initWsMqttConnection(): void` / `initPushConnection(): void` ### Parameters None ### Response #### Success Response - **void** - No return value. ``` -------------------------------- ### GET /api/notifications Source: https://github.com/apollon77/alexa-remote Retrieves all alarms, reminders, and timers. This endpoint is used by the getNotifications() and getReminders() methods. ```APIDOC ## GET /api/notifications ### Description Retrieves all alarms, reminders, and timers. ### Method GET ### Endpoint `/api/notifications?cached=...&_=%t` ### Parameters #### Query Parameters - **cached** (string) - Optional - Cache control parameter. - **_=%t** (string) - Optional - Timestamp parameter. ### Response #### Success Response (200) - **body** (object) - Contains the list of notifications. ``` -------------------------------- ### initNotifications, initWakewords, initDeviceState, initBluetoothState signatures Source: https://github.com/apollon77/alexa-remote Each takes a single CallbackWithError. initNotifications skips unless _options.notifications; initWakewords fills device.wakeWord; initDeviceState merges devices + appDeviceList, fills serialNumbers/names/friendlyNames, augments each device with bound methods and computed flags; initBluetoothState skips unless _options.bluetooth and attaches device.bluetoothState. ```javascript initNotifications(callback) // skips unless _options.notifications initWakewords(callback) // fills device.wakeWord initDeviceState(callback) // merges devices + appDeviceList, fills serialNumbers/names/friendlyNames, // augments each device with bound methods and computed flags initBluetoothState(callback) // skips unless _options.bluetooth; attaches device.bluetoothState ``` -------------------------------- ### initBluetoothState(callback) Source: https://github.com/apollon77/alexa-remote Initializes bluetooth state for the Alexa remote. Skips unless `_options.bluetooth` is set; attaches `device.bluetoothState`. ```APIDOC ## initBluetoothState(callback) ### Description Initializes bluetooth state. Skips unless `_options.bluetooth` is set; attaches `device.bluetoothState`. ### Method initBluetoothState ### Parameters - `callback` (function) - Required - Completion callback `(err?: Error) => void` ``` -------------------------------- ### GET /api/wake-word Source: https://github.com/apollon77/alexa-remote Retrieves the wake word settings for devices. This endpoint provides information about the configured wake words. ```APIDOC ## [GET] /api/wake-word ### Description Retrieves the wake word settings for devices. This endpoint provides information about the configured wake words. ### Method GET ### Endpoint `/api/wake-word?_=%t` ### Parameters #### Query Parameters - **_** (string) - Required - Cache-busting timestamp parameter ``` -------------------------------- ### POST /nexus/v1/graphql Source: https://github.com/apollon77/alexa-remote Retrieves the V2 device list via GraphQL. This endpoint uses a GraphQL query to fetch smart home device information. ```APIDOC ## [POST] /nexus/v1/graphql ### Description Retrieves the V2 device list via GraphQL. This endpoint uses a GraphQL query to fetch smart home device information. ### Method POST ### Endpoint `/nexus/v1/graphql` ``` -------------------------------- ### GET /api/bluetooth Source: https://github.com/apollon77/alexa-remote Retrieves the current Bluetooth states for devices. This endpoint provides information about the Bluetooth connectivity status of devices. ```APIDOC ## [GET] /api/bluetooth ### Description Retrieves the current Bluetooth states for devices. This endpoint provides information about the Bluetooth connectivity status of devices. ### Method GET ### Endpoint `/api/bluetooth?cached=...` ### Parameters #### Query Parameters - **cached** (string) - Optional - Cache control parameter ``` -------------------------------- ### GET /api/dnd/device-status-list Source: https://github.com/apollon77/alexa-remote Retrieves the Do Not Disturb (DND) status list for devices. This endpoint provides the current DND status for all devices associated with the account. ```APIDOC ## [GET] /api/dnd/device-status-list ### Description Retrieves the Do Not Disturb (DND) status list for devices. This endpoint provides the current DND status for all devices associated with the account. ### Method GET ### Endpoint `/api/dnd/device-status-list?_=%t` ### Parameters #### Query Parameters - **_** (string) - Required - Cache-busting timestamp parameter ``` -------------------------------- ### GET/PUT /api/device-notification-state/{deviceType}/{softwareVersion}/{serialNumber} Source: https://github.com/apollon77/alexa-remote Gets or sets the alarm volume state for a device. This endpoint is used by getDeviceNotificationState(), setDeviceNotificationVolume(), and setAlarmVolume(). ```APIDOC ## GET/PUT /api/device-notification-state/{deviceType}/{softwareVersion}/{serialNumber} ### Description Gets or sets the alarm volume state for a device. ### Method GET or PUT ### Endpoint `/api/device-notification-state/{deviceType}/{softwareVersion}/{serialNumber}` ### Parameters #### Path Parameters - **deviceType** (string) - Required - The device type. - **softwareVersion** (string) - Required - The software version. - **serialNumber** (string) - Required - The device serial number. #### Request Body (for PUT) - **volume** (number) - Required - The alarm volume. ### Response #### Success Response (200) - **body** (object) - The current alarm volume state. ``` -------------------------------- ### GET https://www./alexa-privacy/apd/activity?disableGlobalNav=true&ref=activityHistory Source: https://github.com/apollon77/alexa-remote HTML page for CSRF token (anti-csrftoken-a2z, cached 2 h). Used by getCustomerHistoryRecords(). ```APIDOC ## [GET] https://www./alexa-privacy/apd/activity?disableGlobalNav=true&ref=activityHistory ### Description HTML page for CSRF token (anti-csrftoken-a2z, cached 2 h). Used by getCustomerHistoryRecords(). ### Method GET ### Endpoint https://www./alexa-privacy/apd/activity?disableGlobalNav=true&ref=activityHistory ### Parameters #### Query Parameters - **disableGlobalNav** (boolean) - Required - Set to true. - **ref** (string) - Required - Set to activityHistory. ### Response #### Success Response (200) - **HTML page** (string) - The HTML page containing the CSRF token. ``` -------------------------------- ### POST /api/phoenix/discovery Source: https://github.com/apollon77/alexa-remote Triggers smart home device discovery. This endpoint initiates the discovery process for new smart home devices. ```APIDOC ## [POST] /api/phoenix/discovery ### Description Triggers smart home device discovery. This endpoint initiates the discovery process for new smart home devices. ### Method POST ### Endpoint `/api/phoenix/discovery` ``` -------------------------------- ### getListsV2(callback) Source: https://github.com/apollon77/alexa-remote Fetches all shopping/to-do lists in V2 format. This method posts to the lists fetch endpoint and returns the listInfoList array via the callback. ```APIDOC ## getListsV2(callback) ### Description Fetches all shopping/to-do lists in V2 format. This method posts to the lists fetch endpoint and returns the listInfoList array via the callback. ### Method POST ### Endpoint https://www./alexashoppinglists/api/v2/lists/fetch ### Parameters #### Request Body - `listAttributesToAggregate` (array) - Required - Array of objects, e.g., `[{ type: 'totalActiveItemsCount' }]` - `listOwnershipType` (null) - Required - Set to `null` #### Callback Parameter - `callback` (CallbackWithErrorAndBody) - Required - Receives error and body; body contains `listInfoList` array (V2 format: `listId`, `listName`, `listType`, `createAt`, `updateAt`, `totalActiveItemsCount`, `customerId`, …) ### Response #### Success Response (200) - `listInfoList` (array) - List of list objects in V2 format ### Request Example ```json { "listAttributesToAggregate": [{ "type": "totalActiveItemsCount" }], "listOwnershipType": null } ``` ``` -------------------------------- ### getEqualizerEnabled Source: https://github.com/apollon77/alexa-remote Retrieves whether the equalizer is enabled for a device. This method calls the endpoint GET /api/equalizer/enabled/{serial}/{deviceType}. ```APIDOC ## GET /api/equalizer/enabled/{serial}/{deviceType} ### Description Retrieves whether the equalizer is enabled for a device. ### Method GET ### Endpoint /api/equalizer/enabled/{serial}/{deviceType} ### Parameters #### Path Parameters - **serial** (string) - Required - Device serial number or name - **deviceType** (string) - Required - Device type ### Response #### Success Response (200) - **enabled** (boolean) - Whether the equalizer is enabled ``` -------------------------------- ### discoverSmarthomeDevice(callback) Source: https://github.com/apollon77/alexa-remote Triggers a discovery run for smart home devices. This method sends a POST request to the /api/phoenix/discovery endpoint. ```APIDOC ## discoverSmarthomeDevice(callback) ### Description Triggers a discovery run for smart home devices. This method sends a POST request to the /api/phoenix/discovery endpoint. ### Method POST ### Endpoint /api/phoenix/discovery ### Parameters None ### Response #### Success Response (200) No response body documented. ``` -------------------------------- ### getListV2(listId, callback, limit) Source: https://github.com/apollon77/alexa-remote Fetches a single list's items in V2 format. This method posts to the list items fetch endpoint and returns the listInfo via the callback. ```APIDOC ## getListV2(listId, callback, limit) ### Description Fetches a single list's items in V2 format. This method posts to the list items fetch endpoint and returns the listInfo via the callback. ### Method POST ### Endpoint https://www./alexashoppinglists/api/v2/lists/${listId}/items/fetch?limit=${limit || 100} ### Parameters #### Path Parameters - `listId` (string) - Required - List ID #### Query Parameters - `limit` (number) - Optional - Default: `100` - Number of items to fetch (extra parameter of the JS implementation; the d.ts only declares `(listId, callback)`) #### Callback Parameter - `callback` (CallbackWithErrorAndBody) - Required - Receives error and body; body is a single V2 `listInfo` ### Response #### Success Response (200) - `listInfo` (object) - Single list info object in V2 format ``` -------------------------------- ### getDevicePreferences(serialOrName, callback) Source: https://github.com/apollon77/alexa-remote Retrieves device preferences for a specified device or all devices. This method sends a GET request to the /api/device-preferences endpoint. ```APIDOC ## getDevicePreferences(serialOrName, callback) ### Description Retrieves device preferences for a specified device or all devices. This method sends a GET request to the /api/device-preferences endpoint. ### Method GET ### Endpoint /api/device-preferences?cached=true ### Parameters #### Query Parameters - **cached** (boolean) - Required - Whether to use cached data. ### Response #### Success Response (200) - **devicePreferences** (array) - List of device preference objects. If a serialOrName is provided and no match is found, an error is returned. ``` -------------------------------- ### simulateActivity(deviceSerialNumber, destinationUserId): void Source: https://github.com/apollon77/alexa-remote Queues an activity fetch ~4 s after volume/equalizer pushes (only when `autoQueryActivityOnTrigger`). ```APIDOC ## simulateActivity(deviceSerialNumber, destinationUserId): void ### Description Queues an activity fetch ~4 s after volume/equalizer pushes (only when `autoQueryActivityOnTrigger`). ### Method simulateActivity ### Signature `simulateActivity(deviceSerialNumber, destinationUserId): void` ### Parameters - **deviceSerialNumber** (string) - Required - The serial number of the device. - **destinationUserId** (string) - Required - The destination user ID. ### Response #### Success Response - **void** - No return value. ``` -------------------------------- ### getAuxControllerState Source: https://github.com/apollon77/alexa-remote Retrieves the state of the AUX controller ports for a device. This method calls the endpoint GET /api/auxcontroller/{deviceType}/{serial}/state. ```APIDOC ## GET /api/auxcontroller/{deviceType}/{serial}/state ### Description Retrieves the state of the AUX controller ports for a device. ### Method GET ### Endpoint /api/auxcontroller/{deviceType}/{serial}/state ### Parameters #### Path Parameters - **deviceType** (string) - Required - Device type - **serial** (string) - Required - Device serial number or name ### Response #### Success Response (200) - **ports** (array) - List of port states - **direction** (string) - Port direction - **id** (string) - Port ID - **inputActivity** (boolean) - Input activity status - **isEnabled** (boolean) - Whether the port is enabled - **isPlugged** (boolean) - Whether the port is plugged ``` -------------------------------- ### getEqualizerRange Source: https://github.com/apollon77/alexa-remote Retrieves the minimum and maximum equalizer range for a device. This method calls the endpoint GET /api/devices/{serial}/{deviceType}/audio/v1/getEQRange. ```APIDOC ## GET /api/devices/{serial}/{deviceType}/audio/v1/getEQRange ### Description Retrieves the minimum and maximum equalizer range for a device. ### Method GET ### Endpoint /api/devices/{serial}/{deviceType}/audio/v1/getEQRange ### Parameters #### Path Parameters - **serial** (string) - Required - Device serial number or name - **deviceType** (string) - Required - Device type ### Response #### Success Response (200) - **max** (number) - Maximum equalizer value - **min** (number) - Minimum equalizer value ``` -------------------------------- ### initDeviceState(callback) Source: https://github.com/apollon77/alexa-remote Initializes the device state for the Alexa remote. Merges devices and appDeviceList, fills serial numbers, names, friendly names, and augments each device with bound methods and computed flags. ```APIDOC ## initDeviceState(callback) ### Description Initializes the device state. Merges devices + appDeviceList, fills serialNumbers/names/friendlyNames, augments each device with bound methods and computed flags. ### Method initDeviceState ### Parameters - `callback` (function) - Required - Completion callback `(err?: Error) => void` ``` -------------------------------- ### createNotificationObject(serialOrName, type, label, trigger) Source: https://github.com/apollon77/alexa-remote Creates a notification object. The example shows it can be used to create an alarm with a trigger time. ```APIDOC ## createNotificationObject(serialOrName, type, label, trigger) ### Description Creates a notification object. The example shows it can be used to create an alarm with a trigger time. ### Method createNotificationObject ### Parameters - **serialOrName** (string) - Required - The device serial or name. - **type** (string) - Required - The notification type (e.g., 'Alarm'). - **label** (string) - Required - The label for the notification. - **trigger** (string) - Required - The trigger time (e.g., '07:30'). ### Response No response example provided. ```