From 8a090709c9f3a356eef69672b17793d1c04b8a45 Mon Sep 17 00:00:00 2001 From: Chris Mullins Date: Sat, 12 Oct 2024 11:31:33 -0700 Subject: [PATCH 01/48] Update API to support new web UI --- docs/openapi.yaml | 120 ++++++++++++++++++++++++++-- lib/MiLightState/GroupState.cpp | 2 +- lib/MiLightState/GroupState.h | 2 +- lib/Types/MiLightRemoteType.cpp | 11 +++ lib/Types/MiLightRemoteType.h | 1 + lib/WebServer/MiLightHttpServer.cpp | 62 +++++++++++++- lib/WebServer/MiLightHttpServer.h | 8 ++ test/remote/spec/rest_spec.rb | 64 +++++++++++++++ 8 files changed, 259 insertions(+), 11 deletions(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 9d182112..af5667c3 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -126,6 +126,21 @@ paths: application/json: schema: $ref: '#/components/schemas/BooleanResponse' + /gateways: + get: + tags: + - Device Control + summary: Download a dump of all aliases and their current states + responses: + '200': + description: Successful operation + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/GatewayListItem' + /aliases.bin: get: tags: @@ -377,8 +392,11 @@ paths: to the commands sent are processed, and the updated `GroupState` will be returned. If `blockOnQueue` is false or not provided, a simple response indicating success will be returned. + + if `fmt` is set to `normalized`, the response will be in normalized format. parameters: - $ref: '#/components/parameters/BlockOnQueue' + - $ref: '#/components/parameters/StateResponseFormat' requestBody: content: application/json: @@ -402,6 +420,7 @@ paths: oneOf: - $ref: '#/components/schemas/BooleanResponse' - $ref: '#/components/schemas/GroupState' + - $ref: '#/components/schemas/NormalizedGroupState' delete: tags: - Device Control @@ -440,6 +459,7 @@ paths: summary: Patch device state by alias parameters: - $ref: '#/components/parameters/BlockOnQueue' + - $ref: '#/components/parameters/StateResponseFormat' requestBody: content: application/json: @@ -459,7 +479,10 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/GroupState' + oneOf: + - $ref: '#/components/schemas/BooleanResponse' + - $ref: '#/components/schemas/GroupState' + - $ref: '#/components/schemas/NormalizedGroupState' delete: tags: - Device Control by Alias @@ -614,6 +637,15 @@ components: schema: type: string required: true + StateResponseFormat: + name: fmt + in: query + description: If set to `normalized`, the response will be in normalized format. + schema: + type: string + enum: + - normalized + required: false BlockOnQueue: name: blockOnQueue in: query @@ -664,14 +696,19 @@ components: group_id: type: integer device_type: - type: string + $ref: '#/components/schemas/RemoteType' + required: + - alias + - device_id + - group_id + - device_type State: description: "On/Off state" type: string enum: - - On - - Off - example: On + - "ON" + - "OFF" + example: "ON" GroupStateCommand: type: string enum: @@ -806,6 +843,10 @@ components: example: 1 device_type: $ref: '#/components/schemas/RemoteType' + required: + - device_id + - group_id + - device_type GroupStateCommands: type: object properties: @@ -827,6 +868,72 @@ components: example: - level_up - temperature_up + GatewayListItem: + type: object + properties: + state: + $ref: '#/components/schemas/NormalizedGroupState' + device: + type: object + properties: + id: + type: number + device_id: + type: number + device_type: + $ref: '#/components/schemas/RemoteType' + group_id: + type: number + alias: + type: string + required: + - id + - device_id + - device_type + - group_id + - alias + required: + - state + - device + NormalizedGroupState: + type: object + description: Group state with a static set of fields + properties: + alias: + type: string + state: + $ref: '#/components/schemas/State' + color: + type: object + properties: + r: + type: integer + g: + type: integer + b: + type: integer + required: [r, g, b] + level: + type: integer + minimum: 0 + maximum: 100 + kelvin: + type: integer + minimum: 0 + maximum: 100 + color_mode: + $ref: '#/components/schemas/ColorMode' + + ColorMode: + type: string + description: > + Describes the current color mode of the bulb. Useful for HomeAssistant. + enum: + - brightness + - rgb + - color_temp + - onoff + GroupState: type: object description: Group state @@ -904,7 +1011,8 @@ components: description: > Enables a transition from current state to the provided state. example: 2.0 - + color_mode: + $ref: '#/components/schemas/ColorMode' RemoteType: type: string enum: diff --git a/lib/MiLightState/GroupState.cpp b/lib/MiLightState/GroupState.cpp index 8ec375cd..8053d058 100644 --- a/lib/MiLightState/GroupState.cpp +++ b/lib/MiLightState/GroupState.cpp @@ -1033,7 +1033,7 @@ ParsedColor GroupState::getColor() const { // build up a partial state representation based on the specified GrouipStateField array. Used // to gather a subset of states (configurable in the UI) for sending to MQTT and web responses. -void GroupState::applyState(JsonObject partialState, const BulbId& bulbId, std::vector& fields) const { +void GroupState::applyState(JsonObject partialState, const BulbId& bulbId, const std::vector& fields) const { for (std::vector::const_iterator itr = fields.begin(); itr != fields.end(); ++itr) { applyField(partialState, bulbId, *itr); } diff --git a/lib/MiLightState/GroupState.h b/lib/MiLightState/GroupState.h index 33cb773d..63cb2054 100644 --- a/lib/MiLightState/GroupState.h +++ b/lib/MiLightState/GroupState.h @@ -125,7 +125,7 @@ class GroupState { // state in this class. The alternative is to have every GroupState object // keep a reference to its BulbId, which feels too heavy-weight. void applyField(JsonObject state, const BulbId& bulbId, GroupStateField field) const; - void applyState(JsonObject state, const BulbId& bulbId, std::vector& fields) const; + void applyState(JsonObject state, const BulbId& bulbId, const std::vector& fields) const; // Attempt to keep track of increment commands in such a way that we can // know what state it's in. When we get an increment command (like "increase diff --git a/lib/Types/MiLightRemoteType.cpp b/lib/Types/MiLightRemoteType.cpp index 5d5ae8f4..ecd787c4 100644 --- a/lib/Types/MiLightRemoteType.cpp +++ b/lib/Types/MiLightRemoteType.cpp @@ -67,6 +67,17 @@ const String MiLightRemoteTypeHelpers::remoteTypeToString(const MiLightRemoteTyp } } +const bool MiLightRemoteTypeHelpers::supportsRgbw(const MiLightRemoteType type) { + switch (type) { + case REMOTE_TYPE_FUT089: + case REMOTE_TYPE_RGB_CCT: + case REMOTE_TYPE_RGBW: + return true; + default: + return false; + } +} + const bool MiLightRemoteTypeHelpers::supportsRgb(const MiLightRemoteType type) { switch (type) { case REMOTE_TYPE_FUT089: diff --git a/lib/Types/MiLightRemoteType.h b/lib/Types/MiLightRemoteType.h index 4372e03c..e8a648a7 100644 --- a/lib/Types/MiLightRemoteType.h +++ b/lib/Types/MiLightRemoteType.h @@ -18,5 +18,6 @@ class MiLightRemoteTypeHelpers { static const MiLightRemoteType remoteTypeFromString(const String& type); static const String remoteTypeToString(const MiLightRemoteType type); static const bool supportsRgb(const MiLightRemoteType type); + static const bool supportsRgbw(const MiLightRemoteType type); static const bool supportsColorTemp(const MiLightRemoteType type); }; \ No newline at end of file diff --git a/lib/WebServer/MiLightHttpServer.cpp b/lib/WebServer/MiLightHttpServer.cpp index 191ae547..68f84b3b 100644 --- a/lib/WebServer/MiLightHttpServer.cpp +++ b/lib/WebServer/MiLightHttpServer.cpp @@ -14,7 +14,6 @@ #include #include - #ifdef ESP32 #include #include @@ -72,6 +71,10 @@ void MiLightHttpServer::begin() { .on(HTTP_DELETE, std::bind(&MiLightHttpServer::handleDeleteGroupAlias, this, _1)) .on(HTTP_GET, std::bind(&MiLightHttpServer::handleGetGroupAlias, this, _1)); + server + .buildHandler("/gateways") + .onSimple(HTTP_GET, std::bind(&MiLightHttpServer::handleListGroups, this)); + server .buildHandler("/transitions/:id") .on(HTTP_GET, std::bind(&MiLightHttpServer::handleGetTransition, this, _1)) @@ -399,6 +402,7 @@ void MiLightHttpServer::handleListenGateway(RequestContext& request) { void MiLightHttpServer::sendGroupState(bool allowAsync, BulbId& bulbId, RichHttp::Response& response) { bool blockOnQueue = server.arg("blockOnQueue").equalsIgnoreCase("true"); + bool normalizedFormat = server.arg("fmt").equalsIgnoreCase("normalized"); // Wait for packet queue to flush out. State will not have been updated before that. // Bit hacky to call loop outside of main loop, but should be fine. @@ -414,7 +418,7 @@ void MiLightHttpServer::sendGroupState(bool allowAsync, BulbId& bulbId, RichHttp obj[F("error")] = F("not found"); response.setCode(404); } else { - state->applyState(obj, bulbId, settings.groupStateFields); + state->applyState(obj, bulbId, normalizedFormat ? NORMALIZED_GROUP_STATE_FIELDS : settings.groupStateFields); } } else { obj[F("success")] = true; @@ -955,4 +959,56 @@ void MiLightHttpServer::handleCreateBackup(RequestContext &request) { server.streamFile(backupFile, APPLICATION_OCTET_STREAM); ProjectFS.remove(BACKUP_FILE); -} \ No newline at end of file +} + + +void MiLightHttpServer::handleListGroups() { + this->stateStore->flush(); + + server.setContentLength(CONTENT_LENGTH_UNKNOWN); + server.send(200, "application/json"); + + StaticJsonDocument<1024> stateBuffer; + WiFiClient client = server.client(); + + // open array + server.sendContent("["); + + bool firstGroup = true; + for (auto & group : settings.groupIdAliases) { + stateBuffer.clear(); + + JsonObject device = stateBuffer.createNestedObject(F("device")); + + device[F("alias")] = group.first; + device[F("id")] = group.second.id; + device[F("device_id")] = group.second.bulbId.deviceId; + device[F("group_id")] = group.second.bulbId.groupId; + device[F("device_type")] = MiLightRemoteTypeHelpers::remoteTypeToString(group.second.bulbId.deviceType); + + GroupState* state = this->stateStore->get(group.second.bulbId); + JsonObject outputState = stateBuffer.createNestedObject(F("state")); + + if (state != nullptr) { + state->applyState(outputState, group.second.bulbId, NORMALIZED_GROUP_STATE_FIELDS); + } + + client.printf("%zx\r\n", measureJson(stateBuffer)+(firstGroup ? 0 : 1)); + + if (!firstGroup) { + client.print(','); + } + serializeJson(stateBuffer, client); + client.printf_P(PSTR("\r\n")); + + firstGroup = false; + yield(); + } + + // close array + server.sendContent("]"); + + // stop chunked streaming + server.sendContent(""); + server.client().stop(); +} diff --git a/lib/WebServer/MiLightHttpServer.h b/lib/WebServer/MiLightHttpServer.h index 5cedecda..9772dae7 100644 --- a/lib/WebServer/MiLightHttpServer.h +++ b/lib/WebServer/MiLightHttpServer.h @@ -22,6 +22,13 @@ using RequestContext = RichHttpConfig::RequestContextType; const char APPLICATION_OCTET_STREAM[] PROGMEM = "application/octet-stream"; const char TEXT_PLAIN[] PROGMEM = "text/plain"; const char APPLICATION_JSON[] = "application/json"; +const std::vector NORMALIZED_GROUP_STATE_FIELDS = { + GroupStateField::STATE, + GroupStateField::COLOR_MODE, + GroupStateField::LEVEL, + GroupStateField::COLOR, + GroupStateField::KELVIN, +}; static const uint8_t DEFAULT_PAGE_SIZE = 10; @@ -78,6 +85,7 @@ class MiLightHttpServer { void handleUpdateGroup(RequestContext& request); void handleUpdateGroupAlias(RequestContext& request); + void handleListGroups(); void handleGetGroup(RequestContext& request); void handleGetGroupAlias(RequestContext& request); void _handleGetGroup(bool allowAsync, BulbId bulbId, RequestContext& request); diff --git a/test/remote/spec/rest_spec.rb b/test/remote/spec/rest_spec.rb index b4a70bcb..8db5eeb8 100644 --- a/test/remote/spec/rest_spec.rb +++ b/test/remote/spec/rest_spec.rb @@ -407,4 +407,68 @@ expect { @client.upload_string_as_file('/backup', 'invalid') }.to raise_error(Net::HTTPServerException) end end + + context 'list gateways' do + before(:all) do + @id1 = { + id: @client.generate_id, + type: 'rgb_cct', + group_id: 1 + } + @id2 = { + id: @client.generate_id, + type: 'rgb_cct', + group_id: 1 + } + @alias1 = { + alias: "test_alias", + device_type: @id1[:type], + device_id: @id1[:id], + group_id: @id1[:group_id] + } + @alias2 = { + alias: "test_alias2", + device_type: @id2[:type], + device_id: @id2[:id], + group_id: @id2[:group_id] + } + + @client.delete('/aliases.bin') + @client.post('/aliases', @alias1) + @client.post('/aliases', @alias2) + + # set baseline states + @alias1_state = {status: "ON", level: 100, color_mode: "rgb", color: {r: 255, g: 0, b: 0}} + @alias2_state = {status: "ON", level: 100, color_mode: "color_temp", kelvin: 100} + + @client.delete_state(@id1) + @client.delete_state(@id2) + + @client.patch_state(@alias1_state, @id1) + @client.patch_state(@alias2_state, @id2) + end + + it 'should list all gateways' do + result = @client.get('/gateways') + expect(result).to be_a(Array) + expect(result.length).to eq(2) + + aliases = result.map { |r| r['device']['alias'] } + expect(aliases).to include(@alias1[:alias]) + expect(aliases).to include(@alias2[:alias]) + + alias1_state_response = result.find { |r| r['device']['alias'] == @alias1[:alias] }['state'] + alias2_state_response = result.find { |r| r['device']['alias'] == @alias2[:alias] }['state'] + + expect(alias1_state_response['state']).to eq(@alias1_state[:status]) + expect(alias1_state_response['level']).to eq(@alias1_state[:level]) + expect(alias1_state_response['color_mode']).to eq(@alias1_state[:color_mode]) + expect(alias1_state_response['color']).to eq(@alias1_state[:color].transform_keys(&:to_s)) + + expect(alias2_state_response['state']).to eq(@alias2_state[:status]) + expect(alias2_state_response['level']).to eq(@alias2_state[:level]) + expect(alias2_state_response['color_mode']).to eq(@alias2_state[:color_mode]) + expect(alias2_state_response['kelvin']).to eq(@alias2_state[:kelvin]) + end + end end \ No newline at end of file From 37d80c017bf5d9271ae7b3667c07e8de2aee43d4 Mon Sep 17 00:00:00 2001 From: Chris Mullins Date: Sat, 12 Oct 2024 11:32:34 -0700 Subject: [PATCH 02/48] Add first draft of new UI --- .gitignore | 2 + web2/api/.gitignore | 4 + web2/api/.npmignore | 1 + web2/api/.openapi-generator-ignore | 23 + web2/api/.openapi-generator/FILES | 8 + web2/api/.openapi-generator/VERSION | 1 + web2/api/api.ts | 3741 ++++++++++++ web2/api/base.ts | 86 + web2/api/common.ts | 150 + web2/api/configuration.ts | 110 + web2/api/git_push.sh | 57 + web2/api/index.ts | 18 + web2/build.mjs | 16 + web2/components.json | 17 + web2/components/confirmation-dialog.tsx | 67 + web2/components/light/light-card.tsx | 262 + web2/components/light/light-list.tsx | 234 + web2/components/light/light-status-icon.tsx | 32 + web2/components/light/new-light-form.tsx | 147 + web2/components/light/state.ts | 84 + web2/components/ui/button.tsx | 56 + web2/components/ui/card.tsx | 79 + web2/components/ui/dialog.tsx | 126 + web2/components/ui/form.tsx | 176 + web2/components/ui/input.tsx | 25 + web2/components/ui/label.tsx | 24 + web2/components/ui/link.tsx | 61 + web2/components/ui/main-nav.tsx | 31 + web2/components/ui/navigation-menu.tsx | 128 + web2/components/ui/select.tsx | 158 + web2/components/ui/slider.tsx | 35 + web2/components/ui/switch.tsx | 27 + web2/components/ui/toggle-group.tsx | 59 + web2/components/ui/toggle.tsx | 43 + web2/hooks/use-debounce-merge.ts | 34 + web2/hooks/use-rate-limit-merge.ts | 70 + web2/inline.js | 33 + web2/lib/api.ts | 11 + web2/lib/utils.ts | 6 + web2/openapitools.json | 7 + web2/package-lock.json | 5732 +++++++++++++++++++ web2/package.json | 57 + web2/postcss.config.js | 6 + web2/server.js | 22 + web2/src/globals.css | 69 + web2/src/index.css | 4 + web2/src/index.tsx | 48 + web2/src/pages/dashboard.tsx | 13 + web2/tailwind.config.js | 77 + web2/tsconfig.json | 114 + 50 files changed, 12391 insertions(+) create mode 100644 web2/api/.gitignore create mode 100644 web2/api/.npmignore create mode 100644 web2/api/.openapi-generator-ignore create mode 100644 web2/api/.openapi-generator/FILES create mode 100644 web2/api/.openapi-generator/VERSION create mode 100644 web2/api/api.ts create mode 100644 web2/api/base.ts create mode 100644 web2/api/common.ts create mode 100644 web2/api/configuration.ts create mode 100644 web2/api/git_push.sh create mode 100644 web2/api/index.ts create mode 100644 web2/build.mjs create mode 100644 web2/components.json create mode 100644 web2/components/confirmation-dialog.tsx create mode 100644 web2/components/light/light-card.tsx create mode 100644 web2/components/light/light-list.tsx create mode 100644 web2/components/light/light-status-icon.tsx create mode 100644 web2/components/light/new-light-form.tsx create mode 100644 web2/components/light/state.ts create mode 100644 web2/components/ui/button.tsx create mode 100644 web2/components/ui/card.tsx create mode 100644 web2/components/ui/dialog.tsx create mode 100644 web2/components/ui/form.tsx create mode 100644 web2/components/ui/input.tsx create mode 100644 web2/components/ui/label.tsx create mode 100644 web2/components/ui/link.tsx create mode 100644 web2/components/ui/main-nav.tsx create mode 100644 web2/components/ui/navigation-menu.tsx create mode 100644 web2/components/ui/select.tsx create mode 100644 web2/components/ui/slider.tsx create mode 100644 web2/components/ui/switch.tsx create mode 100644 web2/components/ui/toggle-group.tsx create mode 100644 web2/components/ui/toggle.tsx create mode 100644 web2/hooks/use-debounce-merge.ts create mode 100644 web2/hooks/use-rate-limit-merge.ts create mode 100644 web2/inline.js create mode 100644 web2/lib/api.ts create mode 100644 web2/lib/utils.ts create mode 100644 web2/openapitools.json create mode 100644 web2/package-lock.json create mode 100644 web2/package.json create mode 100644 web2/postcss.config.js create mode 100644 web2/server.js create mode 100644 web2/src/globals.css create mode 100644 web2/src/index.css create mode 100644 web2/src/index.tsx create mode 100644 web2/src/pages/dashboard.tsx create mode 100644 web2/tailwind.config.js create mode 100644 web2/tsconfig.json diff --git a/.gitignore b/.gitignore index 7343f694..59e51492 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ /web/package-lock.json /dist/*.bin /dist/docs +/web2/node_modules +/web2/dist .vscode/ .vscode/.browse.c_cpp.db* .vscode/c_cpp_properties.json diff --git a/web2/api/.gitignore b/web2/api/.gitignore new file mode 100644 index 00000000..149b5765 --- /dev/null +++ b/web2/api/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/web2/api/.npmignore b/web2/api/.npmignore new file mode 100644 index 00000000..999d88df --- /dev/null +++ b/web2/api/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/web2/api/.openapi-generator-ignore b/web2/api/.openapi-generator-ignore new file mode 100644 index 00000000..7484ee59 --- /dev/null +++ b/web2/api/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/web2/api/.openapi-generator/FILES b/web2/api/.openapi-generator/FILES new file mode 100644 index 00000000..a80cd4f0 --- /dev/null +++ b/web2/api/.openapi-generator/FILES @@ -0,0 +1,8 @@ +.gitignore +.npmignore +api.ts +base.ts +common.ts +configuration.ts +git_push.sh +index.ts diff --git a/web2/api/.openapi-generator/VERSION b/web2/api/.openapi-generator/VERSION new file mode 100644 index 00000000..09a6d308 --- /dev/null +++ b/web2/api/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0 diff --git a/web2/api/api.ts b/web2/api/api.ts new file mode 100644 index 00000000..a93b2ae9 --- /dev/null +++ b/web2/api/api.ts @@ -0,0 +1,3741 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * ESP8266 MiLight Hub + * Official documention for MiLight Hub\'s REST API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: chris@sidoh.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from './configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common'; +import type { RequestArgs } from './base'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base'; + +/** + * + * @export + * @interface About + */ +export interface About { + /** + * Always set to \"milight-hub\" + * @type {string} + * @memberof About + */ + 'firmware'?: string; + /** + * Semver version string + * @type {string} + * @memberof About + */ + 'version'?: string; + /** + * + * @type {string} + * @memberof About + */ + 'ip_address'?: string; + /** + * Reason the system was last rebooted + * @type {string} + * @memberof About + */ + 'reset_reason'?: string; + /** + * Firmware variant (e.g., d1_mini, nodemcuv2) + * @type {string} + * @memberof About + */ + 'variant'?: string; + /** + * Amount of free heap remaining (measured in bytes) + * @type {number} + * @memberof About + */ + 'free_heap'?: number; + /** + * Version of Arduino SDK firmware was built with + * @type {string} + * @memberof About + */ + 'arduino_version'?: string; + /** + * + * @type {AboutQueueStats} + * @memberof About + */ + 'queue_stats'?: AboutQueueStats; +} +/** + * + * @export + * @interface AboutQueueStats + */ +export interface AboutQueueStats { + /** + * Number of enqueued packets to be sent + * @type {number} + * @memberof AboutQueueStats + */ + 'length'?: number; + /** + * Number of packets that have been dropped since last reboot + * @type {number} + * @memberof AboutQueueStats + */ + 'dropped_packets'?: number; +} +/** + * + * @export + * @interface Alias + */ +export interface Alias { + /** + * + * @type {string} + * @memberof Alias + */ + 'alias': string; + /** + * + * @type {number} + * @memberof Alias + */ + 'id'?: number; + /** + * + * @type {number} + * @memberof Alias + */ + 'device_id': number; + /** + * + * @type {number} + * @memberof Alias + */ + 'group_id': number; + /** + * + * @type {RemoteType} + * @memberof Alias + */ + 'device_type': RemoteType; +} + + +/** + * + * @export + * @interface AliasesGet200Response + */ +export interface AliasesGet200Response { + /** + * + * @type {Array} + * @memberof AliasesGet200Response + */ + 'aliases'?: Array; + /** + * + * @type {number} + * @memberof AliasesGet200Response + */ + 'page'?: number; + /** + * + * @type {number} + * @memberof AliasesGet200Response + */ + 'count'?: number; + /** + * + * @type {number} + * @memberof AliasesGet200Response + */ + 'num_pages'?: number; +} +/** + * + * @export + * @interface AliasesPost201Response + */ +export interface AliasesPost201Response { + /** + * + * @type {number} + * @memberof AliasesPost201Response + */ + 'id'?: number; +} +/** + * + * @export + * @interface BooleanResponse + */ +export interface BooleanResponse { + /** + * + * @type {boolean} + * @memberof BooleanResponse + */ + 'success': boolean; + /** + * If an error occurred, message specifying what went wrong + * @type {string} + * @memberof BooleanResponse + */ + 'error'?: string; +} +/** + * + * @export + * @interface BulbId + */ +export interface BulbId { + /** + * + * @type {number} + * @memberof BulbId + */ + 'device_id': number; + /** + * + * @type {number} + * @memberof BulbId + */ + 'group_id': number; + /** + * + * @type {RemoteType} + * @memberof BulbId + */ + 'device_type': RemoteType; +} + + +/** + * Describes the current color mode of the bulb. Useful for HomeAssistant. + * @export + * @enum {string} + */ + +export const ColorMode = { + Brightness: 'brightness', + Rgb: 'rgb', + ColorTemp: 'color_temp', + Onoff: 'onoff' +} as const; + +export type ColorMode = typeof ColorMode[keyof typeof ColorMode]; + + +/** + * + * @export + * @interface GatewayListItem + */ +export interface GatewayListItem { + /** + * + * @type {NormalizedGroupState} + * @memberof GatewayListItem + */ + 'state': NormalizedGroupState; + /** + * + * @type {GatewayListItemDevice} + * @memberof GatewayListItem + */ + 'device': GatewayListItemDevice; +} +/** + * + * @export + * @interface GatewayListItemDevice + */ +export interface GatewayListItemDevice { + /** + * + * @type {number} + * @memberof GatewayListItemDevice + */ + 'id': number; + /** + * + * @type {number} + * @memberof GatewayListItemDevice + */ + 'device_id': number; + /** + * + * @type {RemoteType} + * @memberof GatewayListItemDevice + */ + 'device_type': RemoteType; + /** + * + * @type {number} + * @memberof GatewayListItemDevice + */ + 'group_id': number; + /** + * + * @type {string} + * @memberof GatewayListItemDevice + */ + 'alias': string; +} + + +/** + * @type GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter + * @export + */ +export type GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter = number | string; + +/** + * @type GatewaysDeviceIdRemoteTypeGroupIdPut200Response + * @export + */ +export type GatewaysDeviceIdRemoteTypeGroupIdPut200Response = BooleanResponse | GroupState | NormalizedGroupState; + +/** + * + * @export + * @interface GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ +export interface GatewaysDeviceIdRemoteTypeGroupIdPutRequest { + /** + * + * @type {State} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'state'?: State; + /** + * + * @type {State} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'status'?: State; + /** + * Color hue. Will change bulb to color mode. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'hue'?: number; + /** + * Color saturation. Will normally change bulb to color mode. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'saturation'?: number; + /** + * White temperature. 0 is coolest, 100 is warmest. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'kelvin'?: number; + /** + * Alias for `kelvin`. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'temperature'?: number; + /** + * White temperature measured in mireds. Lower values are cooler. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'color_temp'?: number; + /** + * Party mode ID. Actual effect depends on the bulb. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'mode'?: number; + /** + * + * @type {GroupStateColor} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'color'?: GroupStateColor; + /** + * Brightness on a 0-100 scale. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'level'?: number; + /** + * Brightness on a 0-255 scale. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'brightness'?: number; + /** + * + * @type {string} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'effect'?: GatewaysDeviceIdRemoteTypeGroupIdPutRequestEffectEnum; + /** + * Enables a transition from current state to the provided state. + * @type {number} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'transition'?: number; + /** + * + * @type {ColorMode} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'color_mode'?: ColorMode; + /** + * + * @type {GroupStateCommandsCommand} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'command'?: GroupStateCommandsCommand; + /** + * + * @type {Array} + * @memberof GatewaysDeviceIdRemoteTypeGroupIdPutRequest + */ + 'commands'?: Array; +} + +export const GatewaysDeviceIdRemoteTypeGroupIdPutRequestEffectEnum = { + NightMode: 'night_mode', + WhiteMode: 'white_mode' +} as const; + +export type GatewaysDeviceIdRemoteTypeGroupIdPutRequestEffectEnum = typeof GatewaysDeviceIdRemoteTypeGroupIdPutRequestEffectEnum[keyof typeof GatewaysDeviceIdRemoteTypeGroupIdPutRequestEffectEnum]; + +/** + * Group state + * @export + * @interface GroupState + */ +export interface GroupState { + /** + * + * @type {State} + * @memberof GroupState + */ + 'state'?: State; + /** + * + * @type {State} + * @memberof GroupState + */ + 'status'?: State; + /** + * Color hue. Will change bulb to color mode. + * @type {number} + * @memberof GroupState + */ + 'hue'?: number; + /** + * Color saturation. Will normally change bulb to color mode. + * @type {number} + * @memberof GroupState + */ + 'saturation'?: number; + /** + * White temperature. 0 is coolest, 100 is warmest. + * @type {number} + * @memberof GroupState + */ + 'kelvin'?: number; + /** + * Alias for `kelvin`. + * @type {number} + * @memberof GroupState + */ + 'temperature'?: number; + /** + * White temperature measured in mireds. Lower values are cooler. + * @type {number} + * @memberof GroupState + */ + 'color_temp'?: number; + /** + * Party mode ID. Actual effect depends on the bulb. + * @type {number} + * @memberof GroupState + */ + 'mode'?: number; + /** + * + * @type {GroupStateColor} + * @memberof GroupState + */ + 'color'?: GroupStateColor; + /** + * Brightness on a 0-100 scale. + * @type {number} + * @memberof GroupState + */ + 'level'?: number; + /** + * Brightness on a 0-255 scale. + * @type {number} + * @memberof GroupState + */ + 'brightness'?: number; + /** + * + * @type {string} + * @memberof GroupState + */ + 'effect'?: GroupStateEffectEnum; + /** + * Enables a transition from current state to the provided state. + * @type {number} + * @memberof GroupState + */ + 'transition'?: number; + /** + * + * @type {ColorMode} + * @memberof GroupState + */ + 'color_mode'?: ColorMode; +} + +export const GroupStateEffectEnum = { + NightMode: 'night_mode', + WhiteMode: 'white_mode' +} as const; + +export type GroupStateEffectEnum = typeof GroupStateEffectEnum[keyof typeof GroupStateEffectEnum]; + +/** + * @type GroupStateColor + * @export + */ +export type GroupStateColor = GroupStateColorOneOf | string; + +/** + * + * @export + * @interface GroupStateColorOneOf + */ +export interface GroupStateColorOneOf { + /** + * + * @type {number} + * @memberof GroupStateColorOneOf + */ + 'r'?: number; + /** + * + * @type {number} + * @memberof GroupStateColorOneOf + */ + 'g'?: number; + /** + * + * @type {number} + * @memberof GroupStateColorOneOf + */ + 'b'?: number; +} +/** + * Commands that affect a given group. Descriptiosn follow: * `pair`. Emulates the pairing process. Send this command right as you connect an unpaired bulb and it will pair with the device ID being used. * `unpair`. Emulates the unpairing process. Send as you connect a paired bulb to have it disassociate with the device ID being used. * `set_white`. Turns off RGB and enters WW/CW mode. * `night_mode`. Most devices support a \"night mode,\" which has LEDs turned to a very dim setting -- lower than brightness 0. * `level_up`. Turns down the brightness. Not all dimmable bulbs support this command. * `level_down`. Turns down the brightness. Not all dimmable bulbs support this command. * `temperature_up`. Turns up the white temperature. Not all bulbs with adjustable white temperature support this command. * `temperature_down`. Turns down the white temperature. Not all bulbs with adjustable white temperature support this command. * `next_mode`. Cycles to the next \"disco mode\". * `previous_mode`. Cycles to the previous disco mode. * `mode_speed_up`. Turn transition speed for current mode up. * `mode_speed_down`. Turn transition speed for current mode down. * `toggle`. Toggle on/off state. + * @export + * @enum {string} + */ + +export const GroupStateCommand = { + Unpair: 'unpair', + Pair: 'pair', + SetWhite: 'set_white', + NightMode: 'night_mode', + LevelUp: 'level_up', + LevelDown: 'level_down', + TemperatureUp: 'temperature_up', + TemperatureDown: 'temperature_down', + NextMode: 'next_mode', + PreviousMode: 'previous_mode', + ModeSpeedDown: 'mode_speed_down', + ModeSpeedUp: 'mode_speed_up', + Toggle: 'toggle' +} as const; + +export type GroupStateCommand = typeof GroupStateCommand[keyof typeof GroupStateCommand]; + + +/** + * + * @export + * @interface GroupStateCommands + */ +export interface GroupStateCommands { + /** + * + * @type {GroupStateCommandsCommand} + * @memberof GroupStateCommands + */ + 'command'?: GroupStateCommandsCommand; + /** + * + * @type {Array} + * @memberof GroupStateCommands + */ + 'commands'?: Array; +} +/** + * @type GroupStateCommandsCommand + * @export + */ +export type GroupStateCommandsCommand = GroupStateCommand | GroupStateCommandsCommandOneOf; + +/** + * + * @export + * @interface GroupStateCommandsCommandOneOf + */ +export interface GroupStateCommandsCommandOneOf { + /** + * + * @type {string} + * @memberof GroupStateCommandsCommandOneOf + */ + 'command'?: GroupStateCommandsCommandOneOfCommandEnum; + /** + * + * @type {TransitionArgs} + * @memberof GroupStateCommandsCommandOneOf + */ + 'args'?: TransitionArgs; +} + +export const GroupStateCommandsCommandOneOfCommandEnum = { + Transition: 'transition' +} as const; + +export type GroupStateCommandsCommandOneOfCommandEnum = typeof GroupStateCommandsCommandOneOfCommandEnum[keyof typeof GroupStateCommandsCommandOneOfCommandEnum]; + +/** + * Defines a field which is a part of state for a particular light device. Most fields are self-explanatory, but documentation for each follows: * `state` / `status` - same value with different keys (useful if your platform expects one or the other). * `brightness` / `level` - [0, 255] and [0, 100] scales of the same value. * `kelvin / color_temp` - [0, 100] and [153, 370] scales for the same value. The later\'s unit is mireds. * `bulb_mode` - what mode the bulb is in: white, rgb, etc. * `color` / `computed_color` - behaves the same when bulb is in rgb mode. `computed_color` will send RGB = 255,255,255 when in white mode. This is useful for HomeAssistant where it always expects the color to be set. * `oh_color` - same as `color` with a format compatible with [OpenHAB\'s colorRGB channel type](https://www.openhab.org/addons/bindings/mqtt.generic/#channel-type-colorrgb-colorhsb). * `hex_color` - same as `color` except in hex color (e.g., `#FF0000` for red). * `device_id` / `device_type` / `group_id` - this information is in the MQTT topic or REST route, but can be included in the payload in the case that processing the topic or route is more difficult. + * @export + * @enum {string} + */ + +export const GroupStateField = { + State: 'state', + Status: 'status', + Brightness: 'brightness', + Level: 'level', + Hue: 'hue', + Saturation: 'saturation', + Color: 'color', + Mode: 'mode', + Kelvin: 'kelvin', + ColorTemp: 'color_temp', + BulbMode: 'bulb_mode', + ComputedColor: 'computed_color', + Effect: 'effect', + DeviceId: 'device_id', + GroupId: 'group_id', + DeviceType: 'device_type', + OhColor: 'oh_color', + HexColor: 'hex_color' +} as const; + +export type GroupStateField = typeof GroupStateField[keyof typeof GroupStateField]; + + +/** + * + * @export + * @enum {string} + */ + +export const LedMode = { + False: 'false', + SlowToggle: 'Slow toggle', + FastToggle: 'Fast toggle', + SlowBlip: 'Slow blip', + FastBlip: 'Fast blip', + Flicker: 'Flicker', + True: 'true' +} as const; + +export type LedMode = typeof LedMode[keyof typeof LedMode]; + + +/** + * Group state with a static set of fields + * @export + * @interface NormalizedGroupState + */ +export interface NormalizedGroupState { + /** + * + * @type {string} + * @memberof NormalizedGroupState + */ + 'alias'?: string; + /** + * + * @type {State} + * @memberof NormalizedGroupState + */ + 'state'?: State; + /** + * + * @type {NormalizedGroupStateColor} + * @memberof NormalizedGroupState + */ + 'color'?: NormalizedGroupStateColor; + /** + * + * @type {number} + * @memberof NormalizedGroupState + */ + 'level'?: number; + /** + * + * @type {number} + * @memberof NormalizedGroupState + */ + 'kelvin'?: number; + /** + * + * @type {ColorMode} + * @memberof NormalizedGroupState + */ + 'color_mode'?: ColorMode; +} + + +/** + * + * @export + * @interface NormalizedGroupStateColor + */ +export interface NormalizedGroupStateColor { + /** + * + * @type {number} + * @memberof NormalizedGroupStateColor + */ + 'r': number; + /** + * + * @type {number} + * @memberof NormalizedGroupStateColor + */ + 'g': number; + /** + * + * @type {number} + * @memberof NormalizedGroupStateColor + */ + 'b': number; +} +/** + * + * @export + * @enum {string} + */ + +export const RF24Channel = { + Low: 'LOW', + Mid: 'MID', + High: 'HIGH' +} as const; + +export type RF24Channel = typeof RF24Channel[keyof typeof RF24Channel]; + + +/** + * + * @export + * @interface RawCommandsRemoteTypePostRequest + */ +export interface RawCommandsRemoteTypePostRequest { + /** + * Raw packet to send + * @type {string} + * @memberof RawCommandsRemoteTypePostRequest + */ + 'packet'?: string; + /** + * Number of repeated packets to send + * @type {number} + * @memberof RawCommandsRemoteTypePostRequest + */ + 'num_repeats'?: number; +} +/** + * + * @export + * @interface ReadPacket + */ +export interface ReadPacket { + /** + * + * @type {string} + * @memberof ReadPacket + */ + 'packet_info'?: string; +} +/** + * + * @export + * @enum {string} + */ + +export const RemoteType = { + Rgbw: 'rgbw', + Cct: 'cct', + RgbCct: 'rgb_cct', + Rgb: 'rgb', + Fut089: 'fut089', + Fut091: 'fut091', + Fut020: 'fut020' +} as const; + +export type RemoteType = typeof RemoteType[keyof typeof RemoteType]; + + +/** + * + * @export + * @interface Settings + */ +export interface Settings { + /** + * If spcified along with `admin_password`, HTTP basic auth will be enabled to access all REST endpoints. + * @type {string} + * @memberof Settings + */ + 'admin_username'?: string; + /** + * If spcified along with `admin_username`, HTTP basic auth will be enabled to access all REST endpoints. + * @type {string} + * @memberof Settings + */ + 'admin_password'?: string; + /** + * CE pin to use for SPI radio (nRF24, LT8900) + * @type {number} + * @memberof Settings + */ + 'ce_pin'?: number; + /** + * CSN pin to use with nRF24 + * @type {number} + * @memberof Settings + */ + 'csn_pin'?: number; + /** + * Reset pin to use with LT8900 + * @type {number} + * @memberof Settings + */ + 'reset_pin'?: number; + /** + * Pin to control for status LED. Set to a negative value to invert on/off status. + * @type {number} + * @memberof Settings + */ + 'led_pin'?: number; + /** + * Number of times to resend the same 2.4 GHz milight packet when a command is sent. + * @type {number} + * @memberof Settings + */ + 'packet_repeats'?: number; + /** + * Packet repeats resulting from REST commands will be multiplied by this number. + * @type {number} + * @memberof Settings + */ + 'http_repeat_factor'?: number; + /** + * Automatically restart the device after the number of specified minutes. Use 0 to disable. + * @type {number} + * @memberof Settings + */ + 'auto_restart_period'?: number; + /** + * MQTT server to connect to. + * @type {string} + * @memberof Settings + */ + 'mqtt_server'?: string; + /** + * If specified, use this username to authenticate with the MQTT server. + * @type {string} + * @memberof Settings + */ + 'mqtt_username'?: string; + /** + * If specified, use this password to authenticate with the MQTT server. + * @type {string} + * @memberof Settings + */ + 'mqtt_password'?: string; + /** + * Topic pattern to listen on for commands. More detail on the format in README. + * @type {string} + * @memberof Settings + */ + 'mqtt_topic_pattern'?: string; + /** + * Topic pattern individual intercepted commands will be sent to. More detail on the format in README. + * @type {string} + * @memberof Settings + */ + 'mqtt_update_topic_pattern'?: string; + /** + * Topic pattern device state will be sent to. More detail on the format in README. + * @type {string} + * @memberof Settings + */ + 'mqtt_update_state_pattern'?: string; + /** + * Topic client status will be sent to. + * @type {string} + * @memberof Settings + */ + 'mqtt_client_status_topic'?: string; + /** + * If true, will use a simple enum flag (`connected` or `disconnected`) to indicate status. If false, will send a rich JSON message including IP address, version, etc. + * @type {boolean} + * @memberof Settings + */ + 'simple_mqtt_client_status'?: boolean; + /** + * UDP discovery port + * @type {number} + * @memberof Settings + */ + 'discovery_port'?: number; + /** + * Controls how many cycles are spent listening for packets. Set to 0 to disable passive listening. + * @type {number} + * @memberof Settings + */ + 'listen_repeats'?: number; + /** + * Controls how many miliseconds must pass between states being flushed to persistent storage. Set to 0 to disable throttling. + * @type {number} + * @memberof Settings + */ + 'state_flush_interval'?: number; + /** + * Controls how many miliseconds must pass between MQTT state updates. Set to 0 to disable throttling. + * @type {number} + * @memberof Settings + */ + 'mqtt_state_rate_limit'?: number; + /** + * Controls how much time has to pass after the last status update was queued. + * @type {number} + * @memberof Settings + */ + 'mqtt_debounce_delay'?: number; + /** + * Controls how packet repeats are throttled. Packets sent with less time (measured in milliseconds) between them than this value (in milliseconds) will cause packet repeats to be throttled down. More than this value will unthrottle up. + * @type {number} + * @memberof Settings + */ + 'packet_repeat_throttle_threshold'?: number; + /** + * Controls how packet repeats are throttled. Higher values cause packets to be throttled up and down faster. Set to 0 to disable throttling. + * @type {number} + * @memberof Settings + */ + 'packet_repeat_throttle_sensitivity'?: number; + /** + * Controls how far throttling can decrease the number of repeated packets + * @type {number} + * @memberof Settings + */ + 'packet_repeat_minimum'?: number; + /** + * When making updates to hue or white temperature in a different bulb mode, switch back to the original bulb mode after applying the setting change. + * @type {boolean} + * @memberof Settings + */ + 'enable_automatic_mode_switching'?: boolean; + /** + * + * @type {LedMode} + * @memberof Settings + */ + 'led_mode_wifi_config'?: LedMode; + /** + * + * @type {LedMode} + * @memberof Settings + */ + 'led_mode_wifi_failed'?: LedMode; + /** + * + * @type {LedMode} + * @memberof Settings + */ + 'led_mode_operating'?: LedMode; + /** + * + * @type {LedMode} + * @memberof Settings + */ + 'led_mode_packet'?: LedMode; + /** + * Number of times the LED will flash when packets are changing + * @type {number} + * @memberof Settings + */ + 'led_mode_packet_count'?: number; + /** + * Hostname that will be advertized on a DHCP request + * @type {string} + * @memberof Settings + */ + 'hostname'?: string; + /** + * Power level used when packets are sent. See nRF24 documentation for further detail. + * @type {string} + * @memberof Settings + */ + 'rf24_power_level'?: SettingsRf24PowerLevelEnum; + /** + * + * @type {RF24Channel} + * @memberof Settings + */ + 'rf24_listen_channel'?: RF24Channel; + /** + * If specified, the static IP address to use + * @type {string} + * @memberof Settings + */ + 'wifi_static_ip'?: string; + /** + * If specified along with static IP, the gateway address to use + * @type {string} + * @memberof Settings + */ + 'wifi_static_ip_gateway'?: string; + /** + * If specified along with static IP, the netmask to use + * @type {string} + * @memberof Settings + */ + 'wifi_static_ip_netmask'?: string; + /** + * Packets are sent asynchronously. This number controls the number of repeats sent during each iteration. Increase this number to improve packet throughput. Decrease to improve system multi-tasking. + * @type {number} + * @memberof Settings + */ + 'packet_repeats_per_loop'?: number; + /** + * If specified along with MQTT settings, will enable HomeAssistant MQTT discovery using the specified discovery prefix. HomeAssistant\'s default is `homeassistant/`. + * @type {string} + * @memberof Settings + */ + 'home_assistant_discovery_prefix'?: string; + /** + * Forces WiFi into the spcified mode. Try using B or G mode if you are having stability issues. + * @type {string} + * @memberof Settings + */ + 'wifi_mode'?: SettingsWifiModeEnum; + /** + * Defines which channels we send on. Each remote type has three channels. We can send on any subset of these. + * @type {Array} + * @memberof Settings + */ + 'rf24_channels'?: Array; + /** + * List of saved device IDs, stored as 3-long arrays. Elements are: 1) remote ID, 2) remote type, 3) group ID + * @type {Array>} + * @memberof Settings + */ + 'device_ids'?: Array>; + /** + * List of UDP servers, stored as 3-long arrays. Elements are 1) remote ID to bind to, 2) UDP port to listen on, 3) protocol version (5 or 6) + * @type {Array} + * @memberof Settings + */ + 'gateway_configs'?: Array; + /** + * + * @type {Array} + * @memberof Settings + */ + 'group_state_fields'?: Array; + /** + * DEPRECATED (use /aliases routes instead) Keys are aliases, values are 3-long arrays with same schema as items in `device_ids`. + * @type {object} + * @memberof Settings + * @deprecated + */ + 'group_id_aliases'?: object; + /** + * Default number of milliseconds between transition packets. Set this value lower for more granular transitions, or higher if you are having performance issues during transitions. + * @type {number} + * @memberof Settings + */ + 'default_transition_period'?: number; +} + +export const SettingsRf24PowerLevelEnum = { + Min: 'MIN', + Low: 'LOW', + High: 'HIGH', + Max: 'MAX' +} as const; + +export type SettingsRf24PowerLevelEnum = typeof SettingsRf24PowerLevelEnum[keyof typeof SettingsRf24PowerLevelEnum]; +export const SettingsWifiModeEnum = { + B: 'B', + G: 'G', + N: 'N' +} as const; + +export type SettingsWifiModeEnum = typeof SettingsWifiModeEnum[keyof typeof SettingsWifiModeEnum]; + +/** + * On/Off state + * @export + * @enum {string} + */ + +export const State = { + On: 'ON', + Off: 'OFF' +} as const; + +export type State = typeof State[keyof typeof State]; + + +/** + * + * @export + * @interface SystemPostRequest + */ +export interface SystemPostRequest { + /** + * + * @type {string} + * @memberof SystemPostRequest + */ + 'command': SystemPostRequestCommandEnum; +} + +export const SystemPostRequestCommandEnum = { + Restart: 'restart', + ClearWifiConfig: 'clear_wifi_config' +} as const; + +export type SystemPostRequestCommandEnum = typeof SystemPostRequestCommandEnum[keyof typeof SystemPostRequestCommandEnum]; + +/** + * + * @export + * @interface TransitionArgs + */ +export interface TransitionArgs { + /** + * + * @type {TransitionField} + * @memberof TransitionArgs + */ + 'field'?: TransitionField; + /** + * + * @type {TransitionValue} + * @memberof TransitionArgs + */ + 'start_value'?: TransitionValue; + /** + * + * @type {TransitionValue} + * @memberof TransitionArgs + */ + 'end_value'?: TransitionValue; + /** + * Duration of transition, measured in seconds + * @type {number} + * @memberof TransitionArgs + */ + 'duration'?: number; + /** + * Length of time between updates in a transition, measured in milliseconds + * @type {number} + * @memberof TransitionArgs + */ + 'period'?: number; +} + + +/** + * + * @export + * @interface TransitionData + */ +export interface TransitionData { + /** + * + * @type {TransitionField} + * @memberof TransitionData + */ + 'field'?: TransitionField; + /** + * + * @type {TransitionValue} + * @memberof TransitionData + */ + 'start_value'?: TransitionValue; + /** + * + * @type {TransitionValue} + * @memberof TransitionData + */ + 'end_value'?: TransitionValue; + /** + * Duration of transition, measured in seconds + * @type {number} + * @memberof TransitionData + */ + 'duration'?: number; + /** + * Length of time between updates in a transition, measured in milliseconds + * @type {number} + * @memberof TransitionData + */ + 'period'?: number; + /** + * + * @type {number} + * @memberof TransitionData + */ + 'id'?: number; + /** + * Timestamp since last update was sent. + * @type {number} + * @memberof TransitionData + */ + 'last_sent'?: number; + /** + * + * @type {BulbId} + * @memberof TransitionData + */ + 'bulb'?: BulbId; + /** + * Specifies whether this is a simple field transition, or a color transition. + * @type {string} + * @memberof TransitionData + */ + 'type'?: TransitionDataTypeEnum; + /** + * + * @type {TransitionValue} + * @memberof TransitionData + */ + 'current_value'?: TransitionValue; +} + +export const TransitionDataTypeEnum = { + Field: 'field', + Color: 'color' +} as const; + +export type TransitionDataTypeEnum = typeof TransitionDataTypeEnum[keyof typeof TransitionDataTypeEnum]; + +/** + * If transitioning `status`: * If transitioning to `OFF`, will fade to 0 brightness and then turn off. * If transitioning to `ON`, will turn on, set brightness to 0, and fade to brightness 100. + * @export + * @enum {string} + */ + +export const TransitionField = { + Hue: 'hue', + Saturation: 'saturation', + Brightness: 'brightness', + Level: 'level', + Kelvin: 'kelvin', + ColorTemp: 'color_temp', + Color: 'color', + Status: 'status' +} as const; + +export type TransitionField = typeof TransitionField[keyof typeof TransitionField]; + + +/** + * @type TransitionValue + * Either an int value or a color + * @export + */ +export type TransitionValue = number | string; + +/** + * + * @export + * @interface TransitionsPostRequest + */ +export interface TransitionsPostRequest { + /** + * + * @type {TransitionField} + * @memberof TransitionsPostRequest + */ + 'field'?: TransitionField; + /** + * + * @type {TransitionValue} + * @memberof TransitionsPostRequest + */ + 'start_value'?: TransitionValue; + /** + * + * @type {TransitionValue} + * @memberof TransitionsPostRequest + */ + 'end_value'?: TransitionValue; + /** + * Duration of transition, measured in seconds + * @type {number} + * @memberof TransitionsPostRequest + */ + 'duration'?: number; + /** + * Length of time between updates in a transition, measured in milliseconds + * @type {number} + * @memberof TransitionsPostRequest + */ + 'period'?: number; + /** + * + * @type {number} + * @memberof TransitionsPostRequest + */ + 'id'?: number; + /** + * Timestamp since last update was sent. + * @type {number} + * @memberof TransitionsPostRequest + */ + 'last_sent'?: number; + /** + * + * @type {BulbId} + * @memberof TransitionsPostRequest + */ + 'bulb'?: BulbId; + /** + * Specifies whether this is a simple field transition, or a color transition. + * @type {string} + * @memberof TransitionsPostRequest + */ + 'type'?: TransitionsPostRequestTypeEnum; + /** + * + * @type {TransitionValue} + * @memberof TransitionsPostRequest + */ + 'current_value'?: TransitionValue; + /** + * + * @type {number} + * @memberof TransitionsPostRequest + */ + 'device_id': number; + /** + * + * @type {number} + * @memberof TransitionsPostRequest + */ + 'group_id': number; + /** + * + * @type {RemoteType} + * @memberof TransitionsPostRequest + */ + 'device_type': RemoteType; +} + +export const TransitionsPostRequestTypeEnum = { + Field: 'field', + Color: 'color' +} as const; + +export type TransitionsPostRequestTypeEnum = typeof TransitionsPostRequestTypeEnum[keyof typeof TransitionsPostRequestTypeEnum]; + + +/** + * AliasesApi - axios parameter creator + * @export + */ +export const AliasesApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Download a backup of all aliases in a binary format + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesBinGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/aliases.bin`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Upload a backup of all aliases in CSV format + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesBinPost: async (file?: File, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/aliases.bin`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); + + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Get all aliases + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/aliases`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Delete an alias by ID + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesIdDelete: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('aliasesIdDelete', 'id', id) + const localVarPath = `/aliases/{id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Update an alias by ID + * @param {number} id + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesIdPut: async (id: number, alias: Alias, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('aliasesIdPut', 'id', id) + // verify required parameter 'alias' is not null or undefined + assertParamExists('aliasesIdPut', 'alias', alias) + const localVarPath = `/aliases/{id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(alias, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Create a new alias + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesPost: async (alias: Alias, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'alias' is not null or undefined + assertParamExists('aliasesPost', 'alias', alias) + const localVarPath = `/aliases`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(alias, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * AliasesApi - functional programming interface + * @export + */ +export const AliasesApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = AliasesApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Download a backup of all aliases in a binary format + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aliasesBinGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aliasesBinGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AliasesApi.aliasesBinGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Upload a backup of all aliases in CSV format + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aliasesBinPost(file?: File, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aliasesBinPost(file, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AliasesApi.aliasesBinPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Get all aliases + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aliasesGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aliasesGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AliasesApi.aliasesGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Delete an alias by ID + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aliasesIdDelete(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aliasesIdDelete(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AliasesApi.aliasesIdDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Update an alias by ID + * @param {number} id + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aliasesIdPut(id: number, alias: Alias, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aliasesIdPut(id, alias, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AliasesApi.aliasesIdPut']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Create a new alias + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aliasesPost(alias: Alias, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aliasesPost(alias, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['AliasesApi.aliasesPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * AliasesApi - factory interface + * @export + */ +export const AliasesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = AliasesApiFp(configuration) + return { + /** + * + * @summary Download a backup of all aliases in a binary format + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesBinGet(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aliasesBinGet(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Upload a backup of all aliases in CSV format + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesBinPost(file?: File, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aliasesBinPost(file, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Get all aliases + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesGet(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aliasesGet(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Delete an alias by ID + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesIdDelete(id: number, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aliasesIdDelete(id, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Update an alias by ID + * @param {number} id + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesIdPut(id: number, alias: Alias, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aliasesIdPut(id, alias, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Create a new alias + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aliasesPost(alias: Alias, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aliasesPost(alias, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * AliasesApi - object-oriented interface + * @export + * @class AliasesApi + * @extends {BaseAPI} + */ +export class AliasesApi extends BaseAPI { + /** + * + * @summary Download a backup of all aliases in a binary format + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AliasesApi + */ + public aliasesBinGet(options?: RawAxiosRequestConfig) { + return AliasesApiFp(this.configuration).aliasesBinGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Upload a backup of all aliases in CSV format + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AliasesApi + */ + public aliasesBinPost(file?: File, options?: RawAxiosRequestConfig) { + return AliasesApiFp(this.configuration).aliasesBinPost(file, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Get all aliases + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AliasesApi + */ + public aliasesGet(options?: RawAxiosRequestConfig) { + return AliasesApiFp(this.configuration).aliasesGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Delete an alias by ID + * @param {number} id + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AliasesApi + */ + public aliasesIdDelete(id: number, options?: RawAxiosRequestConfig) { + return AliasesApiFp(this.configuration).aliasesIdDelete(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Update an alias by ID + * @param {number} id + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AliasesApi + */ + public aliasesIdPut(id: number, alias: Alias, options?: RawAxiosRequestConfig) { + return AliasesApiFp(this.configuration).aliasesIdPut(id, alias, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Create a new alias + * @param {Alias} alias + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof AliasesApi + */ + public aliasesPost(alias: Alias, options?: RawAxiosRequestConfig) { + return AliasesApiFp(this.configuration).aliasesPost(alias, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * DeviceControlApi - axios parameter creator + * @export + */ +export const DeviceControlApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceIdRemoteTypeGroupIdDelete: async (deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'deviceId' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdDelete', 'deviceId', deviceId) + // verify required parameter 'remoteType' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdDelete', 'remoteType', remoteType) + // verify required parameter 'groupId' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdDelete', 'groupId', groupId) + const localVarPath = `/gateways/{device-id}/{remote-type}/{group-id}` + .replace(`{${"device-id"}}`, encodeURIComponent(String(deviceId))) + .replace(`{${"remote-type"}}`, encodeURIComponent(String(remoteType))) + .replace(`{${"group-id"}}`, encodeURIComponent(String(groupId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * If `blockOnQueue` is provided, a response will not be returned until any unprocessed packets in the command queue are finished sending. + * @summary Get device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceIdRemoteTypeGroupIdGet: async (deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'deviceId' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdGet', 'deviceId', deviceId) + // verify required parameter 'remoteType' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdGet', 'remoteType', remoteType) + // verify required parameter 'groupId' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdGet', 'groupId', groupId) + const localVarPath = `/gateways/{device-id}/{remote-type}/{group-id}` + .replace(`{${"device-id"}}`, encodeURIComponent(String(deviceId))) + .replace(`{${"remote-type"}}`, encodeURIComponent(String(remoteType))) + .replace(`{${"group-id"}}`, encodeURIComponent(String(groupId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (blockOnQueue !== undefined) { + localVarQueryParameter['blockOnQueue'] = blockOnQueue; + } + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Update state of the bulbs with the provided parameters. Existing parameters will be unchanged. if `blockOnQueue` is set to true, the response will not return until packets corresponding to the commands sent are processed, and the updated `GroupState` will be returned. If `blockOnQueue` is false or not provided, a simple response indicating success will be returned. if `fmt` is set to `normalized`, the response will be in normalized format. + * @summary Patch device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceIdRemoteTypeGroupIdPut: async (deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, fmt?: GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'deviceId' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdPut', 'deviceId', deviceId) + // verify required parameter 'remoteType' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdPut', 'remoteType', remoteType) + // verify required parameter 'groupId' is not null or undefined + assertParamExists('gatewaysDeviceIdRemoteTypeGroupIdPut', 'groupId', groupId) + const localVarPath = `/gateways/{device-id}/{remote-type}/{group-id}` + .replace(`{${"device-id"}}`, encodeURIComponent(String(deviceId))) + .replace(`{${"remote-type"}}`, encodeURIComponent(String(remoteType))) + .replace(`{${"group-id"}}`, encodeURIComponent(String(groupId))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (blockOnQueue !== undefined) { + localVarQueryParameter['blockOnQueue'] = blockOnQueue; + } + + if (fmt !== undefined) { + localVarQueryParameter['fmt'] = fmt; + } + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(gatewaysDeviceIdRemoteTypeGroupIdPutRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Download a dump of all aliases and their current states + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/gateways`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DeviceControlApi - functional programming interface + * @export + */ +export const DeviceControlApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = DeviceControlApiAxiosParamCreator(configuration) + return { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysDeviceIdRemoteTypeGroupIdDelete(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysDeviceIdRemoteTypeGroupIdDelete(deviceId, remoteType, groupId, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlApi.gatewaysDeviceIdRemoteTypeGroupIdDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * If `blockOnQueue` is provided, a response will not be returned until any unprocessed packets in the command queue are finished sending. + * @summary Get device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysDeviceIdRemoteTypeGroupIdGet(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysDeviceIdRemoteTypeGroupIdGet(deviceId, remoteType, groupId, blockOnQueue, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlApi.gatewaysDeviceIdRemoteTypeGroupIdGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Update state of the bulbs with the provided parameters. Existing parameters will be unchanged. if `blockOnQueue` is set to true, the response will not return until packets corresponding to the commands sent are processed, and the updated `GroupState` will be returned. If `blockOnQueue` is false or not provided, a simple response indicating success will be returned. if `fmt` is set to `normalized`, the response will be in normalized format. + * @summary Patch device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysDeviceIdRemoteTypeGroupIdPut(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, fmt?: GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysDeviceIdRemoteTypeGroupIdPut(deviceId, remoteType, groupId, blockOnQueue, fmt, gatewaysDeviceIdRemoteTypeGroupIdPutRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlApi.gatewaysDeviceIdRemoteTypeGroupIdPut']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Download a dump of all aliases and their current states + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlApi.gatewaysGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * DeviceControlApi - factory interface + * @export + */ +export const DeviceControlApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = DeviceControlApiFp(configuration) + return { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceIdRemoteTypeGroupIdDelete(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewaysDeviceIdRemoteTypeGroupIdDelete(deviceId, remoteType, groupId, options).then((request) => request(axios, basePath)); + }, + /** + * If `blockOnQueue` is provided, a response will not be returned until any unprocessed packets in the command queue are finished sending. + * @summary Get device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceIdRemoteTypeGroupIdGet(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewaysDeviceIdRemoteTypeGroupIdGet(deviceId, remoteType, groupId, blockOnQueue, options).then((request) => request(axios, basePath)); + }, + /** + * Update state of the bulbs with the provided parameters. Existing parameters will be unchanged. if `blockOnQueue` is set to true, the response will not return until packets corresponding to the commands sent are processed, and the updated `GroupState` will be returned. If `blockOnQueue` is false or not provided, a simple response indicating success will be returned. if `fmt` is set to `normalized`, the response will be in normalized format. + * @summary Patch device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceIdRemoteTypeGroupIdPut(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, fmt?: GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewaysDeviceIdRemoteTypeGroupIdPut(deviceId, remoteType, groupId, blockOnQueue, fmt, gatewaysDeviceIdRemoteTypeGroupIdPutRequest, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Download a dump of all aliases and their current states + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysGet(options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.gatewaysGet(options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DeviceControlApi - object-oriented interface + * @export + * @class DeviceControlApi + * @extends {BaseAPI} + */ +export class DeviceControlApi extends BaseAPI { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlApi + */ + public gatewaysDeviceIdRemoteTypeGroupIdDelete(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, options?: RawAxiosRequestConfig) { + return DeviceControlApiFp(this.configuration).gatewaysDeviceIdRemoteTypeGroupIdDelete(deviceId, remoteType, groupId, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * If `blockOnQueue` is provided, a response will not be returned until any unprocessed packets in the command queue are finished sending. + * @summary Get device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlApi + */ + public gatewaysDeviceIdRemoteTypeGroupIdGet(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, options?: RawAxiosRequestConfig) { + return DeviceControlApiFp(this.configuration).gatewaysDeviceIdRemoteTypeGroupIdGet(deviceId, remoteType, groupId, blockOnQueue, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Update state of the bulbs with the provided parameters. Existing parameters will be unchanged. if `blockOnQueue` is set to true, the response will not return until packets corresponding to the commands sent are processed, and the updated `GroupState` will be returned. If `blockOnQueue` is false or not provided, a simple response indicating success will be returned. if `fmt` is set to `normalized`, the response will be in normalized format. + * @summary Patch device state + * @param {GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter} deviceId 2-byte device ID. Can be decimal or hexadecimal. + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {number} groupId Group ID. Should be 0-8, depending on remote type. Group 0 is a \"wildcard\" group. All bulbs paired with the same device ID will respond to commands sent to Group 0. + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlApi + */ + public gatewaysDeviceIdRemoteTypeGroupIdPut(deviceId: GatewaysDeviceIdRemoteTypeGroupIdGetDeviceIdParameter, remoteType: RemoteType, groupId: number, blockOnQueue?: boolean, fmt?: GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options?: RawAxiosRequestConfig) { + return DeviceControlApiFp(this.configuration).gatewaysDeviceIdRemoteTypeGroupIdPut(deviceId, remoteType, groupId, blockOnQueue, fmt, gatewaysDeviceIdRemoteTypeGroupIdPutRequest, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Download a dump of all aliases and their current states + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlApi + */ + public gatewaysGet(options?: RawAxiosRequestConfig) { + return DeviceControlApiFp(this.configuration).gatewaysGet(options).then((request) => request(this.axios, this.basePath)); + } +} + +/** + * @export + */ +export const GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum = { + Normalized: 'normalized' +} as const; +export type GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum = typeof GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum[keyof typeof GatewaysDeviceIdRemoteTypeGroupIdPutFmtEnum]; + + +/** + * DeviceControlByAliasApi - axios parameter creator + * @export + */ +export const DeviceControlByAliasApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state for alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceAliasDelete: async (deviceAlias: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'deviceAlias' is not null or undefined + assertParamExists('gatewaysDeviceAliasDelete', 'deviceAlias', deviceAlias) + const localVarPath = `/gateways/{device-alias}` + .replace(`{${"device-alias"}}`, encodeURIComponent(String(deviceAlias))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Get device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceAliasGet: async (deviceAlias: string, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'deviceAlias' is not null or undefined + assertParamExists('gatewaysDeviceAliasGet', 'deviceAlias', deviceAlias) + const localVarPath = `/gateways/{device-alias}` + .replace(`{${"device-alias"}}`, encodeURIComponent(String(deviceAlias))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Patch device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceAliasPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceAliasPut: async (deviceAlias: string, blockOnQueue?: boolean, fmt?: GatewaysDeviceAliasPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'deviceAlias' is not null or undefined + assertParamExists('gatewaysDeviceAliasPut', 'deviceAlias', deviceAlias) + const localVarPath = `/gateways/{device-alias}` + .replace(`{${"device-alias"}}`, encodeURIComponent(String(deviceAlias))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (blockOnQueue !== undefined) { + localVarQueryParameter['blockOnQueue'] = blockOnQueue; + } + + if (fmt !== undefined) { + localVarQueryParameter['fmt'] = fmt; + } + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(gatewaysDeviceIdRemoteTypeGroupIdPutRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DeviceControlByAliasApi - functional programming interface + * @export + */ +export const DeviceControlByAliasApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = DeviceControlByAliasApiAxiosParamCreator(configuration) + return { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state for alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysDeviceAliasDelete(deviceAlias: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysDeviceAliasDelete(deviceAlias, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlByAliasApi.gatewaysDeviceAliasDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Get device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysDeviceAliasGet(deviceAlias: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysDeviceAliasGet(deviceAlias, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlByAliasApi.gatewaysDeviceAliasGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Patch device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceAliasPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewaysDeviceAliasPut(deviceAlias: string, blockOnQueue?: boolean, fmt?: GatewaysDeviceAliasPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewaysDeviceAliasPut(deviceAlias, blockOnQueue, fmt, gatewaysDeviceIdRemoteTypeGroupIdPutRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DeviceControlByAliasApi.gatewaysDeviceAliasPut']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * DeviceControlByAliasApi - factory interface + * @export + */ +export const DeviceControlByAliasApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = DeviceControlByAliasApiFp(configuration) + return { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state for alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceAliasDelete(deviceAlias: string, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewaysDeviceAliasDelete(deviceAlias, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Get device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceAliasGet(deviceAlias: string, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewaysDeviceAliasGet(deviceAlias, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Patch device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceAliasPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewaysDeviceAliasPut(deviceAlias: string, blockOnQueue?: boolean, fmt?: GatewaysDeviceAliasPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewaysDeviceAliasPut(deviceAlias, blockOnQueue, fmt, gatewaysDeviceIdRemoteTypeGroupIdPutRequest, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DeviceControlByAliasApi - object-oriented interface + * @export + * @class DeviceControlByAliasApi + * @extends {BaseAPI} + */ +export class DeviceControlByAliasApi extends BaseAPI { + /** + * Usets all known values for state fields for the corresponding device. If MQTT is configured, the retained state message corresponding to this device will also be deleted. + * @summary Delete kept state for alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlByAliasApi + */ + public gatewaysDeviceAliasDelete(deviceAlias: string, options?: RawAxiosRequestConfig) { + return DeviceControlByAliasApiFp(this.configuration).gatewaysDeviceAliasDelete(deviceAlias, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Get device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlByAliasApi + */ + public gatewaysDeviceAliasGet(deviceAlias: string, options?: RawAxiosRequestConfig) { + return DeviceControlByAliasApiFp(this.configuration).gatewaysDeviceAliasGet(deviceAlias, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Patch device state by alias + * @param {string} deviceAlias Device alias saved in settings + * @param {boolean} [blockOnQueue] If true, response will block on update packets being sent before returning + * @param {GatewaysDeviceAliasPutFmtEnum} [fmt] If set to `normalized`, the response will be in normalized format. + * @param {GatewaysDeviceIdRemoteTypeGroupIdPutRequest} [gatewaysDeviceIdRemoteTypeGroupIdPutRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DeviceControlByAliasApi + */ + public gatewaysDeviceAliasPut(deviceAlias: string, blockOnQueue?: boolean, fmt?: GatewaysDeviceAliasPutFmtEnum, gatewaysDeviceIdRemoteTypeGroupIdPutRequest?: GatewaysDeviceIdRemoteTypeGroupIdPutRequest, options?: RawAxiosRequestConfig) { + return DeviceControlByAliasApiFp(this.configuration).gatewaysDeviceAliasPut(deviceAlias, blockOnQueue, fmt, gatewaysDeviceIdRemoteTypeGroupIdPutRequest, options).then((request) => request(this.axios, this.basePath)); + } +} + +/** + * @export + */ +export const GatewaysDeviceAliasPutFmtEnum = { + Normalized: 'normalized' +} as const; +export type GatewaysDeviceAliasPutFmtEnum = typeof GatewaysDeviceAliasPutFmtEnum[keyof typeof GatewaysDeviceAliasPutFmtEnum]; + + +/** + * RawPacketHandlingApi - axios parameter creator + * @export + */ +export const RawPacketHandlingApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Read a packet from any remote type. Does not return a response until a packet is read. + * @summary Read a packet from any remote + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewayTrafficGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/gateway_traffic`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Read a packet from the given remote type. Does not return a response until a packet is read. If `remote-type` is unspecified, will read from all remote types simultaneously. + * @summary Read a packet from a specific remote + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewayTrafficRemoteTypeGet: async (remoteType: RemoteType, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'remoteType' is not null or undefined + assertParamExists('gatewayTrafficRemoteTypeGet', 'remoteType', remoteType) + const localVarPath = `/gateway_traffic/{remote-type}` + .replace(`{${"remote-type"}}`, encodeURIComponent(String(remoteType))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Send a raw packet + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {RawCommandsRemoteTypePostRequest} [rawCommandsRemoteTypePostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + rawCommandsRemoteTypePost: async (remoteType: RemoteType, rawCommandsRemoteTypePostRequest?: RawCommandsRemoteTypePostRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'remoteType' is not null or undefined + assertParamExists('rawCommandsRemoteTypePost', 'remoteType', remoteType) + const localVarPath = `/raw_commands/{remote-type}` + .replace(`{${"remote-type"}}`, encodeURIComponent(String(remoteType))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(rawCommandsRemoteTypePostRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * RawPacketHandlingApi - functional programming interface + * @export + */ +export const RawPacketHandlingApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = RawPacketHandlingApiAxiosParamCreator(configuration) + return { + /** + * Read a packet from any remote type. Does not return a response until a packet is read. + * @summary Read a packet from any remote + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewayTrafficGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewayTrafficGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['RawPacketHandlingApi.gatewayTrafficGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Read a packet from the given remote type. Does not return a response until a packet is read. If `remote-type` is unspecified, will read from all remote types simultaneously. + * @summary Read a packet from a specific remote + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async gatewayTrafficRemoteTypeGet(remoteType: RemoteType, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.gatewayTrafficRemoteTypeGet(remoteType, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['RawPacketHandlingApi.gatewayTrafficRemoteTypeGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Send a raw packet + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {RawCommandsRemoteTypePostRequest} [rawCommandsRemoteTypePostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async rawCommandsRemoteTypePost(remoteType: RemoteType, rawCommandsRemoteTypePostRequest?: RawCommandsRemoteTypePostRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.rawCommandsRemoteTypePost(remoteType, rawCommandsRemoteTypePostRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['RawPacketHandlingApi.rawCommandsRemoteTypePost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * RawPacketHandlingApi - factory interface + * @export + */ +export const RawPacketHandlingApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = RawPacketHandlingApiFp(configuration) + return { + /** + * Read a packet from any remote type. Does not return a response until a packet is read. + * @summary Read a packet from any remote + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewayTrafficGet(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewayTrafficGet(options).then((request) => request(axios, basePath)); + }, + /** + * Read a packet from the given remote type. Does not return a response until a packet is read. If `remote-type` is unspecified, will read from all remote types simultaneously. + * @summary Read a packet from a specific remote + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + gatewayTrafficRemoteTypeGet(remoteType: RemoteType, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.gatewayTrafficRemoteTypeGet(remoteType, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Send a raw packet + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {RawCommandsRemoteTypePostRequest} [rawCommandsRemoteTypePostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + rawCommandsRemoteTypePost(remoteType: RemoteType, rawCommandsRemoteTypePostRequest?: RawCommandsRemoteTypePostRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.rawCommandsRemoteTypePost(remoteType, rawCommandsRemoteTypePostRequest, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * RawPacketHandlingApi - object-oriented interface + * @export + * @class RawPacketHandlingApi + * @extends {BaseAPI} + */ +export class RawPacketHandlingApi extends BaseAPI { + /** + * Read a packet from any remote type. Does not return a response until a packet is read. + * @summary Read a packet from any remote + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof RawPacketHandlingApi + */ + public gatewayTrafficGet(options?: RawAxiosRequestConfig) { + return RawPacketHandlingApiFp(this.configuration).gatewayTrafficGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Read a packet from the given remote type. Does not return a response until a packet is read. If `remote-type` is unspecified, will read from all remote types simultaneously. + * @summary Read a packet from a specific remote + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof RawPacketHandlingApi + */ + public gatewayTrafficRemoteTypeGet(remoteType: RemoteType, options?: RawAxiosRequestConfig) { + return RawPacketHandlingApiFp(this.configuration).gatewayTrafficRemoteTypeGet(remoteType, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Send a raw packet + * @param {RemoteType} remoteType Type of remote to read a packet from. If unspecified, will read packets from all remote types. + * @param {RawCommandsRemoteTypePostRequest} [rawCommandsRemoteTypePostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof RawPacketHandlingApi + */ + public rawCommandsRemoteTypePost(remoteType: RemoteType, rawCommandsRemoteTypePostRequest?: RawCommandsRemoteTypePostRequest, options?: RawAxiosRequestConfig) { + return RawPacketHandlingApiFp(this.configuration).rawCommandsRemoteTypePost(remoteType, rawCommandsRemoteTypePostRequest, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * SettingsApi - axios parameter creator + * @export + */ +export const SettingsApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Get existing settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + settingsGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/settings`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Overwrite existing settings with a file + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + settingsPost: async (settings?: Settings, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/settings`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(settings, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Patch existing settings + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + settingsPut: async (settings?: Settings, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/settings`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'PUT', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(settings, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * SettingsApi - functional programming interface + * @export + */ +export const SettingsApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = SettingsApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Get existing settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async settingsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.settingsGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SettingsApi.settingsGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Overwrite existing settings with a file + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async settingsPost(settings?: Settings, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.settingsPost(settings, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SettingsApi.settingsPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Patch existing settings + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async settingsPut(settings?: Settings, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.settingsPut(settings, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SettingsApi.settingsPut']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * SettingsApi - factory interface + * @export + */ +export const SettingsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = SettingsApiFp(configuration) + return { + /** + * + * @summary Get existing settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + settingsGet(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.settingsGet(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Overwrite existing settings with a file + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + settingsPost(settings?: Settings, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.settingsPost(settings, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Patch existing settings + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + settingsPut(settings?: Settings, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.settingsPut(settings, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * SettingsApi - object-oriented interface + * @export + * @class SettingsApi + * @extends {BaseAPI} + */ +export class SettingsApi extends BaseAPI { + /** + * + * @summary Get existing settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SettingsApi + */ + public settingsGet(options?: RawAxiosRequestConfig) { + return SettingsApiFp(this.configuration).settingsGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Overwrite existing settings with a file + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SettingsApi + */ + public settingsPost(settings?: Settings, options?: RawAxiosRequestConfig) { + return SettingsApiFp(this.configuration).settingsPost(settings, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Patch existing settings + * @param {Settings} [settings] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SettingsApi + */ + public settingsPut(settings?: Settings, options?: RawAxiosRequestConfig) { + return SettingsApiFp(this.configuration).settingsPut(settings, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * SystemApi - axios parameter creator + * @export + */ +export const SystemApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Get system information + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aboutGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/about`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Download a backup of all settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + backupGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/backup`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Restore a backup + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + backupPost: async (file?: File, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/backup`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); + + + if (file !== undefined) { + localVarFormParams.append('file', file as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Update firmware + * @param {File} [fileName] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + firmwarePost: async (fileName?: File, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/firmware`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new ((configuration && configuration.formDataCtor) || FormData)(); + + + if (fileName !== undefined) { + localVarFormParams.append('fileName', fileName as any); + } + + + localVarHeaderParameter['Content-Type'] = 'multipart/form-data'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = localVarFormParams; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary List supported remote types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + remoteConfigsGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/remote_configs`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Send commands to the system. Supported commands: 1. `restart`. Restart the ESP8266. 1. `clear_wifi_config`. Clears on-board wifi information. ESP8266 will reboot and enter wifi config mode. + * @summary Send a system command + * @param {SystemPostRequest} [systemPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + systemPost: async (systemPostRequest?: SystemPostRequest, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/system`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(systemPostRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * SystemApi - functional programming interface + * @export + */ +export const SystemApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = SystemApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Get system information + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async aboutGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.aboutGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SystemApi.aboutGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Download a backup of all settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async backupGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.backupGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SystemApi.backupGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Restore a backup + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async backupPost(file?: File, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.backupPost(file, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SystemApi.backupPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Update firmware + * @param {File} [fileName] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async firmwarePost(fileName?: File, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.firmwarePost(fileName, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SystemApi.firmwarePost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary List supported remote types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async remoteConfigsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.remoteConfigsGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SystemApi.remoteConfigsGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * Send commands to the system. Supported commands: 1. `restart`. Restart the ESP8266. 1. `clear_wifi_config`. Clears on-board wifi information. ESP8266 will reboot and enter wifi config mode. + * @summary Send a system command + * @param {SystemPostRequest} [systemPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async systemPost(systemPostRequest?: SystemPostRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.systemPost(systemPostRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['SystemApi.systemPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * SystemApi - factory interface + * @export + */ +export const SystemApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = SystemApiFp(configuration) + return { + /** + * + * @summary Get system information + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + aboutGet(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.aboutGet(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Download a backup of all settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + backupGet(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.backupGet(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Restore a backup + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + backupPost(file?: File, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.backupPost(file, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Update firmware + * @param {File} [fileName] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + firmwarePost(fileName?: File, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.firmwarePost(fileName, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary List supported remote types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + remoteConfigsGet(options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.remoteConfigsGet(options).then((request) => request(axios, basePath)); + }, + /** + * Send commands to the system. Supported commands: 1. `restart`. Restart the ESP8266. 1. `clear_wifi_config`. Clears on-board wifi information. ESP8266 will reboot and enter wifi config mode. + * @summary Send a system command + * @param {SystemPostRequest} [systemPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + systemPost(systemPostRequest?: SystemPostRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.systemPost(systemPostRequest, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * SystemApi - object-oriented interface + * @export + * @class SystemApi + * @extends {BaseAPI} + */ +export class SystemApi extends BaseAPI { + /** + * + * @summary Get system information + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SystemApi + */ + public aboutGet(options?: RawAxiosRequestConfig) { + return SystemApiFp(this.configuration).aboutGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Download a backup of all settings + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SystemApi + */ + public backupGet(options?: RawAxiosRequestConfig) { + return SystemApiFp(this.configuration).backupGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Restore a backup + * @param {File} [file] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SystemApi + */ + public backupPost(file?: File, options?: RawAxiosRequestConfig) { + return SystemApiFp(this.configuration).backupPost(file, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Update firmware + * @param {File} [fileName] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SystemApi + */ + public firmwarePost(fileName?: File, options?: RawAxiosRequestConfig) { + return SystemApiFp(this.configuration).firmwarePost(fileName, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary List supported remote types + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SystemApi + */ + public remoteConfigsGet(options?: RawAxiosRequestConfig) { + return SystemApiFp(this.configuration).remoteConfigsGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * Send commands to the system. Supported commands: 1. `restart`. Restart the ESP8266. 1. `clear_wifi_config`. Clears on-board wifi information. ESP8266 will reboot and enter wifi config mode. + * @summary Send a system command + * @param {SystemPostRequest} [systemPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof SystemApi + */ + public systemPost(systemPostRequest?: SystemPostRequest, options?: RawAxiosRequestConfig) { + return SystemApiFp(this.configuration).systemPost(systemPostRequest, options).then((request) => request(this.axios, this.basePath)); + } +} + + + +/** + * TransitionsApi - axios parameter creator + * @export + */ +export const TransitionsApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary List all active transitions + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsGet: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/transitions`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Delete a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsIdDelete: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('transitionsIdDelete', 'id', id) + const localVarPath = `/transitions/{id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Get properties for a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsIdGet: async (id: number, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'id' is not null or undefined + assertParamExists('transitionsIdGet', 'id', id) + const localVarPath = `/transitions/{id}` + .replace(`{${"id"}}`, encodeURIComponent(String(id))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Create a new transition + * @param {TransitionsPostRequest} [transitionsPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsPost: async (transitionsPostRequest?: TransitionsPostRequest, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/transitions`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(transitionsPostRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * TransitionsApi - functional programming interface + * @export + */ +export const TransitionsApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = TransitionsApiAxiosParamCreator(configuration) + return { + /** + * + * @summary List all active transitions + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async transitionsGet(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.transitionsGet(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['TransitionsApi.transitionsGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Delete a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async transitionsIdDelete(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.transitionsIdDelete(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['TransitionsApi.transitionsIdDelete']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Get properties for a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async transitionsIdGet(id: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.transitionsIdGet(id, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['TransitionsApi.transitionsIdGet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Create a new transition + * @param {TransitionsPostRequest} [transitionsPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async transitionsPost(transitionsPostRequest?: TransitionsPostRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.transitionsPost(transitionsPostRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['TransitionsApi.transitionsPost']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * TransitionsApi - factory interface + * @export + */ +export const TransitionsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = TransitionsApiFp(configuration) + return { + /** + * + * @summary List all active transitions + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsGet(options?: RawAxiosRequestConfig): AxiosPromise> { + return localVarFp.transitionsGet(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Delete a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsIdDelete(id: number, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.transitionsIdDelete(id, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Get properties for a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsIdGet(id: number, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.transitionsIdGet(id, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Create a new transition + * @param {TransitionsPostRequest} [transitionsPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + transitionsPost(transitionsPostRequest?: TransitionsPostRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.transitionsPost(transitionsPostRequest, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * TransitionsApi - object-oriented interface + * @export + * @class TransitionsApi + * @extends {BaseAPI} + */ +export class TransitionsApi extends BaseAPI { + /** + * + * @summary List all active transitions + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TransitionsApi + */ + public transitionsGet(options?: RawAxiosRequestConfig) { + return TransitionsApiFp(this.configuration).transitionsGet(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Delete a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TransitionsApi + */ + public transitionsIdDelete(id: number, options?: RawAxiosRequestConfig) { + return TransitionsApiFp(this.configuration).transitionsIdDelete(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Get properties for a transition + * @param {number} id ID of transition. This will be an auto-incrementing number reset after a restart. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TransitionsApi + */ + public transitionsIdGet(id: number, options?: RawAxiosRequestConfig) { + return TransitionsApiFp(this.configuration).transitionsIdGet(id, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Create a new transition + * @param {TransitionsPostRequest} [transitionsPostRequest] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof TransitionsApi + */ + public transitionsPost(transitionsPostRequest?: TransitionsPostRequest, options?: RawAxiosRequestConfig) { + return TransitionsApiFp(this.configuration).transitionsPost(transitionsPostRequest, options).then((request) => request(this.axios, this.basePath)); + } +} + + + diff --git a/web2/api/base.ts b/web2/api/base.ts new file mode 100644 index 00000000..7f766adf --- /dev/null +++ b/web2/api/base.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * ESP8266 MiLight Hub + * Official documention for MiLight Hub\'s REST API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: chris@sidoh.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from './configuration'; +// Some imports not used depending on template conditions +// @ts-ignore +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; + +export const BASE_PATH = "http://milight-hub".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: RawAxiosRequestConfig; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath ?? basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + constructor(public field: string, msg?: string) { + super(msg); + this.name = "RequiredError" + } +} + +interface ServerMap { + [key: string]: { + url: string, + description: string, + }[]; +} + +/** + * + * @export + */ +export const operationServerMap: ServerMap = { +} diff --git a/web2/api/common.ts b/web2/api/common.ts new file mode 100644 index 00000000..78cbbfa7 --- /dev/null +++ b/web2/api/common.ts @@ -0,0 +1,150 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * ESP8266 MiLight Hub + * Official documention for MiLight Hub\'s REST API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: chris@sidoh.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import type { Configuration } from "./configuration"; +import type { RequestArgs } from "./base"; +import type { AxiosInstance, AxiosResponse } from 'axios'; +import { RequiredError } from "./base"; + +/** + * + * @export + */ +export const DUMMY_BASE_URL = 'https://example.com' + +/** + * + * @throws {RequiredError} + * @export + */ +export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { + if (paramValue === null || paramValue === undefined) { + throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +} + +/** + * + * @export + */ +export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +} + +/** + * + * @export + */ +export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +} + +/** + * + * @export + */ +export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +} + +/** + * + * @export + */ +export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +} + +function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; + if (typeof parameter === "object") { + if (Array.isArray(parameter)) { + (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); + } + else { + Object.keys(parameter).forEach(currentKey => + setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) + ); + } + } + else { + if (urlSearchParams.has(key)) { + urlSearchParams.append(key, parameter); + } + else { + urlSearchParams.set(key, parameter); + } + } +} + +/** + * + * @export + */ +export const setSearchParams = function (url: URL, ...objects: any[]) { + const searchParams = new URLSearchParams(url.search); + setFlattenedQueryParams(searchParams, objects); + url.search = searchParams.toString(); +} + +/** + * + * @export + */ +export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +} + +/** + * + * @export + */ +export const toPathString = function (url: URL) { + return url.pathname + url.search + url.hash +} + +/** + * + * @export + */ +export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { + return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url}; + return axios.request(axiosRequestArgs); + }; +} diff --git a/web2/api/configuration.ts b/web2/api/configuration.ts new file mode 100644 index 00000000..b1e18e34 --- /dev/null +++ b/web2/api/configuration.ts @@ -0,0 +1,110 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * ESP8266 MiLight Hub + * Official documention for MiLight Hub\'s REST API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: chris@sidoh.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + serverIndex?: number; + baseOptions?: any; + formDataCtor?: new () => any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * override server index + * + * @type {number} + * @memberof Configuration + */ + serverIndex?: number; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.serverIndex = param.serverIndex; + this.baseOptions = param.baseOptions; + this.formDataCtor = param.formDataCtor; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} diff --git a/web2/api/git_push.sh b/web2/api/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/web2/api/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/web2/api/index.ts b/web2/api/index.ts new file mode 100644 index 00000000..8bc2d93e --- /dev/null +++ b/web2/api/index.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * ESP8266 MiLight Hub + * Official documention for MiLight Hub\'s REST API. + * + * The version of the OpenAPI document: 1.0.0 + * Contact: chris@sidoh.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export * from "./api"; +export * from "./configuration"; + diff --git a/web2/build.mjs b/web2/build.mjs new file mode 100644 index 00000000..ed438f56 --- /dev/null +++ b/web2/build.mjs @@ -0,0 +1,16 @@ +import { tailwindPlugin } from 'esbuild-plugin-tailwindcss'; +import esbuild from 'esbuild'; + + +await esbuild.build({ + entryPoints: ['src/index.tsx'], + bundle: true, + outfile: 'dist/bundle.js', + minify: true, + sourcemap: false, + define: { 'process.env.NODE_ENV': '"production"' }, + loader: { + '.tsx': 'tsx', + }, + plugins: [tailwindPlugin()], +}); \ No newline at end of file diff --git a/web2/components.json b/web2/components.json new file mode 100644 index 00000000..7687b975 --- /dev/null +++ b/web2/components.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "default", + "rsc": false, + "tsx": true, + "tailwind": { + "config": "tailwind.config.js", + "css": "src/globals.css", + "baseColor": "slate", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils" + } +} \ No newline at end of file diff --git a/web2/components/confirmation-dialog.tsx b/web2/components/confirmation-dialog.tsx new file mode 100644 index 00000000..435d78d8 --- /dev/null +++ b/web2/components/confirmation-dialog.tsx @@ -0,0 +1,67 @@ +import * as React from "react"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, + DialogTrigger, + DialogClose, +} from "./ui/dialog"; +import { Button } from "./ui/button"; + +interface ConfirmationDialogProps { + title: string; + description: string; + open: boolean; + setOpen: (open: boolean) => void; + onConfirm: () => void; + onCancel?: () => void; + confirmText?: string; + cancelText?: string; +} + +const ConfirmationDialog: React.FC = ({ + title, + description, + open, + setOpen, + onConfirm, + onCancel, + confirmText = "Confirm", + cancelText = "Cancel", +}) => { + return ( + + + + {title} + + {description} + + + + + + + ); +}; + +export default ConfirmationDialog; diff --git a/web2/components/light/light-card.tsx b/web2/components/light/light-card.tsx new file mode 100644 index 00000000..41101882 --- /dev/null +++ b/web2/components/light/light-card.tsx @@ -0,0 +1,262 @@ +import React, { useEffect, useRef } from "react"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Slider } from "@/components/ui/slider"; +import { Switch } from "@/components/ui/switch"; +import Wheel from "@uiw/react-color-wheel"; +import { hsvaToRgba, rgbaToHsva } from "@uiw/color-convert"; +import { Sun, Moon, Palette, X } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; +import { api } from "@/lib/api"; +import { + BulbId, + ColorMode, + GatewaysDeviceIdRemoteTypeGroupIdPutRequest, + GroupStateCommand, + GroupStateCommandsCommand, + NormalizedGroupState, +} from "@/api"; +import { useRateLimitMerge } from "@/hooks/use-rate-limit-merge"; +import { LightStatusIcon } from "./light-status-icon"; + +const modeIcons = { + normal: Sun, + night: Moon, + color: Palette, +}; + +export interface LightCapabilities { + brightness: boolean; + color: boolean; + colorTemp: boolean; +} + +export type NormalizedLightMode = "white" | "color" | "scene" | "night"; + +export interface LightCardProps { + name: string; + capabilities: LightCapabilities; + state: NormalizedGroupState; + id: BulbId; + updateState: (payload: Partial) => void; + onClose?: () => void; +} + +export function LightCard({ + name, + capabilities, + state, + id, + updateState: _updateState, + onClose, +}: LightCardProps) { + const [rateLimitedState, setRateLimitedState, clearRateLimitedState] = useRateLimitMerge({}, 500); + const lastUpdateTimeRef = useRef(0); + + const sendUpdate = async (state: GatewaysDeviceIdRemoteTypeGroupIdPutRequest) => { + const response = await api.deviceControl.gatewaysDeviceIdRemoteTypeGroupIdPut( + id.device_id, + id.device_type, + id.group_id, + true, + "normalized", + state + ); + if (response && response.data) { + _updateState(response.data as Partial); + } + }; + + const updateState = (newState: Partial) => { + console.log("UPDATING STATE.", newState); + _updateState(newState); + const now = Date.now(); + if (now - lastUpdateTimeRef.current >= 500) { + // If it's been more than 500ms since the last update, send immediately + sendUpdate(newState); + lastUpdateTimeRef.current = now; + clearRateLimitedState(); + } else { + // Otherwise, buffer the update + setRateLimitedState(prevState => ({ ...prevState, ...newState })); + } + }; + + const sendCommand = async (command: GroupStateCommandsCommand) => { + return await sendUpdate({ command: command }); + }; + + // useEffect to send updates when rateLimitedState changes + useEffect(() => { + if (Object.keys(rateLimitedState.value).length > 0) { + const now = Date.now(); + if (now - lastUpdateTimeRef.current >= 500) { + sendUpdate(rateLimitedState.value); + lastUpdateTimeRef.current = now; + clearRateLimitedState(); + } + } + }, [rateLimitedState]); + + const handleSwitchChange = (checked: boolean) => { + updateState({ state: checked ? "ON" : "OFF" }); + }; + + const handleBrightnessChange = (value: number[]) => { + updateState({ level: value[0] }); + }; + + const handleColorTempChange = (value: number[]) => { + updateState({ kelvin: value[0] }); + _updateState({ color_mode: ColorMode.ColorTemp }); + }; + + const handleColorChange = (color: { + hsva: { h: number; s: number; v: number; a: number }; + }) => { + const rgba = hsvaToRgba(color.hsva); + updateState({ color: rgba }); + _updateState({ color_mode: ColorMode.Rgb }); + }; + + const convertedColor = rgbaToHsva( + state.color ? { ...state.color, a: 1 } : { r: 255, g: 255, b: 255, a: 1 } + ); + + const handleModeChange = (value: ColorMode) => { + _updateState({ color_mode: value }); + if (value === ColorMode.ColorTemp) { + sendCommand(GroupStateCommand.SetWhite); + } else if (value === ColorMode.Rgb) { + updateState({ + color: { + r: state.color?.r || 255, + g: state.color?.g || 0, + b: state.color?.b || 255, + }, + }); + } else if (value === ColorMode.Onoff) { + sendCommand(GroupStateCommand.NightMode); + } + }; + + console.log("render", state.color_mode); + + return ( + + +
+ {onClose && ( + + )} + {name} +
+ +
+
+
+ +
+
+ + {state.state === "ON" ? ( +
+ {capabilities.color && ( +
+
+ +
+
+ +
+
+ )} + {capabilities.brightness && ( +
+ + +
+ )} + {capabilities.colorTemp && ( +
+ + +
+ )} +
+
Mode
+ + + + White + + + + Color + + + + Night + + +
+
+ ) : ( +
+

Light is off

+
+ )} +
+
+ + +
+
+
+ ); +} diff --git a/web2/components/light/light-list.tsx b/web2/components/light/light-list.tsx new file mode 100644 index 00000000..a636f761 --- /dev/null +++ b/web2/components/light/light-list.tsx @@ -0,0 +1,234 @@ +import React, { useReducer, useEffect, useState } from "react"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Switch } from "@/components/ui/switch"; +import { api } from "@/lib/api"; +import { + GatewayListItem, NormalizedGroupState +} from "@/api"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { reducer } from "./state"; // Import the reducer +import { LightStatusIcon } from "./light-status-icon"; +import { Plus, Pencil, Trash } from "lucide-react"; // Import the Plus, Pencil, Trash, and X icons +import ConfirmationDialog from "@/components/confirmation-dialog"; // Import the ConfirmationDialog +import NewLightForm, { NewAlias } from "./new-light-form"; +import { LightCard } from "./light-card"; // Import the LightCard component +import { cn } from "@/lib/utils"; // Make sure to import the cn utility if not already present + +interface LightListProps { + lights: GatewayListItem[]; +} +export function LightList() { + const [lightStates, dispatch] = useReducer(reducer, { lights: [] }); + const [isDeleteMode, setIsDeleteMode] = useState(false); // State to track delete mode + const [showConfirmation, setShowConfirmation] = useState(false); // State to manage dialog visibility + const [lightToDelete, setLightToDelete] = useState( + null + ); // State to track which light to delete + const [selectedLightId, setSelectedLightId] = useState(null); // State for selected light + + useEffect(() => { + const loadInitialState = async () => { + const response = await api.deviceControl.gatewaysGet(); + dispatch({ type: "SET_LIGHTS", lights: response.data }); + }; + loadInitialState(); + }, []); + + const updateGroup = (light: GatewayListItem, state: NormalizedGroupState) => { + console.log("updateGroup", state); + dispatch({ + type: "UPDATE_STATE", + device: light.device, + payload: state, + }); + }; + + const handleSwitchChange = (light: GatewayListItem, checked: boolean) => { + const update: NormalizedGroupState = { + state: checked ? "ON" : ("OFF" as "ON" | "OFF"), + }; + updateGroup(light, update); + api.deviceControl.gatewaysDeviceIdRemoteTypeGroupIdPut( + light.device.device_id, + light.device.device_type, + light.device.group_id, + false, + "normalized", + update + ).then((response) => { + console.log(response); + }); + }; + + const handleAddLight = async (data: NewAlias) => { + console.log(data); + api.aliases.aliasesPost(data).then((response) => { + dispatch({ + type: "ADD_LIGHT", + device: { ...data, id: response.data.id! }, + }); + }); + }; + + const handleAddButtonClick = () => { + // Stub for add button click event + console.log("Add button clicked"); + }; + + const handleDeleteButtonClick = (light: GatewayListItem) => { + setLightToDelete(light); + setShowConfirmation(true); + }; + + const confirmDelete = async () => { + if (lightToDelete) { + await api.aliases.aliasesIdDelete(lightToDelete.device.id); + dispatch({ type: "DELETE_LIGHT", device: lightToDelete.device }); + setLightToDelete(null); + } + setShowConfirmation(false); + }; + + const cancelDelete = () => { + setLightToDelete(null); + setShowConfirmation(false); + }; + + const handleLightClick = (light: GatewayListItem) => { + setSelectedLightId(light.device.id); + console.log(light); + }; + + return ( +
+ + + Lights + + + {lightStates.lights.map((light, index) => ( +
handleLightClick(light)} + > +
+ {isDeleteMode && ( + + )} +
+ +
+ {light.device.alias} +
+ { + e.stopPropagation(); + }} + onCheckedChange={(checked) => { + handleSwitchChange(light, checked); + }} + aria-label={`Toggle ${light.device.alias}`} + /> +
+ ))} +
+ + + + + + + + Add new light + + + + +
+
+
+ {showConfirmation && ( + + )} + {selectedLightId && ( + setSelectedLightId(null)} + > + + {(() => { + const selectedLight = lightStates.lights.find( + (light) => light.device.id === selectedLightId + ); + return ( + selectedLight && ( + { + updateGroup(selectedLight, payload); + }} + onClose={() => setSelectedLightId(null)} + /> + ) + ); + })()} + + + )} +
+ ); +} diff --git a/web2/components/light/light-status-icon.tsx b/web2/components/light/light-status-icon.tsx new file mode 100644 index 00000000..3b53cbd0 --- /dev/null +++ b/web2/components/light/light-status-icon.tsx @@ -0,0 +1,32 @@ +import React from "react"; +import { Lightbulb } from "lucide-react"; +import { NormalizedGroupState } from "@/api"; + +interface LightStatusIconProps { + state: NormalizedGroupState; +} + +export function LightStatusIcon({ state }: LightStatusIconProps) { + let color = "gray"; // Default color for OFF state + const colorMode = state.color_mode || "white"; + + if (state.state === "ON") { + if (colorMode === "rgb" && state.color) { + color = `rgba(${state.color.r}, ${state.color.g}, ${state.color.b}, 1)`; + } else if ( + state.color_mode === "color_temp" && + state.kelvin !== undefined + ) { + const kelvin = state.kelvin; + if (kelvin < 50) { + color = "lightblue"; // Cool white for low kelvin values + } else { + color = "orange"; // Warm white for high kelvin values + } + } else if (colorMode === "white") { + color = "yellow"; // Yellowish in white mode + } + } + + return ; +} diff --git a/web2/components/light/new-light-form.tsx b/web2/components/light/new-light-form.tsx new file mode 100644 index 00000000..fe8e2186 --- /dev/null +++ b/web2/components/light/new-light-form.tsx @@ -0,0 +1,147 @@ +import React from "react"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; + +import { Button } from "@/components/ui/button"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; // Assuming you have a Select component +import { Alias, RemoteType } from "@/api"; + +const schema = z.object({ + name: z.string().min(1, { message: "Name is required." }), + device_type: z.nativeEnum(RemoteType), + device_id: z + .string() + .regex(/^(0x[0-9A-Fa-f]+|[0-9]+)$/, { + message: + "Invalid device ID format. It should be a hexadecimal number starting with 0x or a decimal number.", + }), + group_id: z.number().int().min(0).max(8), +}); + +export interface NewAlias extends Omit {} + +interface NewLightFormProps { + onSubmit: (data: NewAlias) => void; +} + +export function NewLightForm({ onSubmit }: NewLightFormProps) { + const form = useForm>({ + resolver: zodResolver(schema), + }); + + const handleSubmit = (data: z.infer) => { + const parsedDeviceId = data.device_id.startsWith("0x") + ? parseInt(data.device_id, 16) + : parseInt(data.device_id, 10); + + const parsedData = { + ...data, + alias: data.name, + device_id: parsedDeviceId, + }; + + onSubmit(parsedData); + }; + + return ( +
+ + ( + + Name + + + + + + )} + /> + + ( + + Remote Type + + + + )} + /> + + ( + + Device ID + + + + + + )} + /> + + ( + + Group ID + + field.onChange(+e.target.value)} + /> + + + + )} + /> + + + + + ); +} + +export default NewLightForm; diff --git a/web2/components/light/state.ts b/web2/components/light/state.ts new file mode 100644 index 00000000..4f3198ed --- /dev/null +++ b/web2/components/light/state.ts @@ -0,0 +1,84 @@ +"use strict"; + +import { + Alias, + GatewayListItem, + GatewayListItemDevice, + NormalizedGroupState, +} from "@/api"; + +export interface LightIndexState { + lights: GatewayListItem[]; +} + +type Action = + | { + type: "UPDATE_STATE"; + device: GatewayListItemDevice; + payload: Partial; + } + | { + type: "SET_LIGHTS"; + lights: GatewayListItem[]; + } + | { + type: "DELETE_LIGHT"; + device: GatewayListItemDevice; + } + | { + type: "ADD_LIGHT"; + device: Alias; + }; + +function devicesAreEqual(a: GatewayListItemDevice, b: GatewayListItemDevice) { + return ( + a.device_id === b.device_id && + a.device_type === b.device_type && + a.group_id === b.group_id + ); +} + +// Reducer function +export function reducer( + state: LightIndexState, + action: Action +): LightIndexState { + switch (action.type) { + case "UPDATE_STATE": + return { + ...state, + lights: state.lights.map((light) => + devicesAreEqual(light.device, action.device) + ? { ...light, state: { ...light.state, ...action.payload } } + : light + ), + }; + case "SET_LIGHTS": + return { + ...state, + lights: action.lights, + }; + case "DELETE_LIGHT": + return { + ...state, + lights: state.lights.filter( + (light) => !devicesAreEqual(light.device, action.device) + ), + }; + case "ADD_LIGHT": + console.log(action.device); + const device = { + id: action.device.id!, + device_id: action.device.device_id!, + device_type: action.device.device_type!, + group_id: action.device.group_id!, + alias: action.device.alias!, + }; + return { + ...state, + lights: [...state.lights, { device, state: { state: "OFF" } }], + }; + default: + return state; + } +} diff --git a/web2/components/ui/button.tsx b/web2/components/ui/button.tsx new file mode 100644 index 00000000..0ba42773 --- /dev/null +++ b/web2/components/ui/button.tsx @@ -0,0 +1,56 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const buttonVariants = cva( + "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground hover:bg-primary/90", + destructive: + "bg-destructive text-destructive-foreground hover:bg-destructive/90", + outline: + "border border-input bg-background hover:bg-accent hover:text-accent-foreground", + secondary: + "bg-secondary text-secondary-foreground hover:bg-secondary/80", + ghost: "hover:bg-accent hover:text-accent-foreground", + link: "text-primary underline-offset-4 hover:underline", + }, + size: { + default: "h-10 px-4 py-2", + sm: "h-9 rounded-md px-3", + lg: "h-11 rounded-md px-8", + icon: "h-10 w-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +export interface ButtonProps + extends React.ButtonHTMLAttributes, + VariantProps { + asChild?: boolean +} + +const Button = React.forwardRef( + ({ className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : "button" + return ( + + ) + } +) +Button.displayName = "Button" + +export { Button, buttonVariants } diff --git a/web2/components/ui/card.tsx b/web2/components/ui/card.tsx new file mode 100644 index 00000000..afa13ecf --- /dev/null +++ b/web2/components/ui/card.tsx @@ -0,0 +1,79 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +const Card = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +Card.displayName = "Card" + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardHeader.displayName = "CardHeader" + +const CardTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)) +CardTitle.displayName = "CardTitle" + +const CardDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)) +CardDescription.displayName = "CardDescription" + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

