From f7ac41ebcf24abf54abdecdb7eb96bfe27e23d65 Mon Sep 17 00:00:00 2001 From: Ronny Matthei Date: Fri, 6 Dec 2024 20:27:57 +0100 Subject: [PATCH] ... --- build/main.js | 2 +- build/main.js.map | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/main.js b/build/main.js index faac52d..8163d28 100644 --- a/build/main.js +++ b/build/main.js @@ -142,7 +142,7 @@ class Ankersolix2 extends utils.Adapter { this.refreshTimeout = null; this.refreshDate(); }, this.config.POLL_INTERVAL * 1e3); - this.log.debug(`Sleeping for ${this.config.POLL_INTERVAL * 1e3}ms... id ${this.refreshTimeout}`); + this.log.debug(`Sleeping for ${this.config.POLL_INTERVAL * 1e3}ms... TimerId ${this.refreshTimeout}`); } } async fetchAndPublish() { diff --git a/build/main.js.map b/build/main.js.map index f2fcb99..b81d770 100644 --- a/build/main.js.map +++ b/build/main.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/main.ts"], - "sourcesContent": ["/*\n * Created with @iobroker/create-adapter v2.6.3\n */\n\n// The adapter-core module gives you access to the core ioBroker functions\n// you need to create an adapter\nimport * as utils from '@iobroker/adapter-core';\nimport fs, { promises as pfs } from 'fs';\nimport { LoginResultResponse, SolixApi } from './api';\n\n// Load your modules here, e.g.:\n\nclass Ankersolix2 extends utils.Adapter {\n private storeData: string = '';\n private refreshTimeout: any;\n private loginData: LoginResultResponse | null;\n private api: any;\n\n public constructor(options: Partial = {}) {\n super({\n ...options,\n name: 'ankersolix2',\n });\n\n this.storeData = utils.getAbsoluteInstanceDataDir(this) + '/session.data';\n this.loginData = null;\n this.refreshTimeout = null;\n this.on('ready', this.onReady.bind(this));\n this.on('stateChange', this.onStateChange.bind(this));\n // this.on('objectChange', this.onObjectChange.bind(this));\n // this.on('message', this.onMessage.bind(this));\n this.on('unload', this.onUnload.bind(this));\n }\n\n /**\n * Is called when databases are connected and adapter received configuration.\n */\n private async onReady(): Promise {\n // Initialize your adapter here\n\n if (!this.config.Username || !this.config.Password) {\n this.log.error(\n `User name and/or user password empty - please check instance configuration of ${this.namespace}`,\n );\n return;\n }\n\n if (!this.config.POLL_INTERVAL || this.config.POLL_INTERVAL < 10) {\n this.log.error(\n `The poll intervall must be greater than 10 - please check instance configuration of ${this.namespace}`,\n );\n return;\n }\n\n try {\n // create directory to store fetch data\n if (!fs.existsSync(utils.getAbsoluteInstanceDataDir(this))) {\n fs.mkdirSync(utils.getAbsoluteInstanceDataDir(this));\n this.log.debug('Folder created: ' + this.storeData);\n }\n } catch (err) {\n this.log.error(\n 'Could not create storage directory (' + utils.getAbsoluteInstanceDataDir(this) + '): ' + err,\n );\n return;\n }\n\n this.api = new SolixApi({\n username: this.config.Username,\n password: this.config.Password,\n country: this.config.COUNTRY,\n log: this.log,\n });\n\n this.refreshDate();\n }\n\n async loginAPI(): Promise {\n let login = await this.restoreLoginData();\n\n if (!this.isLoginValid(login)) {\n this.log.debug('loginAPI: token expires');\n login = null;\n }\n\n if (login == null) {\n try {\n const loginResponse = await this.api.login();\n login = loginResponse.data ?? null;\n\n if (login && loginResponse.code == 0) {\n this.log.debug('LoginRsponseCode: ' + loginResponse.code);\n\n await this.storeLoginData(login);\n }\n } catch (error) {\n this.log.error('loginAPI: ' + (error as any).message);\n const status = (error as any).status;\n if (status == 401) {\n if (fs.existsSync(this.storeData)) {\n fs.unlinkSync(this.storeData);\n }\n this.terminate('Credentials are wrong, please check and restart', status);\n }\n\n return null;\n }\n } else {\n this.log.debug('Using auth data from savefile');\n }\n\n return login;\n }\n\n async storeLoginData(data: LoginResultResponse): Promise {\n this.log.debug('Write Data to File');\n await pfs.writeFile(this.storeData, JSON.stringify(data), 'utf-8');\n }\n\n async restoreLoginData(): Promise {\n try {\n this.log.debug('Try to restore data from File');\n const data = await pfs.readFile(this.storeData, 'utf8');\n return JSON.parse(data);\n } catch (err) {\n if ((err as any).code === 'ENOENT') {\n this.log.error('RestoreLoginData: ' + (err as any).message);\n return null;\n } else {\n this.log.error('RestoreLoginData: ' + (err as any).message);\n return null;\n }\n }\n }\n\n async refreshDate(): Promise {\n try {\n this.loginData = await this.loginAPI();\n\n await this.fetchAndPublish();\n } catch (err) {\n this.log.error('Failed fetching or publishing printer data, Error: ' + err);\n this.log.debug(`Error Object: ${JSON.stringify(err)}`);\n } finally {\n if (this.refreshTimeout) {\n this.log.debug('refreshTimeout: ' + this.refreshTimeout.id);\n this.clearTimeout(this.refreshTimeout);\n }\n\n this.refreshTimeout = this.setTimeout(() => {\n this.refreshTimeout = null;\n this.refreshDate();\n }, this.config.POLL_INTERVAL * 1000);\n this.log.debug(`Sleeping for ${this.config.POLL_INTERVAL * 1000}ms... id ${this.refreshTimeout}`);\n }\n }\n\n async fetchAndPublish(): Promise {\n const loggedInApi = await this.api.withLogin(this.loginData);\n const siteHomepage = await loggedInApi.siteHomepage();\n\n let sites;\n if (siteHomepage.data.site_list.length === 0) {\n // Fallback for Shared Accounts\n sites = (await loggedInApi.getSiteList()).data.site_list;\n } else {\n sites = siteHomepage.data.site_list;\n }\n\n for (const site of sites) {\n const scenInfo = await loggedInApi.scenInfo(site.site_id);\n\n const message = JSON.stringify(scenInfo.data);\n const jsonparse = JSON.parse(message);\n\n this.CreateOrUpdate(site.site_id, jsonparse.home_info.home_name, 'device');\n this.CreateOrUpdate(\n site.site_id + '.EXTRA.RAW_JSON',\n 'RAW_JSON',\n 'state',\n 'string',\n 'value',\n false,\n 'undefined',\n );\n\n await this.setState(site.site_id + '.EXTRA.RAW_JSON', { val: message, ack: true });\n\n Object.entries(jsonparse).forEach((entries) => {\n const [id, value] = entries;\n\n const type = this.whatIsIt(value);\n\n const key = site.site_id + '.' + id;\n\n if (type === 'object') {\n this.isObject(key, value);\n } else if (type === 'array') {\n const array = JSON.parse(JSON.stringify(value));\n let i = 0;\n array.forEach((elem: any, item: any) => {\n if (this.whatIsIt(array[item]) === 'object') {\n this.isObject(key + '.' + i, array[item]);\n } else if (this.whatIsIt(array[item]) === 'string') {\n this.isString(key + '.' + i, array[item]);\n }\n i++;\n });\n } else {\n this.isString(key, value);\n }\n });\n }\n this.log.debug('Published.');\n }\n\n whatIsIt(obj: any): 'boolean' | 'number' | 'string' | 'array' | 'object' | 'null' | 'undefined' | undefined {\n if (obj === null) {\n return 'null';\n }\n if (obj === undefined) {\n return 'undefined';\n }\n if (Array.isArray(obj)) {\n return 'array';\n }\n if (typeof obj === 'string') {\n return 'string';\n }\n if (typeof obj === 'boolean') {\n return 'boolean';\n }\n if (typeof obj === 'number') {\n return 'number';\n }\n if (obj != null && typeof obj === 'object') {\n return 'object';\n }\n }\n\n isArray(key: string, value: any): void {\n const array = JSON.parse(JSON.stringify(value));\n array.forEach(async (elem: any, item: any) => {\n const type = this.whatIsIt(array[item]);\n\n if (type === 'object') {\n this.isObject(key, array[item]);\n } else if (type === 'string') {\n this.isString(key, array[item]);\n }\n });\n }\n\n isObject(key: string, value: any): void {\n const name = key.split('.').pop()?.replaceAll('_', ' ');\n\n this.CreateOrUpdate(key, name, 'folder');\n Object.entries(value).forEach((subentries) => {\n const [objkey, objvalue] = subentries;\n const type = this.whatIsIt(objvalue);\n if (type === 'array') {\n this.isArray(key + '.' + objkey, objvalue);\n } else if (type === 'object') {\n this.isObject(key + '.' + objkey, objvalue);\n } else {\n this.isString(key + '.' + objkey, objvalue);\n }\n });\n }\n\n async isString(key: string, value: any): Promise {\n let parmType: ioBroker.CommonType = 'string';\n let parmRole: string = 'value';\n let parmUnit = undefined;\n\n const valType = this.whatIsIt(value);\n\n if (valType === 'boolean') {\n parmType = 'boolean';\n }\n if (valType === 'number') {\n parmType = 'number';\n }\n\n if (key.includes('time') && !key.includes('backup_info')) {\n parmType = 'string';\n parmRole = 'value.time';\n\n if (key.includes('create')) {\n value = new Date(value * 1000).toUTCString();\n } else if (key.includes('update')) {\n //when Update_time not set in JSON, set it to actual time\n value = new Date().getTime().toString();\n }\n }\n\n if (key.includes('_power') && !key.includes('display') && !key.includes('battery')) {\n parmType = 'number';\n value = +value;\n parmUnit = 'W';\n }\n\n if (key.includes('battery_power')) {\n //Battery_power Level in %\n parmRole = 'value.fill';\n parmUnit = '%';\n parmType = 'number';\n\n if (key.includes('total_battery_power')) {\n value = +value * 100;\n } else {\n value = +value;\n }\n }\n\n if (key.includes('unit')) {\n switch (value) {\n case 'kWh':\n case 'W':\n parmRole = 'value.energy';\n break;\n }\n }\n\n const name = key.split('.').pop()?.replaceAll('_', ' ');\n\n await this.CreateOrUpdate(key, name, 'state', parmType, parmRole, false, parmUnit);\n await this.setState(key, { val: value, ack: true });\n }\n\n async CreateOrUpdate(\n path: string,\n name: string | undefined = 'Error',\n type: 'state' | 'device' | 'folder' | 'channel',\n commontype: ioBroker.CommonType | undefined = undefined,\n role: string | undefined = undefined,\n writable: boolean | undefined = undefined,\n unit: string | undefined = undefined,\n min: number | undefined = undefined,\n max: number | undefined = undefined,\n step: number | undefined = undefined,\n ): Promise {\n const obj = await this.getObjectAsync(path);\n if (obj == null) {\n let newObj: any = null;\n if (type === 'state') {\n //this.log.debug(path + ' doesnt exist => create');\n newObj = {\n type: type,\n common: {\n name: name,\n type: commontype,\n role: role,\n read: true,\n write: writable,\n unit: unit,\n min: min,\n max: max,\n step: step,\n },\n native: {},\n };\n } else {\n newObj = {\n type: type,\n common: { name: name },\n native: {},\n };\n }\n //this.log.debug(path + ' doesnt exist => create');\n await this.setObjectAsync(path, newObj);\n } else {\n let changed: boolean = false;\n if (type === 'state') {\n if (obj.common.name != name) {\n obj.common.name = name;\n changed = true;\n }\n if (obj.common.type != commontype) {\n obj.common.type = commontype;\n changed = true;\n }\n if (obj.common.role != role) {\n obj.common.role = role;\n changed = true;\n }\n if (obj.common.read != true) {\n obj.common.read = true;\n changed = true;\n }\n if (obj.common.write != writable) {\n obj.common.write = writable;\n changed = true;\n }\n if (obj.common.unit != unit) {\n obj.common.unit = unit;\n changed = true;\n }\n if (obj.common.min != min) {\n obj.common.min = min;\n changed = true;\n }\n if (obj.common.max != max) {\n obj.common.max = max;\n changed = true;\n }\n if (obj.common.step != step) {\n obj.common.step = step;\n changed = true;\n }\n } else {\n if (obj.common.name != name) {\n obj.common.name = name;\n changed = true;\n }\n if (obj.common.type != type) {\n obj.common.type = type;\n changed = true;\n }\n }\n if (changed) {\n //this.log.debug(path + ' => has been updated');\n await this.setObjectAsync(path, obj);\n }\n }\n }\n\n getJSON(value: string): Promise {\n return JSON.parse(JSON.stringify(value));\n }\n\n isLoginValid(loginData: LoginResultResponse | null, now: Date = new Date()): boolean {\n if (loginData != null) {\n return new Date(loginData.token_expires_at * 1000).getTime() > now.getTime();\n }\n return false;\n }\n\n /**\n * Is called when adapter shuts down - callback has to be called under any circumstances!\n */\n private onUnload(callback: () => void): void {\n try {\n // Here you must clear all timeouts or intervals that may still be active\n // clearTimeout(timeout1);\n // clearTimeout(timeout2);\n // ...\n // clearInterval(interval1);\n\n clearTimeout(this.refreshTimeout);\n\n callback();\n } catch (e) {\n this.log.error('onUnload: ' + e);\n callback();\n }\n }\n\n // If you need to react to object changes, uncomment the following block and the corresponding line in the constructor.\n // You also need to subscribe to the objects with `this.subscribeObjects`, similar to `this.subscribeStates`.\n // /**\n // * Is called if a subscribed object changes\n // */\n // private onObjectChange(id: string, obj: ioBroker.Object | null | undefined): void {\n // if (obj) {\n // // The object was changed\n // this.log.info(`object ${id} changed: ${JSON.stringify(obj)}`);\n // } else {\n // // The object was deleted\n // this.log.info(`object ${id} deleted`);\n // }\n // }\n\n /**\n * Is called if a subscribed state changes\n */\n private onStateChange(id: string, state: ioBroker.State | null | undefined): void {\n if (state) {\n // The state was changed\n this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`);\n } else {\n // The state was deleted\n this.log.info(`state ${id} deleted`);\n }\n }\n\n // If you need to accept messages in your adapter, uncomment the following block and the corresponding line in the constructor.\n // /**\n // * Some message was sent to this instance over message box. Used by email, pushover, text2speech, ...\n // * Using this method requires \"common.messagebox\" property to be set to true in io-package.json\n // */\n // private onMessage(obj: ioBroker.Message): void {\n // if (typeof obj === 'object' && obj.message) {\n // if (obj.command === 'send') {\n // // e.g. send email or pushover or whatever\n // this.log.info('send command');\n\n // // Send response in callback if required\n // if (obj.callback) this.sendTo(obj.from, obj.command, 'Message received', obj.callback);\n // }\n // }\n // }\n}\n\nif (require.main !== module) {\n // Export the constructor in compact mode\n module.exports = (options: Partial | undefined) => new Ankersolix2(options);\n} else {\n // otherwise start the instance directly\n (() => new Ankersolix2())();\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AACvB,gBAAoC;AACpC,iBAA8C;AAI9C,MAAM,oBAAoB,MAAM,QAAQ;AAAA,EAC5B,YAAoB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EAED,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AAED,SAAK,YAAY,MAAM,2BAA2B,IAAI,IAAI;AAC1D,SAAK,YAAY;AACjB,SAAK,iBAAiB;AACtB,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AAGpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,UAAyB;AAGnC,QAAI,CAAC,KAAK,OAAO,YAAY,CAAC,KAAK,OAAO,UAAU;AAChD,WAAK,IAAI;AAAA,QACL,iFAAiF,KAAK,SAAS;AAAA,MACnG;AACA;AAAA,IACJ;AAEA,QAAI,CAAC,KAAK,OAAO,iBAAiB,KAAK,OAAO,gBAAgB,IAAI;AAC9D,WAAK,IAAI;AAAA,QACL,uFAAuF,KAAK,SAAS;AAAA,MACzG;AACA;AAAA,IACJ;AAEA,QAAI;AAEA,UAAI,CAAC,UAAAA,QAAG,WAAW,MAAM,2BAA2B,IAAI,CAAC,GAAG;AACxD,kBAAAA,QAAG,UAAU,M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AI,OAAO;AAEP,WAAK,IAAI,KAAK,SAAS,EAAE,aAAa,MAAM,GAAG,WAAW,MAAM,GAAG,GAAG;AAAA,IAC1E,OAAO;AAEH,WAAK,IAAI,KAAK,SAAS,EAAE,UAAU;AAAA,IACvC;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBJ;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAEzB,SAAO,UAAU,CAAC,YAAuD,IAAI,YAAY,OAAO;AACpG,OAAO;AAEH,GAAC,MAAM,IAAI,YAAY,GAAG;AAC9B;", + "sourcesContent": ["/*\n * Created with @iobroker/create-adapter v2.6.3\n */\n\n// The adapter-core module gives you access to the core ioBroker functions\n// you need to create an adapter\nimport * as utils from '@iobroker/adapter-core';\nimport fs, { promises as pfs } from 'fs';\nimport { LoginResultResponse, SolixApi } from './api';\n\n// Load your modules here, e.g.:\n\nclass Ankersolix2 extends utils.Adapter {\n private storeData: string = '';\n private refreshTimeout: any;\n private loginData: LoginResultResponse | null;\n private api: any;\n\n public constructor(options: Partial = {}) {\n super({\n ...options,\n name: 'ankersolix2',\n });\n\n this.storeData = utils.getAbsoluteInstanceDataDir(this) + '/session.data';\n this.loginData = null;\n this.refreshTimeout = null;\n this.on('ready', this.onReady.bind(this));\n this.on('stateChange', this.onStateChange.bind(this));\n // this.on('objectChange', this.onObjectChange.bind(this));\n // this.on('message', this.onMessage.bind(this));\n this.on('unload', this.onUnload.bind(this));\n }\n\n /**\n * Is called when databases are connected and adapter received configuration.\n */\n private async onReady(): Promise {\n // Initialize your adapter here\n\n if (!this.config.Username || !this.config.Password) {\n this.log.error(\n `User name and/or user password empty - please check instance configuration of ${this.namespace}`,\n );\n return;\n }\n\n if (!this.config.POLL_INTERVAL || this.config.POLL_INTERVAL < 10) {\n this.log.error(\n `The poll intervall must be greater than 10 - please check instance configuration of ${this.namespace}`,\n );\n return;\n }\n\n try {\n // create directory to store fetch data\n if (!fs.existsSync(utils.getAbsoluteInstanceDataDir(this))) {\n fs.mkdirSync(utils.getAbsoluteInstanceDataDir(this));\n this.log.debug('Folder created: ' + this.storeData);\n }\n } catch (err) {\n this.log.error(\n 'Could not create storage directory (' + utils.getAbsoluteInstanceDataDir(this) + '): ' + err,\n );\n return;\n }\n\n this.api = new SolixApi({\n username: this.config.Username,\n password: this.config.Password,\n country: this.config.COUNTRY,\n log: this.log,\n });\n\n this.refreshDate();\n }\n\n async loginAPI(): Promise {\n let login = await this.restoreLoginData();\n\n if (!this.isLoginValid(login)) {\n this.log.debug('loginAPI: token expires');\n login = null;\n }\n\n if (login == null) {\n try {\n const loginResponse = await this.api.login();\n login = loginResponse.data ?? null;\n\n if (login && loginResponse.code == 0) {\n this.log.debug('LoginRsponseCode: ' + loginResponse.code);\n\n await this.storeLoginData(login);\n }\n } catch (error) {\n this.log.error('loginAPI: ' + (error as any).message);\n const status = (error as any).status;\n if (status == 401) {\n if (fs.existsSync(this.storeData)) {\n fs.unlinkSync(this.storeData);\n }\n this.terminate('Credentials are wrong, please check and restart', status);\n }\n\n return null;\n }\n } else {\n this.log.debug('Using auth data from savefile');\n }\n\n return login;\n }\n\n async storeLoginData(data: LoginResultResponse): Promise {\n this.log.debug('Write Data to File');\n await pfs.writeFile(this.storeData, JSON.stringify(data), 'utf-8');\n }\n\n async restoreLoginData(): Promise {\n try {\n this.log.debug('Try to restore data from File');\n const data = await pfs.readFile(this.storeData, 'utf8');\n return JSON.parse(data);\n } catch (err) {\n if ((err as any).code === 'ENOENT') {\n this.log.error('RestoreLoginData: ' + (err as any).message);\n return null;\n } else {\n this.log.error('RestoreLoginData: ' + (err as any).message);\n return null;\n }\n }\n }\n\n async refreshDate(): Promise {\n try {\n this.loginData = await this.loginAPI();\n\n await this.fetchAndPublish();\n } catch (err) {\n this.log.error('Failed fetching or publishing printer data, Error: ' + err);\n this.log.debug(`Error Object: ${JSON.stringify(err)}`);\n } finally {\n if (this.refreshTimeout) {\n this.log.debug('refreshTimeout: ' + this.refreshTimeout.id);\n this.clearTimeout(this.refreshTimeout);\n }\n\n this.refreshTimeout = this.setTimeout(() => {\n this.refreshTimeout = null;\n this.refreshDate();\n }, this.config.POLL_INTERVAL * 1000);\n this.log.debug(`Sleeping for ${this.config.POLL_INTERVAL * 1000}ms... TimerId ${this.refreshTimeout}`);\n }\n }\n\n async fetchAndPublish(): Promise {\n const loggedInApi = await this.api.withLogin(this.loginData);\n const siteHomepage = await loggedInApi.siteHomepage();\n\n let sites;\n if (siteHomepage.data.site_list.length === 0) {\n // Fallback for Shared Accounts\n sites = (await loggedInApi.getSiteList()).data.site_list;\n } else {\n sites = siteHomepage.data.site_list;\n }\n\n for (const site of sites) {\n const scenInfo = await loggedInApi.scenInfo(site.site_id);\n\n const message = JSON.stringify(scenInfo.data);\n const jsonparse = JSON.parse(message);\n\n this.CreateOrUpdate(site.site_id, jsonparse.home_info.home_name, 'device');\n this.CreateOrUpdate(\n site.site_id + '.EXTRA.RAW_JSON',\n 'RAW_JSON',\n 'state',\n 'string',\n 'value',\n false,\n 'undefined',\n );\n\n await this.setState(site.site_id + '.EXTRA.RAW_JSON', { val: message, ack: true });\n\n Object.entries(jsonparse).forEach((entries) => {\n const [id, value] = entries;\n\n const type = this.whatIsIt(value);\n\n const key = site.site_id + '.' + id;\n\n if (type === 'object') {\n this.isObject(key, value);\n } else if (type === 'array') {\n const array = JSON.parse(JSON.stringify(value));\n let i = 0;\n array.forEach((elem: any, item: any) => {\n if (this.whatIsIt(array[item]) === 'object') {\n this.isObject(key + '.' + i, array[item]);\n } else if (this.whatIsIt(array[item]) === 'string') {\n this.isString(key + '.' + i, array[item]);\n }\n i++;\n });\n } else {\n this.isString(key, value);\n }\n });\n }\n this.log.debug('Published.');\n }\n\n whatIsIt(obj: any): 'boolean' | 'number' | 'string' | 'array' | 'object' | 'null' | 'undefined' | undefined {\n if (obj === null) {\n return 'null';\n }\n if (obj === undefined) {\n return 'undefined';\n }\n if (Array.isArray(obj)) {\n return 'array';\n }\n if (typeof obj === 'string') {\n return 'string';\n }\n if (typeof obj === 'boolean') {\n return 'boolean';\n }\n if (typeof obj === 'number') {\n return 'number';\n }\n if (obj != null && typeof obj === 'object') {\n return 'object';\n }\n }\n\n isArray(key: string, value: any): void {\n const array = JSON.parse(JSON.stringify(value));\n array.forEach(async (elem: any, item: any) => {\n const type = this.whatIsIt(array[item]);\n\n if (type === 'object') {\n this.isObject(key, array[item]);\n } else if (type === 'string') {\n this.isString(key, array[item]);\n }\n });\n }\n\n isObject(key: string, value: any): void {\n const name = key.split('.').pop()?.replaceAll('_', ' ');\n\n this.CreateOrUpdate(key, name, 'folder');\n Object.entries(value).forEach((subentries) => {\n const [objkey, objvalue] = subentries;\n const type = this.whatIsIt(objvalue);\n if (type === 'array') {\n this.isArray(key + '.' + objkey, objvalue);\n } else if (type === 'object') {\n this.isObject(key + '.' + objkey, objvalue);\n } else {\n this.isString(key + '.' + objkey, objvalue);\n }\n });\n }\n\n async isString(key: string, value: any): Promise {\n let parmType: ioBroker.CommonType = 'string';\n let parmRole: string = 'value';\n let parmUnit = undefined;\n\n const valType = this.whatIsIt(value);\n\n if (valType === 'boolean') {\n parmType = 'boolean';\n }\n if (valType === 'number') {\n parmType = 'number';\n }\n\n if (key.includes('time') && !key.includes('backup_info')) {\n parmType = 'string';\n parmRole = 'value.time';\n\n if (key.includes('create')) {\n value = new Date(value * 1000).toUTCString();\n } else if (key.includes('update')) {\n //when Update_time not set in JSON, set it to actual time\n value = new Date().getTime().toString();\n }\n }\n\n if (key.includes('_power') && !key.includes('display') && !key.includes('battery')) {\n parmType = 'number';\n value = +value;\n parmUnit = 'W';\n }\n\n if (key.includes('battery_power')) {\n //Battery_power Level in %\n parmRole = 'value.fill';\n parmUnit = '%';\n parmType = 'number';\n\n if (key.includes('total_battery_power')) {\n value = +value * 100;\n } else {\n value = +value;\n }\n }\n\n if (key.includes('unit')) {\n switch (value) {\n case 'kWh':\n case 'W':\n parmRole = 'value.energy';\n break;\n }\n }\n\n const name = key.split('.').pop()?.replaceAll('_', ' ');\n\n await this.CreateOrUpdate(key, name, 'state', parmType, parmRole, false, parmUnit);\n await this.setState(key, { val: value, ack: true });\n }\n\n async CreateOrUpdate(\n path: string,\n name: string | undefined = 'Error',\n type: 'state' | 'device' | 'folder' | 'channel',\n commontype: ioBroker.CommonType | undefined = undefined,\n role: string | undefined = undefined,\n writable: boolean | undefined = undefined,\n unit: string | undefined = undefined,\n min: number | undefined = undefined,\n max: number | undefined = undefined,\n step: number | undefined = undefined,\n ): Promise {\n const obj = await this.getObjectAsync(path);\n if (obj == null) {\n let newObj: any = null;\n if (type === 'state') {\n //this.log.debug(path + ' doesnt exist => create');\n newObj = {\n type: type,\n common: {\n name: name,\n type: commontype,\n role: role,\n read: true,\n write: writable,\n unit: unit,\n min: min,\n max: max,\n step: step,\n },\n native: {},\n };\n } else {\n newObj = {\n type: type,\n common: { name: name },\n native: {},\n };\n }\n //this.log.debug(path + ' doesnt exist => create');\n await this.setObjectAsync(path, newObj);\n } else {\n let changed: boolean = false;\n if (type === 'state') {\n if (obj.common.name != name) {\n obj.common.name = name;\n changed = true;\n }\n if (obj.common.type != commontype) {\n obj.common.type = commontype;\n changed = true;\n }\n if (obj.common.role != role) {\n obj.common.role = role;\n changed = true;\n }\n if (obj.common.read != true) {\n obj.common.read = true;\n changed = true;\n }\n if (obj.common.write != writable) {\n obj.common.write = writable;\n changed = true;\n }\n if (obj.common.unit != unit) {\n obj.common.unit = unit;\n changed = true;\n }\n if (obj.common.min != min) {\n obj.common.min = min;\n changed = true;\n }\n if (obj.common.max != max) {\n obj.common.max = max;\n changed = true;\n }\n if (obj.common.step != step) {\n obj.common.step = step;\n changed = true;\n }\n } else {\n if (obj.common.name != name) {\n obj.common.name = name;\n changed = true;\n }\n if (obj.common.type != type) {\n obj.common.type = type;\n changed = true;\n }\n }\n if (changed) {\n //this.log.debug(path + ' => has been updated');\n await this.setObjectAsync(path, obj);\n }\n }\n }\n\n getJSON(value: string): Promise {\n return JSON.parse(JSON.stringify(value));\n }\n\n isLoginValid(loginData: LoginResultResponse | null, now: Date = new Date()): boolean {\n if (loginData != null) {\n return new Date(loginData.token_expires_at * 1000).getTime() > now.getTime();\n }\n return false;\n }\n\n /**\n * Is called when adapter shuts down - callback has to be called under any circumstances!\n */\n private onUnload(callback: () => void): void {\n try {\n // Here you must clear all timeouts or intervals that may still be active\n // clearTimeout(timeout1);\n // clearTimeout(timeout2);\n // ...\n // clearInterval(interval1);\n\n clearTimeout(this.refreshTimeout);\n\n callback();\n } catch (e) {\n this.log.error('onUnload: ' + e);\n callback();\n }\n }\n\n // If you need to react to object changes, uncomment the following block and the corresponding line in the constructor.\n // You also need to subscribe to the objects with `this.subscribeObjects`, similar to `this.subscribeStates`.\n // /**\n // * Is called if a subscribed object changes\n // */\n // private onObjectChange(id: string, obj: ioBroker.Object | null | undefined): void {\n // if (obj) {\n // // The object was changed\n // this.log.info(`object ${id} changed: ${JSON.stringify(obj)}`);\n // } else {\n // // The object was deleted\n // this.log.info(`object ${id} deleted`);\n // }\n // }\n\n /**\n * Is called if a subscribed state changes\n */\n private onStateChange(id: string, state: ioBroker.State | null | undefined): void {\n if (state) {\n // The state was changed\n this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`);\n } else {\n // The state was deleted\n this.log.info(`state ${id} deleted`);\n }\n }\n\n // If you need to accept messages in your adapter, uncomment the following block and the corresponding line in the constructor.\n // /**\n // * Some message was sent to this instance over message box. Used by email, pushover, text2speech, ...\n // * Using this method requires \"common.messagebox\" property to be set to true in io-package.json\n // */\n // private onMessage(obj: ioBroker.Message): void {\n // if (typeof obj === 'object' && obj.message) {\n // if (obj.command === 'send') {\n // // e.g. send email or pushover or whatever\n // this.log.info('send command');\n\n // // Send response in callback if required\n // if (obj.callback) this.sendTo(obj.from, obj.command, 'Message received', obj.callback);\n // }\n // }\n // }\n}\n\nif (require.main !== module) {\n // Export the constructor in compact mode\n module.exports = (options: Partial | undefined) => new Ankersolix2(options);\n} else {\n // otherwise start the instance directly\n (() => new Ankersolix2())();\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AACvB,gBAAoC;AACpC,iBAA8C;AAI9C,MAAM,oBAAoB,MAAM,QAAQ;AAAA,EAC5B,YAAoB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EAED,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AAED,SAAK,YAAY,MAAM,2BAA2B,IAAI,IAAI;AAC1D,SAAK,YAAY;AACjB,SAAK,iBAAiB;AACtB,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AAGpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,UAAyB;AAGnC,QAAI,CAAC,KAAK,OAAO,YAAY,CAAC,KAAK,OAAO,UAAU;AAChD,WAAK,IAAI;AAAA,QACL,iFAAiF,KAAK,SAAS;AAAA,MACnG;AACA;AAAA,IACJ;AAEA,QAAI,CAAC,KAAK,OAAO,iBAAiB,KAAK,OAAO,gBAAgB,IAAI;AAC9D,WAAK,IAAI;AAAA,QACL,uFAAuF,KAAK,SAAS;AAAA,MACzG;AACA;AAAA,IACJ;AAEA,QAAI;AAEA,UAAI,CAAC,UAAAA,QAAG,WAAW,MAAM,2BAA2B,IAAI,CAAC,GAAG;AACxD,kBAAAA,QAAG,UAAU,MAAM,2BAA2B,IAAI,CAAC;AACnD,aAAK,IAAI,MAAM,qBAAqB,KAAK,SAAS;AAAA,MACtD;AAAA,IACJ,SAAS,KAAK;AACV,WAAK,IAAI;AAAA,QACL,yCAAyC,MAAM,2BAA2B,IAAI,IAAI,QAAQ;AAAA,MAC9F;AACA;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