### Initialize UPnP Client and Get Device Description Source: https://github.com/velocityzen/node-upnp/blob/main/README.md Demonstrates how to initialize a UPnPClient instance by providing a device URL and then asynchronously retrieve its device description. This example showcases basic client setup and interaction. ```javascript const UPnPClient = require('node-upnp'); const client = new UPnPClient({ url: 'http://192.168.1.150:44042/some.xml' }); const desc = await client.getDeviceDescription(); console.log('Device', desc); ``` -------------------------------- ### Install node-upnp via npm Source: https://github.com/velocityzen/node-upnp/blob/main/README.md Instructions to install the node-upnp library using the npm package manager, making it available for use in your Node.js projects. ```shell npm i node-upnp ``` -------------------------------- ### UPnPClient API Reference Source: https://github.com/velocityzen/node-upnp/blob/main/README.md Comprehensive API reference for the node-upnp client, detailing methods for device and service interaction, event subscription, and listener management. This includes methods for retrieving descriptions, calling actions, and handling variable change events. ```APIDOC UPnPClient API: async getDeviceDescription() - Returns the device description. async getServiceDescription(serviceId: string) - Returns the service description for a given service ID. - Parameters: - serviceId: The ID of the service. async call(serviceId: string, actionName: string, data: object) - Calls a specific action on a service with provided data. - Parameters: - serviceId: The ID of the service. - actionName: The name of the action to call. - data: An object containing the data for the action. - Returns: The result of the action call. async subscribe(serviceId: string, listener: Function) - Subscribes to updates for a specific service and keeps the subscription alive. - Parameters: - serviceId: The ID of the service to subscribe to. - listener: A callback function to receive updates. async unsubscribe(serviceId: string, listener: Function) - Unsubscribes from updates for a specific service. - Parameters: - serviceId: The ID of the service to unsubscribe from. - listener: The callback function that was used for subscription. hasSubscriptions(): boolean - Checks if the client has any active subscriptions. - Returns: `true` if there are active subscriptions, `false` otherwise. clearSubscriptions() - Clears all active subscriptions. async on(variable: string, listener: Function, options: object = {}) - Subscribes to a variable change event. - Parameters: - variable: The name of the variable to listen for changes. - listener: A callback function to be invoked on variable change. - options: An optional object for subscription settings. - force: Boolean (default: false). If true, subscribes even if the variable is `sendEvents='no'` in the service description. Relevant for variables included in `LastChange` events. async off(variable: string, listener: Function) - Unsubscribes from a variable change event. - Parameters: - variable: The name of the variable. - listener: The callback function to remove. emit(...args: any[]) - Emits an event with the provided arguments. async removeAllListeners() - Removes all registered listeners from the client. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.