+)) +CardContent.displayName = "CardContent" + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +CardFooter.displayName = "CardFooter" + +export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } diff --git a/web2/components/ui/dialog.tsx b/web2/components/ui/dialog.tsx new file mode 100644 index 00000000..3238c46e --- /dev/null +++ b/web2/components/ui/dialog.tsx @@ -0,0 +1,126 @@ +import * as React from "react"; +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { X } from "lucide-react"; + +import { cn } from "@/lib/utils"; + +const Dialog = DialogPrimitive.Root; + +const DialogTrigger = DialogPrimitive.Trigger; + +const DialogPortal = DialogPrimitive.Portal; + +const DialogClose = DialogPrimitive.Close; + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + closeButton?: boolean; + } +>(({ className, children, closeButton = true, ...props }, ref) => ( + + + +
+ {children} + {closeButton && ( + + + Close + + )} +
+
+
+)); +DialogContent.displayName = DialogPrimitive.Content.displayName; + +const DialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+); +DialogHeader.displayName = "DialogHeader"; + +const DialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+); +DialogFooter.displayName = "DialogFooter"; + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +DialogTitle.displayName = DialogPrimitive.Title.displayName; + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +DialogDescription.displayName = DialogPrimitive.Description.displayName; + +export { + Dialog, + DialogPortal, + DialogOverlay, + DialogClose, + DialogTrigger, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +}; diff --git a/web2/components/ui/form.tsx b/web2/components/ui/form.tsx new file mode 100644 index 00000000..4603f8b3 --- /dev/null +++ b/web2/components/ui/form.tsx @@ -0,0 +1,176 @@ +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { Slot } from "@radix-ui/react-slot" +import { + Controller, + ControllerProps, + FieldPath, + FieldValues, + FormProvider, + useFormContext, +} from "react-hook-form" + +import { cn } from "@/lib/utils" +import { Label } from "@/components/ui/label" + +const Form = FormProvider + +type FormFieldContextValue< + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +> = { + name: TName +} + +const FormFieldContext = React.createContext( + {} as FormFieldContextValue +) + +const FormField = < + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath +>({ + ...props +}: ControllerProps) => { + return ( + + + + ) +} + +const useFormField = () => { + const fieldContext = React.useContext(FormFieldContext) + const itemContext = React.useContext(FormItemContext) + const { getFieldState, formState } = useFormContext() + + const fieldState = getFieldState(fieldContext.name, formState) + + if (!fieldContext) { + throw new Error("useFormField should be used within ") + } + + const { id } = itemContext + + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + } +} + +type FormItemContextValue = { + id: string +} + +const FormItemContext = React.createContext( + {} as FormItemContextValue +) + +const FormItem = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => { + const id = React.useId() + + return ( + +
+ + ) +}) +FormItem.displayName = "FormItem" + +const FormLabel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => { + const { error, formItemId } = useFormField() + + return ( +