@di-zed/yandex-smart-home
Version:
The Yandex Smart Home skills for the different device types.
130 lines (129 loc) • 3.33 kB
TypeScript
import { MqttCommandTopicInterface } from '../interfaces/mqttInterface';
import { UserInterface } from '../models/userModel';
/**
* MQTT Service.
*/
declare class MqttService {
/**
* Get Topic Names.
*
* @param input
* @returns Promise<MqttOutputTopicNames>
*/
getTopicNames(input: MqttInputTopicNames): Promise<MqttOutputTopicNames>;
/**
* Get Data from the Topic.
*
* @param topic
* @param typeState
* @returns Promise<TopicData | undefined>
*/
getTopicData(topic: string, typeState?: MqttTopicTypeState): Promise<TopicData | undefined>;
/**
* Get Data from the Command Topic.
*
* @param topic
* @param deviceType
* @param typeState
* @returns Promise<CommandTopicData | undefined>
*/
getCommandTopicData(topic: string, deviceType: string, typeState?: MqttTopicTypeState): Promise<CommandTopicData | undefined>;
/**
* Check the Topic Type.
*
* @param topic
* @param expectedType
* @returns Promise<boolean>
*/
isTopicType(topic: string, expectedType: MqttTopicTypes): Promise<boolean>;
/**
* Get Parsed Information from the Topic Name.
*
* @param patternTopic
* @param topic
* @returns ParsedTopicName | undefined
*/
parseTopicName(patternTopic: string, topic: string): ParsedTopicName | undefined;
/**
* Get Username for the MQTT Topic.
*
* @param user
* @returns string
*/
getTopicUserName(user: UserInterface): string;
/**
* Handle Topic Name.
*
* @param topicName
* @param user
* @param deviceId
* @returns string
*/
handleTopicName(topicName: string, user: UserInterface, deviceId: string): string;
/**
* Match Type & State Instance.
*
* @param commandTopic
* @param typeState
* @returns boolean
*/
matchTopicTypeState(commandTopic: MqttCommandTopicInterface, typeState: MqttTopicTypeState): boolean;
}
/**
* MQTT Topic "Type & State Instance" Type.
*/
export type MqttTopicTypeState = {
capabilityType?: string;
capabilityStateInstance?: string;
propertyType?: string;
propertyStateInstance?: string;
};
/**
* MQTT Input Topic Names Type.
*/
export type MqttInputTopicNames = MqttTopicTypeState & {
user: UserInterface;
deviceId: string;
};
/**
* MQTT Output Topic Names Type.
*/
export type MqttOutputTopicNames = {
stateTopic: string;
configTopic: string;
availableTopic: string;
commandTopic: string;
};
/**
* MQTT Topic Types.
*/
export type MqttTopicTypes = 'stateTopic' | 'configTopic' | 'availableTopic' | 'commandTopic';
/**
* Parsed Information from the Topic Name.
*/
export type ParsedTopicName = {
userName: string;
deviceId: string;
};
/**
* Data from the Topic.
*/
export type TopicData = ParsedTopicName & {
topicType: MqttTopicTypes;
};
/**
* Data from the Command Topic.
*/
export type CommandTopicData = ParsedTopicName & {
deviceType: string;
capabilityType: string;
capabilityStateInstance: string;
propertyType: string;
propertyStateInstance: string;
topicStateKeys: string[];
messageValueMapping: {
[key: string]: any;
};
};
declare const _default: MqttService;
export default _default;