UNPKG

@intruder-detection/shelly-api-typescript

Version:

Typescript client for the Shelly HTTP API

1,262 lines (1,242 loc) 49 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { AxiosErrorCodes: () => AxiosErrorCodes, BLEMethods: () => BLEMethods, BTHomeDeviceMethods: () => BTHomeDeviceMethods, BTHomeMethods: () => BTHomeMethods, BTHomeSensorMethods: () => BTHomeSensorMethods, BooleanMethods: () => BooleanMethods, ButtonMethods: () => ButtonMethods, CloudMethods: () => CloudMethods, CommonErrors: () => CommonErrors, CoverMethods: () => CoverMethods, DevicePowerMethods: () => DevicePowerMethods, EnumMethods: () => EnumMethods, EthernetMethods: () => EthernetMethods, Gen1Device: () => Gen1Device, GroupMethods: () => GroupMethods, HTTPMethods: () => HTTPMethods, InputHelpers: () => InputHelpers, InputMethods: () => InputMethods, Inputs: () => Inputs, KVSMethods: () => KVSMethods, KvsHelpers: () => KvsHelpers, LightMethods: () => LightMethods, MQTTMethods: () => MQTTMethods, ModbusMethods: () => ModbusMethods, MqttHelpers: () => MqttHelpers, NumberMethods: () => NumberMethods, ScheduleMethods: () => ScheduleMethods, ScriptHelpers: () => ScriptHelpers, ScriptMethods: () => ScriptMethods, Shelly1And1PMEndpoints: () => Shelly1And1PMEndpoints, Shelly1LEndpoints: () => Shelly1LEndpoints, Shelly1PlugPlugsDevice: () => Shelly1PlugPlugsDevice, Shelly2Endpoints: () => Shelly2Endpoints, Shelly2_5Endpoints: () => Shelly2_5Endpoints, ShellyEndpoints: () => ShellyEndpoints, ShellyExtraMethods: () => ShellyExtraMethods, ShellyGen2PlusHTTPAPI: () => ShellyGen2PlusHTTPAPI, ShellyHelpers: () => ShellyHelpers, ShellyMethods: () => ShellyMethods, ShellyMotionEndpoints: () => ShellyMotionEndpoints, ShellyPlugPlugSEndpoints: () => ShellyPlugPlugSEndpoints, SwitchMethods: () => SwitchMethods, SystemMethods: () => SystemMethods, TextMethods: () => TextMethods, Timezones: () => Timezones, VirtualMethods: () => VirtualMethods, VoltmeterMethods: () => VoltmeterMethods, WebhookMethods: () => WebhookMethods, WebhooksHelpers: () => WebhooksHelpers, WifiHelpers: () => WifiHelpers, WifiMethods: () => WifiMethods, WsMethods: () => WsMethods }); module.exports = __toCommonJS(src_exports); // src/common/common-errors.enum.ts var CommonErrors = /* @__PURE__ */ ((CommonErrors2) => { CommonErrors2[CommonErrors2["InvalidArgument"] = -103] = "InvalidArgument"; CommonErrors2[CommonErrors2["DeadlineExceeded"] = -104] = "DeadlineExceeded"; CommonErrors2[CommonErrors2["KeyNotFound"] = -105] = "KeyNotFound"; CommonErrors2[CommonErrors2["ResourceAlreadyExists"] = -106] = "ResourceAlreadyExists"; CommonErrors2[CommonErrors2["ResourceExausted"] = -108] = "ResourceExausted"; CommonErrors2[CommonErrors2["FailedPreconditon"] = -109] = "FailedPreconditon"; CommonErrors2[CommonErrors2["Unavaliable"] = -114] = "Unavaliable"; CommonErrors2[CommonErrors2["NoHandlerFound"] = 404] = "NoHandlerFound"; CommonErrors2[CommonErrors2["RequestTimeout"] = 408] = "RequestTimeout"; return CommonErrors2; })(CommonErrors || {}); // src/common/generic.types.ts var AxiosErrorCodes = /* @__PURE__ */ ((AxiosErrorCodes2) => { AxiosErrorCodes2["Timeout"] = "ETIMEDOUT"; AxiosErrorCodes2["ConnectionAborted"] = "ECONNABORTED"; return AxiosErrorCodes2; })(AxiosErrorCodes || {}); // src/common/shelly-gen-2-plus-http-api.ts var import_axios = __toESM(require("axios")); var ShellyGen2PlusHTTPAPI = class _ShellyGen2PlusHTTPAPI { constructor(ip) { this.ip = ip; } static get defaultRequestConfig() { return { headers: { contentType: "application/json" }, timeout: 5e3, // TODO: Provide as an environment variable transitional: { clarifyTimeoutError: true }, responseType: "json" }; } static buildBodyData(endpoint, bodyData) { return { id: 1, method: endpoint, src: "my_self", params: bodyData }; } async post(endpoint, body) { try { const rxp = await import_axios.default.post( this.getUrl(), _ShellyGen2PlusHTTPAPI.buildBodyData(endpoint, body), _ShellyGen2PlusHTTPAPI.defaultRequestConfig ); const data = rxp.data; if (data.error) { throw new import_axios.AxiosError(data.error.message, String(data.error.code)); } return rxp.data; } catch (e) { this.throwError(endpoint, e); } } async get(endpoint) { try { const rxp = await import_axios.default.get( this.getUrl(endpoint), _ShellyGen2PlusHTTPAPI.defaultRequestConfig ); const data = rxp.data; if (data.error) { throw new import_axios.AxiosError(data.error.message, String(data.error.code)); } return rxp.data; } catch (e) { this.throwError(endpoint, e); } } throwError(endpoint, e) { throw new Error( `Failed to run command ${endpoint} on device ${this.ip}. Error is: ${e.message}. Error code: ${e.code} (See CommonErrors enum for more information).` ); } getUrl(endpoint = "rpc") { return `http://${this.ip}/${endpoint}`; } }; // src/gen1/gen1-device.ts var import_axios2 = __toESM(require("axios")); // src/gen1/enums/endpoints.enum.ts var ShellyEndpoints = /* @__PURE__ */ ((ShellyEndpoints2) => { ShellyEndpoints2["Shelly"] = "shelly"; ShellyEndpoints2["Settings"] = "settings"; ShellyEndpoints2["SettingsWifiAccessPoint"] = "settings/ap"; ShellyEndpoints2["SettingsWifiStation"] = "settings/sta"; ShellyEndpoints2["SettingsLogin"] = "settings/login"; ShellyEndpoints2["SettingsCloud"] = "settings/cloud"; ShellyEndpoints2["SettingsActions"] = "settings/actions"; ShellyEndpoints2["Status"] = "status"; ShellyEndpoints2["Reboot"] = "reboot"; ShellyEndpoints2["OTA"] = "ota"; ShellyEndpoints2["OTACheck"] = "ota/check"; ShellyEndpoints2["WifiScan"] = "wifiscan"; ShellyEndpoints2["DebugLog"] = "debug/log"; ShellyEndpoints2["DebugLog1"] = "debug/log1"; ShellyEndpoints2["CoIoTInformation"] = "cit/d"; ShellyEndpoints2["WifiStationCacheReset"] = "sta_cache_reset"; return ShellyEndpoints2; })(ShellyEndpoints || {}); var Shelly1And1PMEndpoints = /* @__PURE__ */ ((Shelly1And1PMEndpoints2) => { Shelly1And1PMEndpoints2["SettingsRelay0"] = "settings/relay/0"; Shelly1And1PMEndpoints2["SettingsPower0"] = "settings/power/0"; Shelly1And1PMEndpoints2["SettingsExternalHumidity0"] = "settings/ext_humidity/0"; Shelly1And1PMEndpoints2["Relay0"] = "relay/0"; return Shelly1And1PMEndpoints2; })(Shelly1And1PMEndpoints || {}); var Shelly1LEndpoints = /* @__PURE__ */ ((Shelly1LEndpoints2) => { Shelly1LEndpoints2["SettingsRelay0"] = "settings/relay/0"; Shelly1LEndpoints2["SettingsPower0"] = "settings/power/0"; Shelly1LEndpoints2["Relay0"] = "relay/0"; return Shelly1LEndpoints2; })(Shelly1LEndpoints || {}); var Shelly2Endpoints = /* @__PURE__ */ ((Shelly2Endpoints2) => { Shelly2Endpoints2["SettingsRelayIndex"] = `settings/relay/:index`; Shelly2Endpoints2["SettingsRollerIndex"] = "settings/roller/:index"; Shelly2Endpoints2["MeterIndex"] = "meter/:index"; Shelly2Endpoints2["RelayIndex"] = "relay/:index"; Shelly2Endpoints2["RollerIndex"] = "roller/:index"; Shelly2Endpoints2["RollerIndexCalibrate"] = "roller/:index/calibrate"; return Shelly2Endpoints2; })(Shelly2Endpoints || {}); var Shelly2_5Endpoints = /* @__PURE__ */ ((Shelly2_5Endpoints2) => { Shelly2_5Endpoints2["SettingsRelayIndex"] = `settings/relay/:index`; Shelly2_5Endpoints2["SettingsRollerIndex"] = "settings/roller/:index"; Shelly2_5Endpoints2["SettingsFavoritesIndex"] = "settings/favorites/:index"; Shelly2_5Endpoints2["MeterIndex"] = "meter/:index"; Shelly2_5Endpoints2["RelayIndex"] = "relay/:index"; Shelly2_5Endpoints2["RollerIndex"] = "roller/:index"; Shelly2_5Endpoints2["RollerIndexCalibrate"] = "roller/:index/calibrate"; return Shelly2_5Endpoints2; })(Shelly2_5Endpoints || {}); var ShellyMotionEndpoints = /* @__PURE__ */ ((ShellyMotionEndpoints2) => { ShellyMotionEndpoints2["PowerOff"] = "poweroff"; return ShellyMotionEndpoints2; })(ShellyMotionEndpoints || {}); var ShellyPlugPlugSEndpoints = /* @__PURE__ */ ((ShellyPlugPlugSEndpoints2) => { ShellyPlugPlugSEndpoints2["SettingsRelay0"] = "settings/relay/0"; ShellyPlugPlugSEndpoints2["Meter0"] = "meter/0"; ShellyPlugPlugSEndpoints2["Relay0"] = "relay/0"; return ShellyPlugPlugSEndpoints2; })(ShellyPlugPlugSEndpoints || {}); // src/gen1/gen1-device.ts var Gen1Device = class _Gen1Device { constructor(ip, id = 1) { this.ip = ip; this.id = id; } /** * Converts a JavaScript object to a URL query string. * @example: * queryStringify({ a: 1, b: 2 }) // returns 'a=1&b=2' * queryStringify({ a: 1, b: [2, 3] }) // returns 'a=1&b=2&b=3' * queryStringify({ a: 1, b: null }) // returns 'a=1' * queryStringify({ a: 1, b: undefined }) // returns 'a=1' * queryStringify({ a: 1, b: [null, undefined] }) // returns 'a=1' * queryStringify({ a: 1, b: [2, null, 3, undefined] }) // returns 'a=1&b=2&b=3' * @param source - The object to convert. * @returns The URL query string. */ static queryStringify(source) { const urlSearch = new URLSearchParams(); Object.entries(source).forEach(([key, value]) => { if (value === null || value === void 0) { return; } if (value instanceof Array) { for (const innerValue of value) { if (innerValue !== null && innerValue !== void 0) { urlSearch.append(key, innerValue.toString()); } } return urlSearch; } return urlSearch.append(key, value.toString()); }); return urlSearch.toString(); } async shelly() { return await this.post("shelly" /* Shelly */); } async status() { return await this.post("status" /* Status */); } async settings(params) { return await this.post("settings" /* Settings */, params); } async settingsActions() { return await this.post("settings/actions" /* SettingsActions */); } async settingsWifiAccessPoint(params) { return await this.post("settings/ap" /* SettingsWifiAccessPoint */, params); } async settingsWifiStation(params) { return await this.post("settings/sta" /* SettingsWifiStation */, params); } async setSettingsLogin(params) { return await this.post("settings/login" /* SettingsLogin */, params); } async getSettingsLogin() { return await this.get("settings/login" /* SettingsLogin */); } async settingsCloud() { return await this.post("settings/cloud" /* SettingsCloud */); } async wifiScan() { return await this.post("wifiscan" /* WifiScan */); } async post(endpoint, params = {}) { const data = Object.keys(params).map((key) => `${key}=${encodeURIComponent(params[key])}`).join("&"); try { return (await import_axios2.default.post(`http://${this.ip}/${endpoint}`, data, { timeout: 5e3, // TODO: Provide as an environment variable transitional: { clarifyTimeoutError: true }, headers: { "content-type": "application/x-www-form-urlencoded" } })).data; } catch (e) { return { id: this.id, src: this.ip, error: { code: e.code === "ETIMEDOUT" /* Timeout */ ? 408 /* RequestTimeout */ : 404 /* NoHandlerFound */, message: `Error trying to request endpoint: ${endpoint} on shelly device with IP: ${this.ip}` } }; } } async get(endpoint, queryParameters) { try { return (await import_axios2.default.get(`http://${this.ip}/${endpoint}${queryParameters ? `?${_Gen1Device.queryStringify(queryParameters)}` : ""}`, { timeout: 5e3, // TODO: Provide as an environment variable transitional: { clarifyTimeoutError: true } })).data; } catch (e) { return { id: this.id, error: { code: e.code === "ETIMEDOUT" /* Timeout */ ? 408 /* RequestTimeout */ : 404 /* NoHandlerFound */, message: `Error trying to request endpoint: ${endpoint} on shelly device with IP: ${this.ip}` } }; } } }; // src/gen1/shelly1-plug-plugs-device.ts var Shelly1PlugPlugsDevice = class extends Gen1Device { async settings(params) { return await this.post("settings" /* Settings */, params); } async settingsRelay0() { return await this.post("settings/relay/0" /* SettingsRelay0 */); } async meter0() { return await this.post("meter/0" /* Meter0 */); } async relay0() { return await this.post("relay/0" /* Relay0 */); } }; // src/gen2/methods.enum.ts var ShellyMethods = /* @__PURE__ */ ((ShellyMethods2) => { ShellyMethods2["GetStatus"] = "Shelly.GetStatus"; ShellyMethods2["GetConfig"] = "Shelly.GetConfig"; ShellyMethods2["ListMethods"] = "Shelly.ListMethods"; ShellyMethods2["GetDeviceInfo"] = "Shelly.GetDeviceInfo"; ShellyMethods2["ListProfiles"] = "Shelly.ListProfiles"; ShellyMethods2["SetProfile"] = "Shelly.SetProfile"; ShellyMethods2["ListTimezones"] = "Shelly.ListTimezones"; ShellyMethods2["DetectLocation"] = "Shelly.DetectLocation"; ShellyMethods2["CheckForUpdate"] = "Shelly.CheckForUpdate"; ShellyMethods2["Update"] = "Shelly.Update"; ShellyMethods2["FactoryReset"] = "Shelly.FactoryReset"; ShellyMethods2["ResetWiFiConfig"] = "Shelly.ResetWiFiConfig"; ShellyMethods2["Reboot"] = "Shelly.Reboot"; ShellyMethods2["SetAuth"] = "Shelly.SetAuth"; ShellyMethods2["PutUserCA"] = "Shelly.PutUserCA"; ShellyMethods2["PutTLSClientCert"] = "Shelly.PutTLSClientCert"; ShellyMethods2["PutTLSClientKey"] = "Shelly.PutTLSClientKey"; ShellyMethods2["GetComponents"] = "Shelly.GetComponents"; return ShellyMethods2; })(ShellyMethods || {}); var ShellyExtraMethods = /* @__PURE__ */ ((ShellyExtraMethods2) => { ShellyExtraMethods2["Shelly"] = "shelly"; return ShellyExtraMethods2; })(ShellyExtraMethods || {}); var ScheduleMethods = /* @__PURE__ */ ((ScheduleMethods2) => { ScheduleMethods2["Create"] = "Schedule.Create"; ScheduleMethods2["Update"] = "Schedule.Update"; ScheduleMethods2["List"] = "Schedule.List"; ScheduleMethods2["Delete"] = "Schedule.Delete"; ScheduleMethods2["DeleteAll"] = "Schedule.DeleteAll"; return ScheduleMethods2; })(ScheduleMethods || {}); var WebhookMethods = /* @__PURE__ */ ((WebhookMethods2) => { WebhookMethods2["ListSupported"] = "Webhook.ListSupported"; WebhookMethods2["List"] = "Webhook.List"; WebhookMethods2["Create"] = "Webhook.Create"; WebhookMethods2["Update"] = "Webhook.Update"; WebhookMethods2["Delete"] = "Webhook.Delete"; WebhookMethods2["DeleteAll"] = "Webhook.DeleteAll"; return WebhookMethods2; })(WebhookMethods || {}); var HTTPMethods = /* @__PURE__ */ ((HTTPMethods2) => { HTTPMethods2["GET"] = "HTTP.GET"; return HTTPMethods2; })(HTTPMethods || {}); var KVSMethods = /* @__PURE__ */ ((KVSMethods2) => { KVSMethods2["Set"] = "KVS.Set"; KVSMethods2["Get"] = "KVS.Get"; KVSMethods2["GetMany"] = "KVS.GetMany"; KVSMethods2["List"] = "KVS.List"; KVSMethods2["Delete"] = "KVS.Delete"; return KVSMethods2; })(KVSMethods || {}); var SystemMethods = /* @__PURE__ */ ((SystemMethods2) => { SystemMethods2["SetConfig"] = "Sys.SetConfig"; SystemMethods2["GetConfig"] = "Sys.GetConfig"; SystemMethods2["GetStatus"] = "Sys.GetStatus"; return SystemMethods2; })(SystemMethods || {}); var WifiMethods = /* @__PURE__ */ ((WifiMethods2) => { WifiMethods2["GetConfig"] = "WiFi.GetConfig"; WifiMethods2["SetConfig"] = "WiFi.SetConfig"; WifiMethods2["GetStatus"] = "WiFi.GetStatus"; WifiMethods2["Scan"] = "WiFi.Scan"; WifiMethods2["ListAPClients"] = "Wifi.ListAPClients"; return WifiMethods2; })(WifiMethods || {}); var EthernetMethods = /* @__PURE__ */ ((EthernetMethods2) => { EthernetMethods2["SetConfig"] = "Eth.SetConfig"; EthernetMethods2["GetConfig"] = "Eth.GetConfig"; EthernetMethods2["GetStatus"] = "Eth.GetStatus"; return EthernetMethods2; })(EthernetMethods || {}); var BLEMethods = /* @__PURE__ */ ((BLEMethods2) => { BLEMethods2["SetConfig"] = "BLE.SetConfig"; BLEMethods2["GetConfig"] = "BLE.GetConfig"; BLEMethods2["GetStatus"] = "BLE.GetStatus"; return BLEMethods2; })(BLEMethods || {}); var CloudMethods = /* @__PURE__ */ ((CloudMethods2) => { CloudMethods2["SetConfig"] = "Cloud.SetConfig"; CloudMethods2["GetConfig"] = "Cloud.GetConfig"; CloudMethods2["GetStatus"] = "Cloud.GetStatus"; return CloudMethods2; })(CloudMethods || {}); var MQTTMethods = /* @__PURE__ */ ((MQTTMethods2) => { MQTTMethods2["SetConfig"] = "MQTT.SetConfig"; MQTTMethods2["GetConfig"] = "MQTT.GetConfig"; MQTTMethods2["GetStatus"] = "MQTT.GetStatus"; return MQTTMethods2; })(MQTTMethods || {}); var WsMethods = /* @__PURE__ */ ((WsMethods2) => { WsMethods2["SetConfig"] = "Ws.SetConfig"; WsMethods2["GetConfig"] = "Ws.GetConfig"; WsMethods2["GetStatus"] = "Ws.GetStatus"; return WsMethods2; })(WsMethods || {}); var ScriptMethods = /* @__PURE__ */ ((ScriptMethods2) => { ScriptMethods2["Create"] = "Script.Create"; ScriptMethods2["Delete"] = "Script.Delete"; ScriptMethods2["Eval"] = "Script.Eval"; ScriptMethods2["GetCode"] = "Script.GetCode"; ScriptMethods2["GetConfig"] = "Script.GetConfig"; ScriptMethods2["GetStatus"] = "Script.GetStatus"; ScriptMethods2["List"] = "Script.List"; ScriptMethods2["PutCode"] = "Script.PutCode"; ScriptMethods2["SetConfig"] = "Script.SetConfig"; ScriptMethods2["Start"] = "Script.Start"; ScriptMethods2["Stop"] = "Script.Stop"; return ScriptMethods2; })(ScriptMethods || {}); var SwitchMethods = /* @__PURE__ */ ((SwitchMethods2) => { SwitchMethods2["Set"] = "Switch.Set"; SwitchMethods2["Toggle"] = "Switch.Toggle"; SwitchMethods2["SetConfig"] = "Switch.SetConfig"; SwitchMethods2["GetConfig"] = "Switch.GetConfig"; SwitchMethods2["GetStatus"] = "Switch.GetStatus"; SwitchMethods2["ResetCounters"] = "Switch.ResetCounters"; return SwitchMethods2; })(SwitchMethods || {}); var InputMethods = /* @__PURE__ */ ((InputMethods2) => { InputMethods2["GetConfig"] = "Input.GetConfig"; InputMethods2["SetConfig"] = "Input.SetConfig"; InputMethods2["GetStatus"] = "Input.GetStatus"; InputMethods2["CheckExpression"] = "Input.CheckExpression"; InputMethods2["ResetCounters"] = "Input.ResetCounters"; InputMethods2["Trigger"] = "Input.Trigger"; return InputMethods2; })(InputMethods || {}); var ModbusMethods = /* @__PURE__ */ ((ModbusMethods2) => { ModbusMethods2["SetConfig"] = "Modbus.SetConfig"; ModbusMethods2["GetConfig"] = "Modbus.GetConfig"; ModbusMethods2["GetStatus"] = "Modbus.GetStatus"; return ModbusMethods2; })(ModbusMethods || {}); var VoltmeterMethods = /* @__PURE__ */ ((VoltmeterMethods2) => { VoltmeterMethods2["SetConfig"] = "Voltmeter.SetConfig"; VoltmeterMethods2["GetConfig"] = "Voltmeter.GetConfig"; VoltmeterMethods2["GetStatus"] = "Voltmeter.GetStatus"; return VoltmeterMethods2; })(VoltmeterMethods || {}); var CoverMethods = /* @__PURE__ */ ((CoverMethods2) => { CoverMethods2["SetConfig"] = "Cover.SetConfig"; CoverMethods2["GetConfig"] = "Cover.GetConfig"; CoverMethods2["GetStatus"] = "Cover.GetStatus"; CoverMethods2["Open"] = "Cover.Open"; CoverMethods2["Close"] = "Cover.Close"; CoverMethods2["Stop"] = "Cover.Stop"; CoverMethods2["GoToPosition"] = "Cover.GoToPosition"; CoverMethods2["Calibrate"] = "Cover.Calibrate"; CoverMethods2["ResetCounters"] = "Cover.ResetCounters"; return CoverMethods2; })(CoverMethods || {}); var LightMethods = /* @__PURE__ */ ((LightMethods2) => { LightMethods2["SetConfig"] = "Light.SetConfig"; LightMethods2["GetConfig"] = "Light.GetConfig"; LightMethods2["GetStatus"] = "Light.GetStatus"; LightMethods2["Set"] = "Light.Set"; LightMethods2["Toggle"] = "Light.Toggle"; LightMethods2["Calibrate"] = "Light.Calibrate"; LightMethods2["ResetCounters"] = "Light.ResetCounters"; return LightMethods2; })(LightMethods || {}); var DevicePowerMethods = /* @__PURE__ */ ((DevicePowerMethods2) => { DevicePowerMethods2["SetConfig"] = "DevicePower.SetConfig"; DevicePowerMethods2["GetConfig"] = "DevicePower.GetConfig"; DevicePowerMethods2["GetStatus"] = "DevicePower.GetStatus"; return DevicePowerMethods2; })(DevicePowerMethods || {}); // src/gen2/endpoints/types/common/timezones.enum.ts var Timezones = /* @__PURE__ */ ((Timezones2) => { Timezones2["Abidjan"] = "Africa/Abidjan"; Timezones2["Algiers"] = "Africa/Algiers"; Timezones2["Bissau"] = "Africa/Bissau"; Timezones2["Cairo"] = "Africa/Cairo"; Timezones2["Casablanca"] = "Africa/Casablanca"; Timezones2["Ceuta"] = "Africa/Ceuta"; Timezones2["El_Aaiun"] = "Africa/El_Aaiun"; Timezones2["Johannesburg"] = "Africa/Johannesburg"; Timezones2["Juba"] = "Africa/Juba"; Timezones2["Khartoum"] = "Africa/Khartoum"; Timezones2["Lagos"] = "Africa/Lagos"; Timezones2["Maputo"] = "Africa/Maputo"; Timezones2["Monrovia"] = "Africa/Monrovia"; Timezones2["Nairobi"] = "Africa/Nairobi"; Timezones2["Ndjamena"] = "Africa/Ndjamena"; Timezones2["Sao_Tome"] = "Africa/Sao_Tome"; Timezones2["Tripoli"] = "Africa/Tripoli"; Timezones2["Tunis"] = "Africa/Tunis"; Timezones2["Windhoek"] = "Africa/Windhoek"; Timezones2["Adak"] = "America/Adak"; Timezones2["Anchorage"] = "America/Anchorage"; Timezones2["Araguaina"] = "America/Araguaina"; Timezones2["Buenos_Aires"] = "America/Argentina/Buenos_Aires"; Timezones2["Catamarca"] = "America/Argentina/Catamarca"; Timezones2["Cordoba"] = "America/Argentina/Cordoba"; Timezones2["Jujuy"] = "America/Argentina/Jujuy"; Timezones2["La_Rioja"] = "America/Argentina/La_Rioja"; Timezones2["Mendoza"] = "America/Argentina/Mendoza"; Timezones2["Rio_Gallegos"] = "America/Argentina/Rio_Gallegos"; Timezones2["Salta"] = "America/Argentina/Salta"; Timezones2["San_Juan"] = "America/Argentina/San_Juan"; Timezones2["San_Luis"] = "America/Argentina/San_Luis"; Timezones2["Tucuman"] = "America/Argentina/Tucuman"; Timezones2["Ushuaia"] = "America/Argentina/Ushuaia"; Timezones2["Asuncion"] = "America/Asuncion"; Timezones2["Bahia"] = "America/Bahia"; Timezones2["Bahia_Banderas"] = "America/Bahia_Banderas"; Timezones2["Barbados"] = "America/Barbados"; Timezones2["Belem"] = "America/Belem"; Timezones2["Belize"] = "America/Belize"; Timezones2["Boa_Vista"] = "America/Boa_Vista"; Timezones2["Bogota"] = "America/Bogota"; Timezones2["Boise"] = "America/Boise"; Timezones2["Cambridge_Bay"] = "America/Cambridge_Bay"; Timezones2["Campo_Grande"] = "America/Campo_Grande"; Timezones2["Cancun"] = "America/Cancun"; Timezones2["Caracas"] = "America/Caracas"; Timezones2["Cayenne"] = "America/Cayenne"; Timezones2["Chicago"] = "America/Chicago"; Timezones2["Chihuahua"] = "America/Chihuahua"; Timezones2["Ciudad_Juarez"] = "America/Ciudad_Juarez"; Timezones2["Costa_Rica"] = "America/Costa_Rica"; Timezones2["Cuiaba"] = "America/Cuiaba"; Timezones2["Danmarkshavn"] = "America/Danmarkshavn"; Timezones2["Dawson"] = "America/Dawson"; Timezones2["Dawson_Creek"] = "America/Dawson_Creek"; Timezones2["Denver"] = "America/Denver"; Timezones2["Detroit"] = "America/Detroit"; Timezones2["Edmonton"] = "America/Edmonton"; Timezones2["Eirunepe"] = "America/Eirunepe"; Timezones2["El_Salvador"] = "America/El_Salvador"; Timezones2["Fort_Nelson"] = "America/Fort_Nelson"; Timezones2["Fortaleza"] = "America/Fortaleza"; Timezones2["Glace_Bay"] = "America/Glace_Bay"; Timezones2["Goose_Bay"] = "America/Goose_Bay"; Timezones2["Grand_Turk"] = "America/Grand_Turk"; Timezones2["Guatemala"] = "America/Guatemala"; Timezones2["Guayaquil"] = "America/Guayaquil"; Timezones2["Guyana"] = "America/Guyana"; Timezones2["Halifax"] = "America/Halifax"; Timezones2["Havana"] = "America/Havana"; Timezones2["Hermosillo"] = "America/Hermosillo"; Timezones2["Indianapolis"] = "America/Indiana/Indianapolis"; Timezones2["Knox"] = "America/Indiana/Knox"; Timezones2["Marengo"] = "America/Indiana/Marengo"; Timezones2["Petersburg"] = "America/Indiana/Petersburg"; Timezones2["Tell_City"] = "America/Indiana/Tell_City"; Timezones2["Vevay"] = "America/Indiana/Vevay"; Timezones2["Vincennes"] = "America/Indiana/Vincennes"; Timezones2["Winamac"] = "America/Indiana/Winamac"; Timezones2["Inuvik"] = "America/Inuvik"; Timezones2["Iqaluit"] = "America/Iqaluit"; Timezones2["Jamaica"] = "America/Jamaica"; Timezones2["Juneau"] = "America/Juneau"; Timezones2["Louisville"] = "America/Kentucky/Louisville"; Timezones2["Monticello"] = "America/Kentucky/Monticello"; Timezones2["La_Paz"] = "America/La_Paz"; Timezones2["Lima"] = "America/Lima"; Timezones2["Los_Angeles"] = "America/Los_Angeles"; Timezones2["Maceio"] = "America/Maceio"; Timezones2["Managua"] = "America/Managua"; Timezones2["Manaus"] = "America/Manaus"; Timezones2["Martinique"] = "America/Martinique"; Timezones2["Matamoros"] = "America/Matamoros"; Timezones2["Mazatlan"] = "America/Mazatlan"; Timezones2["Menominee"] = "America/Menominee"; Timezones2["Merida"] = "America/Merida"; Timezones2["Metlakatla"] = "America/Metlakatla"; Timezones2["Mexico_City"] = "America/Mexico_City"; Timezones2["Miquelon"] = "America/Miquelon"; Timezones2["Moncton"] = "America/Moncton"; Timezones2["Monterrey"] = "America/Monterrey"; Timezones2["Montevideo"] = "America/Montevideo"; Timezones2["New_York"] = "America/New_York"; Timezones2["Nome"] = "America/Nome"; Timezones2["Noronha"] = "America/Noronha"; Timezones2["Beulah"] = "America/North_Dakota/Beulah"; Timezones2["Center"] = "America/North_Dakota/Center"; Timezones2["New_Salem"] = "America/North_Dakota/New_Salem"; Timezones2["Nuuk"] = "America/Nuuk"; Timezones2["Ojinaga"] = "America/Ojinaga"; Timezones2["Panama"] = "America/Panama"; Timezones2["Paramaribo"] = "America/Paramaribo"; Timezones2["Phoenix"] = "America/Phoenix"; Timezones2["Port"] = "America/Port-au-Prince"; Timezones2["Porto_Velho"] = "America/Porto_Velho"; Timezones2["Puerto_Rico"] = "America/Puerto_Rico"; Timezones2["Punta_Arenas"] = "America/Punta_Arenas"; Timezones2["Rankin_Inlet"] = "America/Rankin_Inlet"; Timezones2["Recife"] = "America/Recife"; Timezones2["Regina"] = "America/Regina"; Timezones2["Resolute"] = "America/Resolute"; Timezones2["Rio_Branco"] = "America/Rio_Branco"; Timezones2["Santarem"] = "America/Santarem"; Timezones2["Santiago"] = "America/Santiago"; Timezones2["Santo_Domingo"] = "America/Santo_Domingo"; Timezones2["Sao_Paulo"] = "America/Sao_Paulo"; Timezones2["Scoresbysund"] = "America/Scoresbysund"; Timezones2["Sitka"] = "America/Sitka"; Timezones2["St_Johns"] = "America/St_Johns"; Timezones2["Swift_Current"] = "America/Swift_Current"; Timezones2["Tegucigalpa"] = "America/Tegucigalpa"; Timezones2["Thule"] = "America/Thule"; Timezones2["Tijuana"] = "America/Tijuana"; Timezones2["Toronto"] = "America/Toronto"; Timezones2["Vancouver"] = "America/Vancouver"; Timezones2["Whitehorse"] = "America/Whitehorse"; Timezones2["Winnipeg"] = "America/Winnipeg"; Timezones2["Yakutat"] = "America/Yakutat"; Timezones2["Casey"] = "Antarctica/Casey"; Timezones2["Davis"] = "Antarctica/Davis"; Timezones2["Macquarie"] = "Antarctica/Macquarie"; Timezones2["Mawson"] = "Antarctica/Mawson"; Timezones2["Palmer"] = "Antarctica/Palmer"; Timezones2["Rothera"] = "Antarctica/Rothera"; Timezones2["Troll"] = "Antarctica/Troll"; Timezones2["Almaty"] = "Asia/Almaty"; Timezones2["Amman"] = "Asia/Amman"; Timezones2["Anadyr"] = "Asia/Anadyr"; Timezones2["Aqtau"] = "Asia/Aqtau"; Timezones2["Aqtobe"] = "Asia/Aqtobe"; Timezones2["Ashgabat"] = "Asia/Ashgabat"; Timezones2["Atyrau"] = "Asia/Atyrau"; Timezones2["Baghdad"] = "Asia/Baghdad"; Timezones2["Baku"] = "Asia/Baku"; Timezones2["Bangkok"] = "Asia/Bangkok"; Timezones2["Barnaul"] = "Asia/Barnaul"; Timezones2["Beirut"] = "Asia/Beirut"; Timezones2["Bishkek"] = "Asia/Bishkek"; Timezones2["Chita"] = "Asia/Chita"; Timezones2["Choibalsan"] = "Asia/Choibalsan"; Timezones2["Colombo"] = "Asia/Colombo"; Timezones2["Damascus"] = "Asia/Damascus"; Timezones2["Dhaka"] = "Asia/Dhaka"; Timezones2["Dili"] = "Asia/Dili"; Timezones2["Dubai"] = "Asia/Dubai"; Timezones2["Dushanbe"] = "Asia/Dushanbe"; Timezones2["Famagusta"] = "Asia/Famagusta"; Timezones2["Gaza"] = "Asia/Gaza"; Timezones2["Hebron"] = "Asia/Hebron"; Timezones2["Ho_Chi_Minh"] = "Asia/Ho_Chi_Minh"; Timezones2["Hong_Kong"] = "Asia/Hong_Kong"; Timezones2["Hovd"] = "Asia/Hovd"; Timezones2["Irkutsk"] = "Asia/Irkutsk"; Timezones2["Jakarta"] = "Asia/Jakarta"; Timezones2["Jayapura"] = "Asia/Jayapura"; Timezones2["Jerusalem"] = "Asia/Jerusalem"; Timezones2["Kabul"] = "Asia/Kabul"; Timezones2["Kamchatka"] = "Asia/Kamchatka"; Timezones2["Karachi"] = "Asia/Karachi"; Timezones2["Kathmandu"] = "Asia/Kathmandu"; Timezones2["Khandyga"] = "Asia/Khandyga"; Timezones2["Kolkata"] = "Asia/Kolkata"; Timezones2["Krasnoyarsk"] = "Asia/Krasnoyarsk"; Timezones2["Kuching"] = "Asia/Kuching"; Timezones2["Macau"] = "Asia/Macau"; Timezones2["Magadan"] = "Asia/Magadan"; Timezones2["Makassar"] = "Asia/Makassar"; Timezones2["Manila"] = "Asia/Manila"; Timezones2["Nicosia"] = "Asia/Nicosia"; Timezones2["Novokuznetsk"] = "Asia/Novokuznetsk"; Timezones2["Novosibirsk"] = "Asia/Novosibirsk"; Timezones2["Omsk"] = "Asia/Omsk"; Timezones2["Oral"] = "Asia/Oral"; Timezones2["Pontianak"] = "Asia/Pontianak"; Timezones2["Pyongyang"] = "Asia/Pyongyang"; Timezones2["Qatar"] = "Asia/Qatar"; Timezones2["Qostanay"] = "Asia/Qostanay"; Timezones2["Qyzylorda"] = "Asia/Qyzylorda"; Timezones2["Riyadh"] = "Asia/Riyadh"; Timezones2["Sakhalin"] = "Asia/Sakhalin"; Timezones2["Samarkand"] = "Asia/Samarkand"; Timezones2["Seoul"] = "Asia/Seoul"; Timezones2["Shanghai"] = "Asia/Shanghai"; Timezones2["Singapore"] = "Asia/Singapore"; Timezones2["Srednekolymsk"] = "Asia/Srednekolymsk"; Timezones2["Taipei"] = "Asia/Taipei"; Timezones2["Tashkent"] = "Asia/Tashkent"; Timezones2["Tbilisi"] = "Asia/Tbilisi"; Timezones2["Tehran"] = "Asia/Tehran"; Timezones2["Thimphu"] = "Asia/Thimphu"; Timezones2["Tokyo"] = "Asia/Tokyo"; Timezones2["Tomsk"] = "Asia/Tomsk"; Timezones2["Ulaanbaatar"] = "Asia/Ulaanbaatar"; Timezones2["Urumqi"] = "Asia/Urumqi"; Timezones2["Ust"] = "Asia/Ust-Nera"; Timezones2["Vladivostok"] = "Asia/Vladivostok"; Timezones2["Yakutsk"] = "Asia/Yakutsk"; Timezones2["Yangon"] = "Asia/Yangon"; Timezones2["Yekaterinburg"] = "Asia/Yekaterinburg"; Timezones2["Yerevan"] = "Asia/Yerevan"; Timezones2["Azores"] = "Atlantic/Azores"; Timezones2["Bermuda"] = "Atlantic/Bermuda"; Timezones2["Canary"] = "Atlantic/Canary"; Timezones2["Cape_Verde"] = "Atlantic/Cape_Verde"; Timezones2["Faroe"] = "Atlantic/Faroe"; Timezones2["Madeira"] = "Atlantic/Madeira"; Timezones2["South_Georgia"] = "Atlantic/South_Georgia"; Timezones2["Stanley"] = "Atlantic/Stanley"; Timezones2["Adelaide"] = "Australia/Adelaide"; Timezones2["Brisbane"] = "Australia/Brisbane"; Timezones2["Broken_Hill"] = "Australia/Broken_Hill"; Timezones2["Darwin"] = "Australia/Darwin"; Timezones2["Eucla"] = "Australia/Eucla"; Timezones2["Hobart"] = "Australia/Hobart"; Timezones2["Lindeman"] = "Australia/Lindeman"; Timezones2["Lord_Howe"] = "Australia/Lord_Howe"; Timezones2["Melbourne"] = "Australia/Melbourne"; Timezones2["Perth"] = "Australia/Perth"; Timezones2["Sydney"] = "Australia/Sydney"; Timezones2["CET"] = "CET"; Timezones2["CST6CDT"] = "CST6CDT"; Timezones2["EET"] = "EET"; Timezones2["EST"] = "EST"; Timezones2["EST5EDT"] = "EST5EDT"; Timezones2["EtcGMT"] = "Etc/GMT"; Timezones2["GMTPlus1"] = "Etc/GMT+1"; Timezones2["GMTPlus10"] = "Etc/GMT+10"; Timezones2["GMTPlus11"] = "Etc/GMT+11"; Timezones2["GMTPlus12"] = "Etc/GMT+12"; Timezones2["GMTPlus2"] = "Etc/GMT+2"; Timezones2["GMTPlus3"] = "Etc/GMT+3"; Timezones2["GMTPlus4"] = "Etc/GMT+4"; Timezones2["GMTPlus5"] = "Etc/GMT+5"; Timezones2["GMTPlus6"] = "Etc/GMT+6"; Timezones2["GMTPlus7"] = "Etc/GMT+7"; Timezones2["GMTPlus8"] = "Etc/GMT+8"; Timezones2["GMTPlus9"] = "Etc/GMT+9"; Timezones2["GMTMinus1"] = "Etc/GMT-1"; Timezones2["GMTMinus10"] = "Etc/GMT-10"; Timezones2["GMTMinus11"] = "Etc/GMT-11"; Timezones2["GMTMinus12"] = "Etc/GMT-12"; Timezones2["GMTMinus13"] = "Etc/GMT-13"; Timezones2["GMTMinus14"] = "Etc/GMT-14"; Timezones2["GMTMinus2"] = "Etc/GMT-2"; Timezones2["GMTMinus3"] = "Etc/GMT-3"; Timezones2["GMTMinus4"] = "Etc/GMT-4"; Timezones2["GMTMinus5"] = "Etc/GMT-5"; Timezones2["GMTMinus6"] = "Etc/GMT-6"; Timezones2["GMTMinus7"] = "Etc/GMT-7"; Timezones2["GMTMinus8"] = "Etc/GMT-8"; Timezones2["GMTMinus9"] = "Etc/GMT-9"; Timezones2["UTC"] = "Etc/UTC"; Timezones2["Andorra"] = "Europe/Andorra"; Timezones2["Astrakhan"] = "Europe/Astrakhan"; Timezones2["Athens"] = "Europe/Athens"; Timezones2["Belgrade"] = "Europe/Belgrade"; Timezones2["Berlin"] = "Europe/Berlin"; Timezones2["Brussels"] = "Europe/Brussels"; Timezones2["Bucharest"] = "Europe/Bucharest"; Timezones2["Budapest"] = "Europe/Budapest"; Timezones2["Chisinau"] = "Europe/Chisinau"; Timezones2["Dublin"] = "Europe/Dublin"; Timezones2["Gibraltar"] = "Europe/Gibraltar"; Timezones2["Helsinki"] = "Europe/Helsinki"; Timezones2["Istanbul"] = "Europe/Istanbul"; Timezones2["Kaliningrad"] = "Europe/Kaliningrad"; Timezones2["Kirov"] = "Europe/Kirov"; Timezones2["Kyiv"] = "Europe/Kyiv"; Timezones2["Lisbon"] = "Europe/Lisbon"; Timezones2["London"] = "Europe/London"; Timezones2["Madrid"] = "Europe/Madrid"; Timezones2["Malta"] = "Europe/Malta"; Timezones2["Minsk"] = "Europe/Minsk"; Timezones2["Moscow"] = "Europe/Moscow"; Timezones2["Paris"] = "Europe/Paris"; Timezones2["Prague"] = "Europe/Prague"; Timezones2["Riga"] = "Europe/Riga"; Timezones2["Rome"] = "Europe/Rome"; Timezones2["Samara"] = "Europe/Samara"; Timezones2["Saratov"] = "Europe/Saratov"; Timezones2["Simferopol"] = "Europe/Simferopol"; Timezones2["Sofia"] = "Europe/Sofia"; Timezones2["Tallinn"] = "Europe/Tallinn"; Timezones2["Tirane"] = "Europe/Tirane"; Timezones2["Ulyanovsk"] = "Europe/Ulyanovsk"; Timezones2["Vienna"] = "Europe/Vienna"; Timezones2["Vilnius"] = "Europe/Vilnius"; Timezones2["Volgograd"] = "Europe/Volgograd"; Timezones2["Warsaw"] = "Europe/Warsaw"; Timezones2["Zurich"] = "Europe/Zurich"; Timezones2["Factory"] = "Factory"; Timezones2["GMT"] = "GMT"; Timezones2["HST"] = "HST"; Timezones2["Chagos"] = "Indian/Chagos"; Timezones2["Maldives"] = "Indian/Maldives"; Timezones2["Mauritius"] = "Indian/Mauritius"; Timezones2["MET"] = "MET"; Timezones2["MST"] = "MST"; Timezones2["MST7MDT"] = "MST7MDT"; Timezones2["PST8PDT"] = "PST8PDT"; Timezones2["Apia"] = "Pacific/Apia"; Timezones2["Auckland"] = "Pacific/Auckland"; Timezones2["Bougainville"] = "Pacific/Bougainville"; Timezones2["Chatham"] = "Pacific/Chatham"; Timezones2["Easter"] = "Pacific/Easter"; Timezones2["Efate"] = "Pacific/Efate"; Timezones2["Fakaofo"] = "Pacific/Fakaofo"; Timezones2["Fiji"] = "Pacific/Fiji"; Timezones2["Galapagos"] = "Pacific/Galapagos"; Timezones2["Gambier"] = "Pacific/Gambier"; Timezones2["Guadalcanal"] = "Pacific/Guadalcanal"; Timezones2["Guam"] = "Pacific/Guam"; Timezones2["Honolulu"] = "Pacific/Honolulu"; Timezones2["Kanton"] = "Pacific/Kanton"; Timezones2["Kiritimati"] = "Pacific/Kiritimati"; Timezones2["Kosrae"] = "Pacific/Kosrae"; Timezones2["Kwajalein"] = "Pacific/Kwajalein"; Timezones2["Marquesas"] = "Pacific/Marquesas"; Timezones2["Nauru"] = "Pacific/Nauru"; Timezones2["Niue"] = "Pacific/Niue"; Timezones2["Norfolk"] = "Pacific/Norfolk"; Timezones2["Noumea"] = "Pacific/Noumea"; Timezones2["Pago_Pago"] = "Pacific/Pago_Pago"; Timezones2["Palau"] = "Pacific/Palau"; Timezones2["Pitcairn"] = "Pacific/Pitcairn"; Timezones2["Port_Moresby"] = "Pacific/Port_Moresby"; Timezones2["Rarotonga"] = "Pacific/Rarotonga"; Timezones2["Tahiti"] = "Pacific/Tahiti"; Timezones2["Tarawa"] = "Pacific/Tarawa"; Timezones2["Tongatapu"] = "Pacific/Tongatapu"; Timezones2["WET"] = "WET"; return Timezones2; })(Timezones || {}); // src/gen2/endpoints/types/input/input-common.types.ts var Inputs = /* @__PURE__ */ ((Inputs2) => { Inputs2["zero"] = "input:0"; Inputs2["one"] = "input:1"; Inputs2["two"] = "input:2"; Inputs2["three"] = "input:3"; return Inputs2; })(Inputs || {}); // src/gen3/methods.enum.ts var VirtualMethods = /* @__PURE__ */ ((VirtualMethods2) => { VirtualMethods2["Add"] = "Virtual.Add"; VirtualMethods2["Delete"] = "Virtual.Delete"; return VirtualMethods2; })(VirtualMethods || {}); var BooleanMethods = /* @__PURE__ */ ((BooleanMethods2) => { BooleanMethods2["SetConfig"] = "Boolean.SetConfig"; BooleanMethods2["GetConfig"] = "Boolean.GetConfig"; BooleanMethods2["GetStatus"] = "Boolean.GetStatus"; BooleanMethods2["Set"] = "Boolean.Set"; return BooleanMethods2; })(BooleanMethods || {}); var NumberMethods = /* @__PURE__ */ ((NumberMethods2) => { NumberMethods2["SetConfig"] = "Number.SetConfig"; NumberMethods2["GetConfig"] = "Number.GetConfig"; NumberMethods2["GetStatus"] = "Number.GetStatus"; NumberMethods2["Set"] = "Number.Set"; return NumberMethods2; })(NumberMethods || {}); var TextMethods = /* @__PURE__ */ ((TextMethods2) => { TextMethods2["SetConfig"] = "Text.SetConfig"; TextMethods2["GetConfig"] = "Text.GetConfig"; TextMethods2["GetStatus"] = "Text.GetStatus"; TextMethods2["Set"] = "Text.Set"; return TextMethods2; })(TextMethods || {}); var EnumMethods = /* @__PURE__ */ ((EnumMethods2) => { EnumMethods2["SetConfig"] = "Enum.SetConfig"; EnumMethods2["GetConfig"] = "Enum.GetConfig"; EnumMethods2["GetStatus"] = "Enum.GetStatus"; EnumMethods2["Set"] = "Enum.Set"; return EnumMethods2; })(EnumMethods || {}); var ButtonMethods = /* @__PURE__ */ ((ButtonMethods2) => { ButtonMethods2["SetConfig"] = "Button.SetConfig"; ButtonMethods2["GetConfig"] = "Button.GetConfig"; ButtonMethods2["Trigger"] = "Button.Trigger"; return ButtonMethods2; })(ButtonMethods || {}); var GroupMethods = /* @__PURE__ */ ((GroupMethods2) => { GroupMethods2["SetConfig"] = "Group.SetConfig"; GroupMethods2["GetConfig"] = "Group.GetConfig"; GroupMethods2["GetStatus"] = "Group.GetStatus"; GroupMethods2["Set"] = "Group.Set"; return GroupMethods2; })(GroupMethods || {}); var BTHomeMethods = /* @__PURE__ */ ((BTHomeMethods2) => { BTHomeMethods2["SetConfig"] = "BTHome.SetConfig"; BTHomeMethods2["GetConfig"] = "BTHome.GetConfig"; BTHomeMethods2["GetStatus"] = "BTHome.GetStatus"; BTHomeMethods2["AddDevice"] = "BTHome.AddDevice"; BTHomeMethods2["DeleteDevice"] = "BTHome.DeleteDevice"; BTHomeMethods2["AddSensor"] = "BTHome.AddSensor"; BTHomeMethods2["DeleteSensor"] = "BTHome.DeleteSensor"; BTHomeMethods2["StartDeviceDiscovery"] = "BTHome.StartDeviceDiscovery"; BTHomeMethods2["GetObjectInfos"] = "BTHome.GetObjectInfos"; return BTHomeMethods2; })(BTHomeMethods || {}); var BTHomeDeviceMethods = /* @__PURE__ */ ((BTHomeDeviceMethods2) => { BTHomeDeviceMethods2["SetConfig"] = "BTHomeDevice.SetConfig"; BTHomeDeviceMethods2["GetConfig"] = "BTHomeDevice.GetConfig"; BTHomeDeviceMethods2["GetStatus"] = "BTHomeDevice.GetStatus"; BTHomeDeviceMethods2["GetKnownObjects"] = "BTHomeDevice.GetKnownObjects"; return BTHomeDeviceMethods2; })(BTHomeDeviceMethods || {}); var BTHomeSensorMethods = /* @__PURE__ */ ((BTHomeSensorMethods2) => { BTHomeSensorMethods2["SetConfig"] = "BTHomeSensor.SetConfig"; BTHomeSensorMethods2["GetConfig"] = "BTHomeSensor.GetConfig"; BTHomeSensorMethods2["GetStatus"] = "BTHomeSensor.GetStatus"; return BTHomeSensorMethods2; })(BTHomeSensorMethods || {}); // src/helpers/input/input.helpers.ts var InputHelpers = class { constructor(gen2Device) { this.gen2Device = gen2Device; } async getInputs() { const config = await this.gen2Device.post("Shelly.GetConfig" /* GetConfig */); return Object.values(Inputs).map((key) => config.result[key]); } async getStatus(id) { return this.gen2Device.post("Input.GetStatus" /* GetStatus */, { id }); } async getConfig(id) { return this.gen2Device.post("Input.GetConfig" /* GetConfig */, { id }); } }; // src/helpers/kvs/kvs.helpers.ts var KvsHelpers = class { constructor(gen2Device) { this.gen2Device = gen2Device; } async listAll() { return this.gen2Device.post("KVS.List" /* List */); } async deleteKey(key, etag) { return this.gen2Device.post("KVS.Delete" /* Delete */, { key, etag }); } async hasKey(key) { try { await this.gen2Device.post("KVS.Get" /* Get */, { key }); return true; } catch (e) { return false; } } async setKey(kvs) { if (kvs.key.length > 42) { throw new Error("Maximum key length is 42"); } if (JSON.stringify(kvs.value).length > 255) { throw new Error("Maximum value length is 255"); } const numExistingKeys = Object.keys((await this.listAll()).result.keys).length; if (numExistingKeys >= 50) { throw new Error("Maximum number of keys is 50"); } return this.gen2Device.post("KVS.Set" /* Set */, kvs); } async deleteAll() { const allKVS = await this.listAll(); for (const [key, val] of Object.entries(allKVS.result.keys)) { await this.deleteKey(key, val.etag); } } }; // src/helpers/mqtt/mqtt.helpers.ts var MqttHelpers = class { constructor(gen2Device) { this.gen2Device = gen2Device; } async setConfig(config) { return this.gen2Device.post("MQTT.SetConfig" /* SetConfig */, { config }); } }; // src/helpers/scripts/script.helpers.ts var ScriptHelpers = class { constructor(gen2Device) { this.gen2Device = gen2Device; } async listScripts() { return this.gen2Device.post("Script.List" /* List */); } async deleteScript(id) { return this.gen2Device.post("Script.Delete" /* Delete */, { id }); } async createScript(name) { return await this.gen2Device.post("Script.Create" /* Create */, { name }); } async getScriptWithName(name) { const scriptListResponse = await this.listScripts(); return scriptListResponse.result?.scripts?.find((script) => script.name === name); } async getScriptWithId(id) { const scriptListResponse = await this.listScripts(); return scriptListResponse.result?.scripts?.find((script) => script.id === id); } async getScriptFullData(id) { const [scriptConfig, scriptStatus] = await Promise.all([ this.gen2Device.post("Script.GetConfig" /* GetConfig */, { id }), this.gen2Device.post("Script.GetStatus" /* GetStatus */, { id }) ]); return { config: scriptConfig, status: scriptStatus }; } async hasScriptWithId(id) { return await this.getScriptWithId(id) !== void 0; } async hasScriptWithName(name) { return await this.getScriptWithName(name) !== void 0; } async createNewScriptIfNotExists(name) { const scriptWithName = await this.getScriptWithName(name); if (!scriptWithName) { const creatScriptResponse = await this.createScript(name); return creatScriptResponse.result.id; } return scriptWithName.id; } async uploadScriptInChunks(id, code, chunkSize = 1024) { for (let position = 0, append = false; position < code.length; position += chunkSize) { const chunk = code.slice(position, position + chunkSize); await this.uploadChunk(id, chunk, append); append = true; } } async deleteAllScripts() { const listOfScripts = await this.listScripts(); const deletedScriptIds = []; for (let script of listOfScripts.result.scripts) { await this.deleteScript(script.id); deletedScriptIds.push(script.id); } return deletedScriptIds; } async disableScript(id) { await this.gen2Device.post("Script.SetConfig" /* SetConfig */, { id, config: { enable: false } }); } async enableScript(id) { await this.gen2Device.post("Script.SetConfig" /* SetConfig */, { id, config: { enable: true } }); } async startScript(id) { return await this.gen2Device.post("Script.Start" /* Start */, { id }); } async uploadChunk(id, codeChunk, append) { await this.gen2Device.post("Script.PutCode" /* PutCode */, { id, code: codeChunk, append }); } }; // src/helpers/shelly/shelly.helpers.ts var ShellyHelpers = class { constructor(gen2Device) { this.gen2Device = gen2Device; } async getConfig() { return this.gen2Device.post("Shelly.GetConfig" /* GetConfig */); } async getStatus() { return this.gen2Device.post("Shelly.GetStatus" /* GetStatus */); } async reboot(rebootBody) { if (rebootBody && rebootBody.delay_ms < 500) { throw new Error(`Reboot delay_ms provided was ${rebootBody.delay_ms} but must be equal or greater than 500`); } return this.gen2Device.post("Shelly.Reboot" /* Reboot */, rebootBody); } }; // src/helpers/webhooks/webhooks.helpers.ts var WebhooksHelpers = class { constructor(gen2Device) { this.gen2Device = gen2Device; } async creatWebhook(webhookBody) { this.validateName(webhookBody.name); this.validateUrls(webhookBody.urls); return this.gen2Device.post("Webhook.Create" /* Create */, webhookBody); } validateName(name) { if (name.length > 300) { throw new Error("Provided webhook name has more than 300 characters"); } } validateUrls(urls) { if (!urls || urls.length < 1) { throw new Error("At least one urls is required"); } if (urls?.length > 5) { throw new Error("The maximum number of URLS is 5"); } const invalidUrlIndex = urls.findIndex((url) => url.length > 300); if (invalidUrlIndex !== -1) { throw new Error("Provided URL has more than 300 characters"); } } }; // src/helpers/wifi/wifi.helpers.ts var WifiHelpers = class { constructor(gen2PlusDevice) { this.gen2PlusDevice = gen2PlusDevice; } async getConfig() { return this.gen2PlusDevice.post("WiFi.GetConfig" /* GetConfig */); } async getStatus() { return this.gen2PlusDevice.post("WiFi.GetStatus" /* GetStatus */); } async setConfig(config) { return this.gen2PlusDevice.post("WiFi.SetConfig" /* SetConfig */, config); } async isConnectedToShellyNetwork() { const config = await this.getConfig(); return config.result.ap && config.result.ap.enable === true; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { AxiosErrorCodes, BLEMethods, BTHomeDeviceMethods, BTHomeMethods, BTHomeSensorMethods, BooleanMethods, ButtonMethods, CloudMethods, CommonErrors, CoverMethods, DevicePowerMethods, EnumMethods, EthernetMethods, Gen1Device, GroupMethods, HTTPMethods, InputHelpers, InputMethods, Inputs, KVSMethods, KvsHelpers, LightMethods, MQTTMethods, ModbusMethods, MqttHelpers, NumberMethods, ScheduleMethods, ScriptHelpers, ScriptMethods, Shelly1And1PMEndpoints, Shelly1LEndpoints, Shelly1PlugPlugsDevice, Shelly2Endpoints, Shelly2_5Endpoints, ShellyEndpoints, ShellyExtraMethods, ShellyGen2PlusHTTPAPI, ShellyHelpers, ShellyMethods, ShellyMotionEndpoints, ShellyPlugPlugSEndpoints, SwitchMethods, SystemMethods, TextMethods, Timezones, VirtualMethods, VoltmeterMethods, WebhookMethods, WebhooksHelpers, WifiHelpers, WifiMethods, WsMethods });