UNPKG

@di-zed/yandex-smart-home

Version:

The Yandex Smart Home skills for the different device types.

73 lines (72 loc) 2.25 kB
/// <reference types="node" /> import mqtt from 'mqtt'; import { IClientPublishOptions, ISubscriptionGrant } from 'mqtt/src/lib/client'; import { Packet } from 'mqtt-packet'; /** * MQTT Provider. */ export declare class MqttProvider { /** * MQTT Client. * * @protected */ protected client: mqtt.MqttClient | undefined; /** * Get MQTT Client. * * @returns mqtt.MqttClient | undefined */ getClient(): mqtt.MqttClient | undefined; /** * Get MQTT Client. * Async method with reconnect possibility. * * @returns Promise<mqtt.MqttClient> */ getClientAsync(): Promise<mqtt.MqttClient>; /** * By default, client connects when constructor is called. * To prevent this you can set "manualConnect" option to "true" and call "client.connect()" manually. * * @returns Promise<mqtt.MqttClient> * @see https://github.com/mqttjs/MQTT.js?tab=readme-ov-file#connect-async */ connect(): Promise<mqtt.MqttClient>; /** * Subscribe to a topic or topics. * * @param eventMessageCallback * @returns Promise<ISubscriptionGrant[]> * @see https://github.com/mqttjs/MQTT.js?tab=readme-ov-file#mqttclientsubscribeasynctopictopic-arraytopic-object-options */ subscribe(eventMessageCallback: Function): Promise<ISubscriptionGrant[]>; /** * Publish a message to a topic. * * @param topic * @param message * @param opts * @returns Promise<Packet | undefined> * @see https://github.com/mqttjs/MQTT.js?tab=readme-ov-file#mqttclientpublishasynctopic-message-options */ publish(topic: string, message: string | Buffer, opts?: IClientPublishOptions): Promise<Packet | undefined>; /** * Close the client. * * @returns Promise<void> * @see https://github.com/mqttjs/MQTT.js?tab=readme-ov-file#mqttclientendasyncforce-options */ end(): Promise<void>; /** * Listen Topic. * * @param topic * @param oldMessage * @param newMessage * @returns void */ listenTopic(topic: string, oldMessage: string | undefined, newMessage: string): void; } declare const _default: MqttProvider; export default _default;