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.
71 lines • 2.91 kB
JavaScript
// Matterbridge plugin for Dyson robot vacuum and air treatment devices
// Copyright © 2025-2026 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';
import { DysonCloudAPIDevice } from './dyson-cloud-api-device.js';
import { assertIsDefined } from './utils.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.getJSON(checkers.DysonSupportedMarketResponse, path);
}
// Retrieve version (required before login)
getVersion(platform = DysonAppPlatform.iOS) {
const path = `/v1/provisioningservice/application/${platform}/version`;
return this.ua.getJSON(checkers.DysonVersionResponse, path);
}
// Check the status of a user account
getUserStatus(email) {
const body = { email };
const path = '/v3/userregistration/email/userstatus';
return this.ua.postJSON(checkers.DysonEmailUserStatusResponse, path, body);
}
// Start authorisation
async startAuthorisation(email) {
const body = { email };
const path = '/v3/userregistration/email/auth';
const response = await this.ua.postJSON(checkers.DysonEmailAuthResponse, 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.postJSON(checkers.DysonEmailVerifyResponse, path, body);
this.token = response.token;
this.ua.setBearerToken(response.token);
return response;
}
// Request the list of devices associated with the account
getManifest() {
const path = '/v3/manifest';
return this.ua.getJSON(checkers.DysonManifestResponse, path);
}
// Create a device-specific cloud API client
createDeviceClient(log, manifest) {
assertIsDefined(this.token);
return new DysonCloudAPIDevice(log, this.config, this.china, this.token, manifest);
}
}
//# sourceMappingURL=dyson-cloud-api.js.map