UNPKG

matterbridge-dyson-robot

Version:

A Matterbridge plugin that connects Dyson robot vacuums and air treatment devices to the Matter smart home ecosystem via their local or cloud MQTT APIs.

69 lines 2.88 kB
// Matterbridge plugin for Dyson robot vacuum and air treatment devices // Copyright © 2025 Alexander Thoukydides import { DysonAppPlatform } from './dyson-cloud-types.js'; import { checkers } from './ti/dyson-cloud-types.js'; import { DysonCloudAPIUserAgent } from './dyson-cloud-api-ua.js'; // Dyson cloud API client for all device types export class DysonCloudAPI { log; config; china; token; // User agent used for all requests ua; // Construct a new Dyson cloud API client constructor(log, config, china, token) { this.log = log; this.config = config; this.china = china; this.token = token; // Create a user agent this.ua = new DysonCloudAPIUserAgent(log, config, china); // If a token was provided then set the Bearer header if (token) this.ua.setBearerToken(token); } // Retrieve list of supported markets (countries) getSupportedMarket() { const path = '/v1/supportedmarket'; return this.ua.request(checkers.DysonSupportedMarketResponse, 'GET', path); } // Retrieve version (required before login) getVersion(platform = DysonAppPlatform.iOS) { const path = `/v1/provisioningservice/application/${platform}/version`; return this.ua.request(checkers.DysonVersionResponse, 'GET', path); } // Check the status of a user account getUserStatus(email) { const body = { email }; const path = '/v3/userregistration/email/userstatus'; return this.ua.request(checkers.DysonEmailUserStatusResponse, 'POST', path, body); } // Start authorisation async startAuthorisation(email) { const body = { email }; const path = '/v3/userregistration/email/auth'; const response = await this.ua.request(checkers.DysonEmailAuthResponse, 'POST', path, body); return response.challengeId; } // Complete authorisation async completeAuthorisation(challengeId, email, otpCode, password) { const body = { challengeId, email, otpCode, password }; const path = '/v3/userregistration/email/verify'; const response = await this.ua.request(checkers.DysonEmailVerifyResponse, 'POST', path, body); this.ua.setBearerToken(response.token); return response; } // Request the list of devices associated with the account getManifest() { const path = '/v3/manifest'; return this.ua.request(checkers.DysonManifestResponse, 'GET', path, undefined); } // Retrieve the AWS IoT credentials for a specific device getIoTCredentials(serialNumber) { const body = { Serial: serialNumber }; const path = '/v2/authorize/iot-credentials'; return this.ua.request(checkers.DysonIoTCredentialsResponse, 'POST', path, body); } } //# sourceMappingURL=dyson-cloud-api.js.map