From 4f52cbc520e78dbc9daf625d272eb6a7392f1cf8 Mon Sep 17 00:00:00 2001 From: afuerhoff <50245893+afuerhoff@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:33:19 +0100 Subject: [PATCH] some optimizations --- build/main.js | 2 ++ build/main.js.map | 4 ++-- src/main.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build/main.js b/build/main.js index 2b009d8..9a79495 100644 --- a/build/main.js +++ b/build/main.js @@ -519,6 +519,8 @@ class Solarviewdatareader extends utils.Adapter { if (csum.data.toString("ascii") != ";-)\n") { this.chkCnt += 1; this.log.warn(`checksum not correct! ${sv_data[0]}: ${csum.data.toString("ascii")}`); + } else { + this.log.warn(`command ${this.lastCommand} not supported!`); } } } diff --git a/build/main.js.map b/build/main.js.map index 686b09c..f897406 100644 --- a/build/main.js.map +++ b/build/main.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/main.ts"], - "sourcesContent": ["'use strict';\n/*\n * Created with @iobroker/create-adapter v1.14.0\n */\n\n// The adapter-core module gives you access to the core ioBroker functions\nimport * as utils from '@iobroker/adapter-core';\n\n// Load your modules here, e.g.:\nimport * as net from 'net';\n\ninterface ChecksumResult {\n result: boolean;\n chksum: number;\n ind: number;\n data: Buffer;\n}\n\nclass Solarviewdatareader extends utils.Adapter {\n tout!: NodeJS.Timeout;\n jobSchedule!: NodeJS.Timeout;\n chkCnt = 0;\n conn!: net.Socket;\n lastCommand: string | null = null;\n private commandQueue: string[] = [];\n private isProcessingQueue = false;\n private isProcessingCmd = false;\n\n public constructor(options: Partial = {}) {\n super({\n ...options,\n name: 'solarviewdatareader',\n });\n //this.pTimeoutcnt = 0;\n this.on('ready', this.onReady.bind(this));\n this.on('unload', this.onUnload.bind(this));\n }\n\n // Nullen voranstellen - add Leading Zero\n aLZ(n: number): string {\n return n <= 9 ? `0${n}` : n.toString();\n }\n\n calcChecksum(inputString: string): ChecksumResult {\n const buffer = Buffer.from(inputString);\n let sum = 0;\n let index = 0;\n\n for (let i = 0; i < buffer.length; i++) {\n sum = (sum + buffer[i]) % 128;\n if (buffer[i] === 125) {\n index = i + 2;\n break;\n }\n }\n\n const result: ChecksumResult = {\n result: buffer[index] === sum,\n chksum: sum,\n ind: index,\n data: buffer,\n };\n\n return result;\n }\n\n async createObject(id: string, obj: ioBroker.SettableObject): Promise {\n await this.setObjectNotExistsAsync(id, obj);\n await this.extendObject(id, obj);\n\n const currentState = await this.getStateAsync(id);\n const stCommon: ioBroker.StateCommon = obj.common as ioBroker.StateCommon; // Type Assertion\n if (currentState === null && stCommon.def !== undefined) {\n await this.setState(id, stCommon.def, true); // set default\n }\n }\n\n async createGlobalObjects(): Promise {\n const options: [string, ioBroker.SettableObject][] = [\n [\n 'info.connection',\n {\n type: 'state',\n common: {\n name: 'connection',\n type: 'boolean',\n role: 'indicator.connected',\n def: false,\n read: true,\n write: false,\n desc: 'Solarview connection state',\n unit: '',\n },\n native: {},\n },\n ],\n [\n 'info.lastUpdate',\n {\n type: 'state',\n common: {\n name: 'lastUpdate',\n type: 'string',\n role: 'date',\n def: new Date('1900-01-01T00:00:00').toString(),\n read: true,\n write: false,\n desc: 'Last connection date/time',\n unit: '',\n },\n native: {},\n },\n ],\n ];\n\n for (const option of options) {\n await this.createObject(...option);\n }\n }\n\n async createSolarviewObjects(device: string, additional: boolean = false): Promise {\n let options: [string, ioBroker.SettableObject][] = [\n [device, { type: 'channel', common: { name: device }, native: {} }],\n [\n `${device}.current`,\n {\n type: 'state',\n common: {\n name: 'current',\n type: 'number',\n role: 'value.power',\n def: 0,\n read: true,\n write: false,\n desc: 'Current PAC',\n unit: 'W',\n },\n native: {},\n },\n ],\n [\n `${device}.daily`,\n {\n type: 'state',\n common: {\n name: 'daily',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Daily yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n [\n `${device}.monthly`,\n {\n type: 'state',\n common: {\n name: 'monthly',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Monthly yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n [\n `${device}.yearly`,\n {\n type: 'state',\n common: {\n name: 'yearly',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Yearly yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n [\n `${device}.total`,\n {\n type: 'state',\n common: {\n name: 'total',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Total yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n ];\n\n if (additional) {\n const additionalOptions: [string, ioBroker.SettableObject][] = [\n [\n `${device}.udc`,\n {\n type: 'state',\n common: {\n name: 'udc',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idc`,\n {\n type: 'state',\n common: {\n name: 'idc',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.udcb`,\n {\n type: 'state',\n common: {\n name: 'udcb',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idcb`,\n {\n type: 'state',\n common: {\n name: 'idcb',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.udcc`,\n {\n type: 'state',\n common: {\n name: 'udcc',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idcc`,\n {\n type: 'state',\n common: {\n name: 'idcc',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.udcd`,\n {\n type: 'state',\n common: {\n name: 'udcd',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idcd`,\n {\n type: 'state',\n common: {\n name: 'idcd',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.ul1`,\n {\n type: 'state',\n common: {\n name: 'ul1',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.il1`,\n {\n type: 'state',\n common: {\n name: 'il1',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.ul2`,\n {\n type: 'state',\n common: {\n name: 'ul2',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.il2`,\n {\n type: 'state',\n common: {\n name: 'il2',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.ul3`,\n {\n type: 'state',\n common: {\n name: 'ul3',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.il3`,\n {\n type: 'state',\n common: {\n name: 'il3',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.tkk`,\n {\n type: 'state',\n common: {\n name: 'tkk',\n type: 'number',\n role: 'value.temperature',\n def: 0,\n read: true,\n write: false,\n desc: 'Temperature',\n unit: '\u00B0C',\n },\n native: {},\n },\n ],\n ];\n options = options.concat(additionalOptions);\n }\n\n for (const option of options) {\n await this.createObject(...option);\n }\n }\n\n async adjustIntervalToSeconds(): Promise {\n const adapterObj: ioBroker.Object | null | undefined = await this.getForeignObjectAsync(\n `system.adapter.${this.namespace}`,\n );\n if (!this.config.interval_seconds) {\n if (adapterObj) {\n adapterObj.native.interval_seconds = true;\n adapterObj.native.intervalVal *= 60;\n this.log.warn('Interval changed to seconds!');\n this.log.info('Interval attribute changed! Please check the configuration');\n this.log.info('Adapter restarts');\n }\n }\n }\n\n preprocessSolarviewData(response: Buffer): string[] {\n let sv_data = response.toString('ascii');\n sv_data = sv_data.replace(/[{}]+/g, ''); // Remove \"{}\"\n return sv_data.split(',');\n }\n\n getSolarviewPrefix(dataCode: string): string {\n const prefixMap: { [key: string]: string } = {\n '00': 'pvig.',\n '01': 'pvi1.',\n '02': 'pvi2.',\n '03': 'pvi3.',\n '04': 'pvi4.',\n 10: 'scm0.',\n 11: 'scm1.',\n 12: 'scm2.',\n 13: 'scm3.',\n 14: 'scm4.',\n 21: 'd0supply.',\n 22: 'd0consumption.',\n };\n return prefixMap[dataCode] || '';\n }\n\n async handleChecksumSuccess(sv_data: string[], sv_prefix: string, response: Buffer): Promise {\n try {\n this.chkCnt = 0;\n this.log.debug(`${response.toString('ascii')}`);\n\n await this.updateSolarviewStates(sv_data, sv_prefix);\n\n const sDate = `${sv_data[3]}-${this.aLZ(parseInt(sv_data[2]))}-${this.aLZ(parseInt(sv_data[1]))} ${this.aLZ(parseInt(sv_data[4]))}:${this.aLZ(parseInt(sv_data[5]))}`;\n this.setStateChanged('info.lastUpdate', { val: sDate, ack: true });\n this.setStateChanged('info.connection', { val: true, ack: true });\n } catch (error: any) {\n this.log.error(`handleChecksumSuccess: ${error}`);\n }\n }\n\n handleChecksumFailure(sv_data: string[], csum: ChecksumResult): void {\n if (csum.chksum !== 0) {\n if (csum.data.toString('ascii') != ';-)\\n') {\n this.chkCnt += 1;\n this.log.warn(`checksum not correct! ${sv_data[0]}: ${csum.data.toString('ascii')}`);\n }\n //else -> option not supported from Solarview due to missing Inverter -> chksum ;-)\\n\n }\n }\n\n async updateSolarviewStates(sv_data: string[], sv_prefix: string): Promise {\n try {\n this.updateState(`${sv_prefix}current`, sv_data, 10);\n if (sv_prefix === 'pvig.') {\n await this.handleCCUUpdate(sv_data);\n }\n this.updateState(`${sv_prefix}daily`, sv_data, 6);\n this.updateState(`${sv_prefix}monthly`, sv_data, 7);\n this.updateState(`${sv_prefix}yearly`, sv_data, 8);\n this.updateState(`${sv_prefix}total`, sv_data, 9);\n\n if (sv_data.length >= 23) {\n this.updateExtendedStates(sv_data, sv_prefix);\n }\n } catch (error: any) {\n this.log.error(`updateSolarviewStates: ${error}`);\n }\n }\n\n async handleCCUUpdate(sv_data: string[]): Promise {\n if (this.config.setCCU) {\n const obj = await this.findForeignObjectAsync(this.config.CCUSystemV, 'state');\n if (obj && obj.name) {\n this.log.debug(`set CCU system variable: ${this.config.CCUSystemV}`);\n this.setForeignState(this.config.CCUSystemV, { val: Number(sv_data[10]), ack: false });\n } else {\n this.log.error(`CCU system variable ${this.config.CCUSystemV} does not exist!`);\n }\n }\n }\n\n private updateExtendedStates(sv_data: string[], sv_prefix: string): void {\n this.updateState(`${sv_prefix}udc`, sv_data, 11);\n this.updateState(`${sv_prefix}idc`, sv_data, 12);\n this.updateState(`${sv_prefix}udcb`, sv_data, 13);\n this.updateState(`${sv_prefix}idcb`, sv_data, 14);\n this.updateState(`${sv_prefix}udcc`, sv_data, 15);\n this.updateState(`${sv_prefix}idcc`, sv_data, 16);\n this.updateState(`${sv_prefix}udcd`, sv_data, 17);\n this.updateState(`${sv_prefix}idcd`, sv_data, 18);\n\n if (sv_data.length === 27) {\n // Neue Version Solarview\n this.updateState(`${sv_prefix}ul1`, sv_data, 19);\n this.updateState(`${sv_prefix}il1`, sv_data, 20);\n this.updateState(`${sv_prefix}ul2`, sv_data, 21);\n this.updateState(`${sv_prefix}il2`, sv_data, 22);\n this.updateState(`${sv_prefix}ul3`, sv_data, 23);\n this.updateState(`${sv_prefix}il3`, sv_data, 24);\n this.updateState(`${sv_prefix}tkk`, sv_data, 25);\n } else if (sv_data.length === 23) {\n // Alte Version Solarview\n this.updateState(`${sv_prefix}ul1`, sv_data, 19);\n this.updateState(`${sv_prefix}il1`, sv_data, 20);\n this.updateState(`${sv_prefix}tkk`, sv_data, 21);\n }\n }\n\n private updateState(stateName: string, sv_data: string[], index: number): void {\n const value = Number(sv_data[index]);\n this.setStateChanged(stateName, { val: value, ack: true });\n }\n\n private async onReady(): Promise {\n try {\n const starttime = this.config.intervalstart.split(':').slice(0, 2).join(':');\n const endtime = this.config.intervalend.split(':').slice(0, 2).join(':');\n\n this.log.info(\n `start solarview ${this.config.ipaddress}:${this.config.port} - polling interval: ${this.config.intervalVal}s (${starttime} to ${\n endtime\n })`,\n );\n this.log.info(`d0 converter: ${this.config.d0converter.toString()}`);\n\n await this.createGlobalObjects();\n\n await this.createSolarviewObjects('pvig', false);\n if (this.config.d0converter) {\n await this.createSolarviewObjects('d0supply', false);\n }\n if (this.config.d0converter) {\n await this.createSolarviewObjects('d0consumption', false);\n }\n if (this.config.scm0) {\n await this.createSolarviewObjects('scm0', false);\n }\n if (this.config.scm1) {\n await this.createSolarviewObjects('scm1', false);\n }\n if (this.config.scm2) {\n await this.createSolarviewObjects('scm2', false);\n }\n if (this.config.scm3) {\n await this.createSolarviewObjects('scm3', false);\n }\n if (this.config.scm4) {\n await this.createSolarviewObjects('scm4', false);\n }\n if (this.config.pvi1) {\n await this.createSolarviewObjects('pvi1', true);\n }\n if (this.config.pvi2) {\n await this.createSolarviewObjects('pvi2', true);\n }\n if (this.config.pvi3) {\n await this.createSolarviewObjects('pvi3', true);\n }\n if (this.config.pvi4) {\n await this.createSolarviewObjects('pvi4', true);\n }\n\n if (!this.config.interval_seconds) {\n await this.adjustIntervalToSeconds.call(this);\n }\n\n this.conn = new net.Socket();\n this.conn.setTimeout(2000);\n this.conn.on('data', this.onDataHandler.bind(this));\n this.conn.on('close', this.onCloseHandler.bind(this));\n this.conn.on('error', this.onErrorHandler.bind(this));\n\n //First start\n await this.setCmdQueue();\n\n this.jobSchedule = setInterval(async () => {\n try {\n await this.setCmdQueue();\n } catch (error: any) {\n this.log.error(`onReady.schedule: ${error.message}`);\n }\n }, this.config.intervalVal * 1000);\n } catch (error: any) {\n this.log.error(`onReady: ${error.message}`);\n }\n }\n\n async onDataHandler(data: any): Promise {\n try {\n await this.processData(data);\n this.conn.end();\n } catch (error: any) {\n this.log.error(`conn.on data: ${error.message}`);\n }\n }\n\n processData = async (data: Buffer): Promise => {\n try {\n const strdata: string[] = this.preprocessSolarviewData(data);\n const id = this.getSolarviewPrefix(strdata[0]);\n const cs: ChecksumResult = this.calcChecksum(data.toString('ascii'));\n if (cs.result) {\n await this.handleChecksumSuccess(strdata, id, data);\n } else {\n this.handleChecksumFailure(strdata, cs);\n }\n } catch (error: any) {\n this.log.error(`processData: ${error.message}`);\n }\n };\n\n private async onCloseHandler(): Promise {\n try {\n //this.log.warn('Connection closed');\n if (this.lastCommand) {\n this.log.debug(`Connection closed after executing command: ${this.lastCommand}`);\n } else {\n this.log.debug('Connection closed');\n }\n this.isProcessingCmd = false;\n if (this.chkCnt > 3) {\n await this.setState('info.connection', false, true);\n this.log.warn('Solarview Server is not reachable');\n this.chkCnt = 0;\n }\n } catch (error: any) {\n this.log.error(`conn.on close: ${error.message}`);\n }\n }\n\n onErrorHandler(err: any): void {\n this.log.error(`conn.on error - cmd: ${this.lastCommand} - ${err.message}`);\n }\n\n _sleep(milliseconds: number): Promise {\n return new Promise(resolve => setTimeout(resolve, milliseconds));\n }\n\n connectAsync = (port: number, ip_address: string): Promise => {\n return new Promise((resolve, reject) => {\n this.conn.connect(port, ip_address, () => {\n resolve();\n });\n this.conn.on('error', err => {\n reject(err);\n });\n });\n };\n\n async setCmdQueue(): Promise {\n const commands: string[] = [];\n const { d0converter, scm0, scm1, scm2, scm3, scm4, pvi1, pvi2, pvi3, pvi4, intervalstart, intervalend } =\n this.config;\n\n const starttime = intervalstart.split(':').slice(0, 2).join(':');\n let endtime = intervalend.split(':').slice(0, 2).join(':');\n endtime = endtime === '00:00' ? '23:59' : endtime;\n\n const dnow = new Date();\n const dstart = new Date(`${dnow.getFullYear()}-${dnow.getMonth() + 1}-${dnow.getDate()} ${starttime}`);\n const dend = new Date(`${dnow.getFullYear()}-${dnow.getMonth() + 1}-${dnow.getDate()} ${endtime}`);\n\n if (dnow >= dstart && dnow <= dend) {\n commands.push('00*'); // pvig\n if (d0converter) {\n commands.push('21*');\n }\n if (pvi1) {\n commands.push('01*');\n }\n if (pvi2) {\n commands.push('02*');\n }\n if (pvi3) {\n commands.push('03*');\n }\n if (pvi4) {\n commands.push('04*');\n }\n }\n\n if (d0converter) {\n commands.push('22*');\n }\n if (scm0) {\n commands.push('10*');\n }\n if (scm1) {\n commands.push('11*');\n }\n if (scm2) {\n commands.push('12*');\n }\n if (scm3) {\n commands.push('13*');\n }\n if (scm4) {\n commands.push('14*');\n }\n\n // Befehle zur Warteschlange hinzuf\u00FCgen\n this.commandQueue.push(...commands);\n\n // Verarbeite die Warteschlange\n await this.processQueue();\n }\n\n async processQueue(): Promise {\n if (this.isProcessingQueue) {\n return;\n }\n this.isProcessingQueue = true;\n\n while (this.commandQueue.length > 0) {\n if (!this.isProcessingCmd) {\n const cmd = this.commandQueue.shift();\n if (cmd) {\n try {\n this.isProcessingCmd = true;\n await this.executeCommand(cmd);\n } catch (error: any) {\n this.log.error(`processQueue.executeCommand: ${error}`);\n }\n }\n }\n await this._sleep(500);\n }\n this.isProcessingQueue = false;\n }\n\n private async executeCommand(cmd: string): Promise {\n this.log.debug(`Attempting to execute command: ${cmd}`);\n try {\n await this.connectAsync(this.config.port, this.config.ipaddress);\n this.lastCommand = cmd;\n this.conn.write(cmd);\n this.log.debug(`Command successfully sent: ${cmd}`);\n } catch (error: any) {\n this.log.error(`Error executing command ${cmd}: ${error.message}`);\n throw error;\n }\n }\n\n private onUnload(callback: () => void): void {\n try {\n clearInterval(this.jobSchedule);\n clearTimeout(this.tout);\n this.conn.destroy();\n this.setStateChanged('info.connection', { val: false, ack: true });\n this.log.info('cleaned everything up...');\n callback();\n } catch (error: any) {\n this.log.info(`onUnload: ${error.message}`);\n callback();\n }\n }\n}\n\nif (require.main !== module) {\n module.exports = (options: Partial | undefined) => new Solarviewdatareader(options);\n} else {\n (() => new Solarviewdatareader())();\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AAGvB,UAAqB;AASrB,MAAM,4BAA4B,MAAM,QAAQ;AAAA,EAC5C;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,cAA6B;AAAA,EACrB,eAAyB,CAAC;AAAA,EAC1B,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAEnB,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AAED,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA;AAAA,EAGA,IAAI,GAAmB;AACnB,WAAO,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,SAAS;AAAA,EACzC;AAAA,EAEA,aAAa,aAAqC;AAC9C,UAAM,SAAS,OAAO,KAAK,WAAW;AACtC,QAAI,MAAM;AACV,QAAI,QAAQ;AAEZ,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,MAAM,OAAO,CAAC,KAAK;AAC1B,UAAI,OAAO,CAAC,MAAM,KAAK;AACnB,gBAAQ,IAAI;AACZ;AAAA,MACJ;AAAA,IACJ;AAEA,UAAM,SAAyB;AAAA,MAC3B,QAAQ,OAAO,KAAK,MAAM;AAAA,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AI,MAAM,gCAAgC,KAAK,EAAE;AAAA,UAC1D;AAAA,QACJ;AAAA,MACJ;AACA,YAAM,KAAK,OAAO,GAAG;AAAA,IACzB;AACA,SAAK,oBAAoB;AAAA,EAC7B;AAAA,EAEA,MAAc,eAAe,KAA4B;AACrD,SAAK,IAAI,MAAM,kCAAkC,GAAG,EAAE;AACtD,QAAI;AACA,YAAM,KAAK,aAAa,KAAK,OAAO,MAAM,KAAK,OAAO,SAAS;AAC/D,WAAK,cAAc;AACnB,WAAK,KAAK,MAAM,GAAG;AACnB,WAAK,IAAI,MAAM,8BAA8B,GAAG,EAAE;AAAA,IACtD,SAAS,OAAY;AACjB,WAAK,IAAI,MAAM,2BAA2B,GAAG,KAAK,MAAM,OAAO,EAAE;AACjE,YAAM;AAAA,IACV;AAAA,EACJ;AAAA,EAEQ,SAAS,UAA4B;AACzC,QAAI;AACA,oBAAc,KAAK,WAAW;AAC9B,mBAAa,KAAK,IAAI;AACtB,WAAK,KAAK,QAAQ;AAClB,WAAK,gBAAgB,mBAAmB,EAAE,KAAK,OAAO,KAAK,KAAK,CAAC;AACjE,WAAK,IAAI,KAAK,0BAA0B;AACxC,eAAS;AAAA,IACb,SAAS,OAAY;AACjB,WAAK,IAAI,KAAK,aAAa,MAAM,OAAO,EAAE;AAC1C,eAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAEA,IAAI,QAAQ,SAAS,QAAQ;AACzB,SAAO,UAAU,CAAC,YAAuD,IAAI,oBAAoB,OAAO;AAC5G,OAAO;AACH,GAAC,MAAM,IAAI,oBAAoB,GAAG;AACtC;", + "sourcesContent": ["'use strict';\n/*\n * Created with @iobroker/create-adapter v1.14.0\n */\n\n// The adapter-core module gives you access to the core ioBroker functions\nimport * as utils from '@iobroker/adapter-core';\n\n// Load your modules here, e.g.:\nimport * as net from 'net';\n\ninterface ChecksumResult {\n result: boolean;\n chksum: number;\n ind: number;\n data: Buffer;\n}\n\nclass Solarviewdatareader extends utils.Adapter {\n tout!: NodeJS.Timeout;\n jobSchedule!: NodeJS.Timeout;\n chkCnt = 0;\n conn!: net.Socket;\n lastCommand: string | null = null;\n private commandQueue: string[] = [];\n private isProcessingQueue = false;\n private isProcessingCmd = false;\n\n public constructor(options: Partial = {}) {\n super({\n ...options,\n name: 'solarviewdatareader',\n });\n //this.pTimeoutcnt = 0;\n this.on('ready', this.onReady.bind(this));\n this.on('unload', this.onUnload.bind(this));\n }\n\n // Nullen voranstellen - add Leading Zero\n aLZ(n: number): string {\n return n <= 9 ? `0${n}` : n.toString();\n }\n\n calcChecksum(inputString: string): ChecksumResult {\n const buffer = Buffer.from(inputString);\n let sum = 0;\n let index = 0;\n\n for (let i = 0; i < buffer.length; i++) {\n sum = (sum + buffer[i]) % 128;\n if (buffer[i] === 125) {\n index = i + 2;\n break;\n }\n }\n\n const result: ChecksumResult = {\n result: buffer[index] === sum,\n chksum: sum,\n ind: index,\n data: buffer,\n };\n\n return result;\n }\n\n async createObject(id: string, obj: ioBroker.SettableObject): Promise {\n await this.setObjectNotExistsAsync(id, obj);\n await this.extendObject(id, obj);\n\n const currentState = await this.getStateAsync(id);\n const stCommon: ioBroker.StateCommon = obj.common as ioBroker.StateCommon; // Type Assertion\n if (currentState === null && stCommon.def !== undefined) {\n await this.setState(id, stCommon.def, true); // set default\n }\n }\n\n async createGlobalObjects(): Promise {\n const options: [string, ioBroker.SettableObject][] = [\n [\n 'info.connection',\n {\n type: 'state',\n common: {\n name: 'connection',\n type: 'boolean',\n role: 'indicator.connected',\n def: false,\n read: true,\n write: false,\n desc: 'Solarview connection state',\n unit: '',\n },\n native: {},\n },\n ],\n [\n 'info.lastUpdate',\n {\n type: 'state',\n common: {\n name: 'lastUpdate',\n type: 'string',\n role: 'date',\n def: new Date('1900-01-01T00:00:00').toString(),\n read: true,\n write: false,\n desc: 'Last connection date/time',\n unit: '',\n },\n native: {},\n },\n ],\n ];\n\n for (const option of options) {\n await this.createObject(...option);\n }\n }\n\n async createSolarviewObjects(device: string, additional: boolean = false): Promise {\n let options: [string, ioBroker.SettableObject][] = [\n [device, { type: 'channel', common: { name: device }, native: {} }],\n [\n `${device}.current`,\n {\n type: 'state',\n common: {\n name: 'current',\n type: 'number',\n role: 'value.power',\n def: 0,\n read: true,\n write: false,\n desc: 'Current PAC',\n unit: 'W',\n },\n native: {},\n },\n ],\n [\n `${device}.daily`,\n {\n type: 'state',\n common: {\n name: 'daily',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Daily yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n [\n `${device}.monthly`,\n {\n type: 'state',\n common: {\n name: 'monthly',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Monthly yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n [\n `${device}.yearly`,\n {\n type: 'state',\n common: {\n name: 'yearly',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Yearly yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n [\n `${device}.total`,\n {\n type: 'state',\n common: {\n name: 'total',\n type: 'number',\n role: 'value.energy',\n def: 0,\n read: true,\n write: false,\n desc: 'Total yield',\n unit: 'kWh',\n },\n native: {},\n },\n ],\n ];\n\n if (additional) {\n const additionalOptions: [string, ioBroker.SettableObject][] = [\n [\n `${device}.udc`,\n {\n type: 'state',\n common: {\n name: 'udc',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idc`,\n {\n type: 'state',\n common: {\n name: 'idc',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.udcb`,\n {\n type: 'state',\n common: {\n name: 'udcb',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idcb`,\n {\n type: 'state',\n common: {\n name: 'idcb',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.udcc`,\n {\n type: 'state',\n common: {\n name: 'udcc',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idcc`,\n {\n type: 'state',\n common: {\n name: 'idcc',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.udcd`,\n {\n type: 'state',\n common: {\n name: 'udcd',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.idcd`,\n {\n type: 'state',\n common: {\n name: 'idcd',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Generator current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.ul1`,\n {\n type: 'state',\n common: {\n name: 'ul1',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.il1`,\n {\n type: 'state',\n common: {\n name: 'il1',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.ul2`,\n {\n type: 'state',\n common: {\n name: 'ul2',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.il2`,\n {\n type: 'state',\n common: {\n name: 'il2',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.ul3`,\n {\n type: 'state',\n common: {\n name: 'ul3',\n type: 'number',\n role: 'value.voltage',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains voltage',\n unit: 'V',\n },\n native: {},\n },\n ],\n [\n `${device}.il3`,\n {\n type: 'state',\n common: {\n name: 'il3',\n type: 'number',\n role: 'value.current',\n def: 0,\n read: true,\n write: false,\n desc: 'Mains current',\n unit: 'A',\n },\n native: {},\n },\n ],\n [\n `${device}.tkk`,\n {\n type: 'state',\n common: {\n name: 'tkk',\n type: 'number',\n role: 'value.temperature',\n def: 0,\n read: true,\n write: false,\n desc: 'Temperature',\n unit: '\u00B0C',\n },\n native: {},\n },\n ],\n ];\n options = options.concat(additionalOptions);\n }\n\n for (const option of options) {\n await this.createObject(...option);\n }\n }\n\n async adjustIntervalToSeconds(): Promise {\n const adapterObj: ioBroker.Object | null | undefined = await this.getForeignObjectAsync(\n `system.adapter.${this.namespace}`,\n );\n if (!this.config.interval_seconds) {\n if (adapterObj) {\n adapterObj.native.interval_seconds = true;\n adapterObj.native.intervalVal *= 60;\n this.log.warn('Interval changed to seconds!');\n this.log.info('Interval attribute changed! Please check the configuration');\n this.log.info('Adapter restarts');\n }\n }\n }\n\n preprocessSolarviewData(response: Buffer): string[] {\n let sv_data = response.toString('ascii');\n sv_data = sv_data.replace(/[{}]+/g, ''); // Remove \"{}\"\n return sv_data.split(',');\n }\n\n getSolarviewPrefix(dataCode: string): string {\n const prefixMap: { [key: string]: string } = {\n '00': 'pvig.',\n '01': 'pvi1.',\n '02': 'pvi2.',\n '03': 'pvi3.',\n '04': 'pvi4.',\n 10: 'scm0.',\n 11: 'scm1.',\n 12: 'scm2.',\n 13: 'scm3.',\n 14: 'scm4.',\n 21: 'd0supply.',\n 22: 'd0consumption.',\n };\n return prefixMap[dataCode] || '';\n }\n\n async handleChecksumSuccess(sv_data: string[], sv_prefix: string, response: Buffer): Promise {\n try {\n this.chkCnt = 0;\n this.log.debug(`${response.toString('ascii')}`);\n\n await this.updateSolarviewStates(sv_data, sv_prefix);\n\n const sDate = `${sv_data[3]}-${this.aLZ(parseInt(sv_data[2]))}-${this.aLZ(parseInt(sv_data[1]))} ${this.aLZ(parseInt(sv_data[4]))}:${this.aLZ(parseInt(sv_data[5]))}`;\n this.setStateChanged('info.lastUpdate', { val: sDate, ack: true });\n this.setStateChanged('info.connection', { val: true, ack: true });\n } catch (error: any) {\n this.log.error(`handleChecksumSuccess: ${error}`);\n }\n }\n\n handleChecksumFailure(sv_data: string[], csum: ChecksumResult): void {\n if (csum.chksum !== 0) {\n if (csum.data.toString('ascii') != ';-)\\n') {\n this.chkCnt += 1;\n this.log.warn(`checksum not correct! ${sv_data[0]}: ${csum.data.toString('ascii')}`);\n } else {\n //else -> option not supported from Solarview due to missing Inverter -> chksum ;-)\\n\n this.log.warn(`command ${this.lastCommand} not supported!`);\n }\n }\n }\n\n async updateSolarviewStates(sv_data: string[], sv_prefix: string): Promise {\n try {\n this.updateState(`${sv_prefix}current`, sv_data, 10);\n if (sv_prefix === 'pvig.') {\n await this.handleCCUUpdate(sv_data);\n }\n this.updateState(`${sv_prefix}daily`, sv_data, 6);\n this.updateState(`${sv_prefix}monthly`, sv_data, 7);\n this.updateState(`${sv_prefix}yearly`, sv_data, 8);\n this.updateState(`${sv_prefix}total`, sv_data, 9);\n\n if (sv_data.length >= 23) {\n this.updateExtendedStates(sv_data, sv_prefix);\n }\n } catch (error: any) {\n this.log.error(`updateSolarviewStates: ${error}`);\n }\n }\n\n async handleCCUUpdate(sv_data: string[]): Promise {\n if (this.config.setCCU) {\n const obj = await this.findForeignObjectAsync(this.config.CCUSystemV, 'state');\n if (obj && obj.name) {\n this.log.debug(`set CCU system variable: ${this.config.CCUSystemV}`);\n this.setForeignState(this.config.CCUSystemV, { val: Number(sv_data[10]), ack: false });\n } else {\n this.log.error(`CCU system variable ${this.config.CCUSystemV} does not exist!`);\n }\n }\n }\n\n private updateExtendedStates(sv_data: string[], sv_prefix: string): void {\n this.updateState(`${sv_prefix}udc`, sv_data, 11);\n this.updateState(`${sv_prefix}idc`, sv_data, 12);\n this.updateState(`${sv_prefix}udcb`, sv_data, 13);\n this.updateState(`${sv_prefix}idcb`, sv_data, 14);\n this.updateState(`${sv_prefix}udcc`, sv_data, 15);\n this.updateState(`${sv_prefix}idcc`, sv_data, 16);\n this.updateState(`${sv_prefix}udcd`, sv_data, 17);\n this.updateState(`${sv_prefix}idcd`, sv_data, 18);\n\n if (sv_data.length === 27) {\n // Neue Version Solarview\n this.updateState(`${sv_prefix}ul1`, sv_data, 19);\n this.updateState(`${sv_prefix}il1`, sv_data, 20);\n this.updateState(`${sv_prefix}ul2`, sv_data, 21);\n this.updateState(`${sv_prefix}il2`, sv_data, 22);\n this.updateState(`${sv_prefix}ul3`, sv_data, 23);\n this.updateState(`${sv_prefix}il3`, sv_data, 24);\n this.updateState(`${sv_prefix}tkk`, sv_data, 25);\n } else if (sv_data.length === 23) {\n // Alte Version Solarview\n this.updateState(`${sv_prefix}ul1`, sv_data, 19);\n this.updateState(`${sv_prefix}il1`, sv_data, 20);\n this.updateState(`${sv_prefix}tkk`, sv_data, 21);\n }\n }\n\n private updateState(stateName: string, sv_data: string[], index: number): void {\n const value = Number(sv_data[index]);\n this.setStateChanged(stateName, { val: value, ack: true });\n }\n\n private async onReady(): Promise {\n try {\n const starttime = this.config.intervalstart.split(':').slice(0, 2).join(':');\n const endtime = this.config.intervalend.split(':').slice(0, 2).join(':');\n\n this.log.info(\n `start solarview ${this.config.ipaddress}:${this.config.port} - polling interval: ${this.config.intervalVal}s (${starttime} to ${\n endtime\n })`,\n );\n this.log.info(`d0 converter: ${this.config.d0converter.toString()}`);\n\n await this.createGlobalObjects();\n\n await this.createSolarviewObjects('pvig', false);\n if (this.config.d0converter) {\n await this.createSolarviewObjects('d0supply', false);\n }\n if (this.config.d0converter) {\n await this.createSolarviewObjects('d0consumption', false);\n }\n if (this.config.scm0) {\n await this.createSolarviewObjects('scm0', false);\n }\n if (this.config.scm1) {\n await this.createSolarviewObjects('scm1', false);\n }\n if (this.config.scm2) {\n await this.createSolarviewObjects('scm2', false);\n }\n if (this.config.scm3) {\n await this.createSolarviewObjects('scm3', false);\n }\n if (this.config.scm4) {\n await this.createSolarviewObjects('scm4', false);\n }\n if (this.config.pvi1) {\n await this.createSolarviewObjects('pvi1', true);\n }\n if (this.config.pvi2) {\n await this.createSolarviewObjects('pvi2', true);\n }\n if (this.config.pvi3) {\n await this.createSolarviewObjects('pvi3', true);\n }\n if (this.config.pvi4) {\n await this.createSolarviewObjects('pvi4', true);\n }\n\n if (!this.config.interval_seconds) {\n await this.adjustIntervalToSeconds.call(this);\n }\n\n this.conn = new net.Socket();\n this.conn.setTimeout(2000);\n this.conn.on('data', this.onDataHandler.bind(this));\n this.conn.on('close', this.onCloseHandler.bind(this));\n this.conn.on('error', this.onErrorHandler.bind(this));\n\n //First start\n await this.setCmdQueue();\n\n this.jobSchedule = setInterval(async () => {\n try {\n await this.setCmdQueue();\n } catch (error: any) {\n this.log.error(`onReady.schedule: ${error.message}`);\n }\n }, this.config.intervalVal * 1000);\n } catch (error: any) {\n this.log.error(`onReady: ${error.message}`);\n }\n }\n\n async onDataHandler(data: any): Promise {\n try {\n await this.processData(data);\n this.conn.end();\n } catch (error: any) {\n this.log.error(`conn.on data: ${error.message}`);\n }\n }\n\n processData = async (data: Buffer): Promise => {\n try {\n const strdata: string[] = this.preprocessSolarviewData(data);\n const id = this.getSolarviewPrefix(strdata[0]);\n const cs: ChecksumResult = this.calcChecksum(data.toString('ascii'));\n if (cs.result) {\n await this.handleChecksumSuccess(strdata, id, data);\n } else {\n this.handleChecksumFailure(strdata, cs);\n }\n } catch (error: any) {\n this.log.error(`processData: ${error.message}`);\n }\n };\n\n private async onCloseHandler(): Promise {\n try {\n //this.log.warn('Connection closed');\n if (this.lastCommand) {\n this.log.debug(`Connection closed after executing command: ${this.lastCommand}`);\n } else {\n this.log.debug('Connection closed');\n }\n this.isProcessingCmd = false;\n if (this.chkCnt > 3) {\n await this.setState('info.connection', false, true);\n this.log.warn('Solarview Server is not reachable');\n this.chkCnt = 0;\n }\n } catch (error: any) {\n this.log.error(`conn.on close: ${error.message}`);\n }\n }\n\n onErrorHandler(err: any): void {\n this.log.error(`conn.on error - cmd: ${this.lastCommand} - ${err.message}`);\n }\n\n _sleep(milliseconds: number): Promise {\n return new Promise(resolve => setTimeout(resolve, milliseconds));\n }\n\n connectAsync = (port: number, ip_address: string): Promise => {\n return new Promise((resolve, reject) => {\n this.conn.connect(port, ip_address, () => {\n resolve();\n });\n this.conn.on('error', err => {\n reject(err);\n });\n });\n };\n\n async setCmdQueue(): Promise {\n const commands: string[] = [];\n const { d0converter, scm0, scm1, scm2, scm3, scm4, pvi1, pvi2, pvi3, pvi4, intervalstart, intervalend } =\n this.config;\n\n const starttime = intervalstart.split(':').slice(0, 2).join(':');\n let endtime = intervalend.split(':').slice(0, 2).join(':');\n endtime = endtime === '00:00' ? '23:59' : endtime;\n\n const dnow = new Date();\n const dstart = new Date(`${dnow.getFullYear()}-${dnow.getMonth() + 1}-${dnow.getDate()} ${starttime}`);\n const dend = new Date(`${dnow.getFullYear()}-${dnow.getMonth() + 1}-${dnow.getDate()} ${endtime}`);\n\n if (dnow >= dstart && dnow <= dend) {\n commands.push('00*'); // pvig\n if (d0converter) {\n commands.push('21*');\n }\n if (pvi1) {\n commands.push('01*');\n }\n if (pvi2) {\n commands.push('02*');\n }\n if (pvi3) {\n commands.push('03*');\n }\n if (pvi4) {\n commands.push('04*');\n }\n }\n\n if (d0converter) {\n commands.push('22*');\n }\n if (scm0) {\n commands.push('10*');\n }\n if (scm1) {\n commands.push('11*');\n }\n if (scm2) {\n commands.push('12*');\n }\n if (scm3) {\n commands.push('13*');\n }\n if (scm4) {\n commands.push('14*');\n }\n\n // Befehle zur Warteschlange hinzuf\u00FCgen\n this.commandQueue.push(...commands);\n\n // Verarbeite die Warteschlange\n await this.processQueue();\n }\n\n async processQueue(): Promise {\n if (this.isProcessingQueue) {\n return;\n }\n this.isProcessingQueue = true;\n\n while (this.commandQueue.length > 0) {\n if (!this.isProcessingCmd) {\n const cmd = this.commandQueue.shift();\n if (cmd) {\n try {\n this.isProcessingCmd = true;\n await this.executeCommand(cmd);\n } catch (error: any) {\n this.log.error(`processQueue.executeCommand: ${error}`);\n }\n }\n }\n await this._sleep(500);\n }\n this.isProcessingQueue = false;\n }\n\n private async executeCommand(cmd: string): Promise {\n this.log.debug(`Attempting to execute command: ${cmd}`);\n try {\n await this.connectAsync(this.config.port, this.config.ipaddress);\n this.lastCommand = cmd;\n this.conn.write(cmd);\n this.log.debug(`Command successfully sent: ${cmd}`);\n } catch (error: any) {\n this.log.error(`Error executing command ${cmd}: ${error.message}`);\n throw error;\n }\n }\n\n private onUnload(callback: () => void): void {\n try {\n clearInterval(this.jobSchedule);\n clearTimeout(this.tout);\n this.conn.destroy();\n this.setStateChanged('info.connection', { val: false, ack: true });\n this.log.info('cleaned everything up...');\n callback();\n } catch (error: any) {\n this.log.info(`onUnload: ${error.message}`);\n callback();\n }\n }\n}\n\nif (require.main !== module) {\n module.exports = (options: Partial | undefined) => new Solarviewdatareader(options);\n} else {\n (() => new Solarviewdatareader())();\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AAGvB,UAAqB;AASrB,MAAM,4BAA4B,MAAM,QAAQ;AAAA,EAC5C;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,cAA6B;AAAA,EACrB,eAAyB,CAAC;AAAA,EAC1B,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAEnB,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AAED,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9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AAAA,IACb,SAAS,OAAY;AACjB,WAAK,IAAI,KAAK,aAAa,MAAM,OAAO,EAAE;AAC1C,eAAS;AAAA,IACb;AAAA,EACJ;AACJ;AAEA,IAAI,QAAQ,SAAS,QAAQ;AACzB,SAAO,UAAU,CAAC,YAAuD,IAAI,oBAAoB,OAAO;AAC5G,OAAO;AACH,GAAC,MAAM,IAAI,oBAAoB,GAAG;AACtC;", "names": [] } diff --git a/src/main.ts b/src/main.ts index 932666e..456043f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -533,8 +533,10 @@ class Solarviewdatareader extends utils.Adapter { if (csum.data.toString('ascii') != ';-)\n') { this.chkCnt += 1; this.log.warn(`checksum not correct! ${sv_data[0]}: ${csum.data.toString('ascii')}`); + } else { + //else -> option not supported from Solarview due to missing Inverter -> chksum ;-)\n + this.log.warn(`command ${this.lastCommand} not supported!`); } - //else -> option not supported from Solarview due to missing Inverter -> chksum ;-)\n } }