From ebebcec0c9b12b996cb20400f421b8ca544fbc14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=92=8F=E4=BC=B6?= <1451131107@qq.com> Date: Fri, 7 Feb 2025 11:09:35 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9AReview=20Feedback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/auto-merge.yml | 16 ++++++ .github/dependabot.yml | 17 +++++++ .github/workflows/test-and-release.yml | 67 ++++++++++++++++++++++++++ README.md | 4 ++ admin/jsonConfig.json | 10 ---- io-package.json | 22 ++++++--- lib/devices/refossem06.js | 12 ++--- lib/protocol/base.js | 67 -------------------------- lib/protocol/http.js | 10 ++-- lib/protocol/udp4.js | 2 +- main.js | 17 ------- package-lock.json | 4 +- package.json | 6 +-- 13 files changed, 137 insertions(+), 117 deletions(-) create mode 100644 .github/auto-merge.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/test-and-release.yml diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml new file mode 100644 index 0000000..80b6f12 --- /dev/null +++ b/.github/auto-merge.yml @@ -0,0 +1,16 @@ +# Configure here which dependency updates should be merged automatically. +# The recommended configuration is the following: +- match: + # Only merge patches for production dependencies + dependency_type: production + update_type: "semver:patch" +- match: + # Except for security fixes, here we allow minor patches + dependency_type: production + update_type: "security:minor" +- match: + # and development dependencies can have a minor update, too + dependency_type: development + update_type: "semver:minor" +# The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: +# https://dependabot.com/docs/config-file/#automerged_updates diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cd5a058 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: monthly + time: "04:00" + timezone: Europe/Berlin + open-pull-requests-limit: 5 + versioning-strategy: increase + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: monthly + time: "04:00" + timezone: Europe/Berlin diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..6052a4b --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,67 @@ +name: Test and Release + +# Run this job on all pushes and pull requests +# as well as tags with a semantic version +on: + push: + branches: + - "main" + tags: + # normal versions + - "v[0-9]+.[0-9]+.[0-9]+" + # pre-releases + - "v[0-9]+.[0-9]+.[0-9]+-**" + pull_request: {} + +# Cancel previous PR/branch runs when a new commit is pushed +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + # Performs quick checks before the expensive test runs + check-and-lint: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + runs-on: ubuntu-latest + + steps: + - uses: ioBroker/testing-action-check@v1 + with: + node-version: "20.x" + lint: true + + adapter-tests: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + runs-on: ${{ matrix.os }} + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: ioBroker/testing-action-adapter@v1 + with: + node-version: ${{ matrix.node-version }} + os: ${{ matrix.os }} + + deploy: + needs: [check-and-lint, adapter-tests] + + if: | + contains(github.event.head_commit.message, '[skip ci]') == false && + github.event_name == 'push' && + startsWith(github.ref, 'refs/tags/v') + + runs-on: ubuntu-latest + + steps: + - uses: ioBroker/testing-action-deploy@v1 + with: + node-version: '20.x' + npm-token: ${{ secrets.NPM_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + sentry-token: ${{ secrets.SENTRY_AUTH_TOKEN }} + sentry-project: "iobroker-refoss" + sentry-version-prefix: "iobroker.refoss" diff --git a/README.md b/README.md index 751b1e8..cc220e8 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ You can find more and detailed information about the device here: [Refoss](https ## Changelog +### 0.1.6 (2025-02-07) + +- (zhaochuanling) revise the feedback content + ### 0.1.5 (2024-12-24) - (zhaochuanling) fix detected errors diff --git a/admin/jsonConfig.json b/admin/jsonConfig.json index 45252a1..b3994da 100644 --- a/admin/jsonConfig.json +++ b/admin/jsonConfig.json @@ -2,15 +2,5 @@ "i18n": true, "type": "panel", "items": { - "port": { - "type": "number", - "label": "Port", - "min": 1, - "max": 65535, - "xs": 12, - "sm": 12, - "md": 4, - "lg": 2 - } } } \ No newline at end of file diff --git a/io-package.json b/io-package.json index 8e82e2c..e7d899c 100644 --- a/io-package.json +++ b/io-package.json @@ -1,8 +1,21 @@ { "common": { "name": "refoss", - "version": "0.1.5", + "version": "0.1.6", "news": { + "0.1.6": { + "en": "Revise the feedback content", + "de": "Den Feedback-Inhalt überarbeiten", + "ru": "Отредактировать содержимое обратной связи", + "pt": "Revisar o conteúdo do feedback", + "nl": "Het feedbackinhoud aanpassen", + "fr": "Réviser le contenu du feedback", + "it": "Revisione del contenuto del feedback", + "es": "Revisar el contenido del feedback", + "pl": "Przeanalizuj i zmodyfikuj treść opinii zwrotnej", + "uk": "Переглянути та виправити вміст зворотного зв'язку", + "zh-cn": "修改反馈内容" + }, "0.1.5": { "en": "initial review", "de": "Erste Überprüfung", @@ -57,7 +70,6 @@ "zh-cn": "集成Reforss设备" }, "authors": [ - "Bluefox ", "zhaochuanling ", "Refoss " ], @@ -94,9 +106,7 @@ } ] }, - "native": { - "port": 9989 - }, + "native": {}, "objects": [], "instanceObjects": [ { @@ -166,4 +176,4 @@ "native": {} } ] -} \ No newline at end of file +} diff --git a/lib/devices/refossem06.js b/lib/devices/refossem06.js index 903e83b..949a058 100644 --- a/lib/devices/refossem06.js +++ b/lib/devices/refossem06.js @@ -57,7 +57,7 @@ const refossem06 = { common: { name: 'Power Factor', type: 'number', - role: 'value.pf', + role: 'value.powerFactor', read: true, write: false, def: 0, @@ -182,7 +182,7 @@ const refossem06 = { common: { name: 'Power Factor', type: 'number', - role: 'value.pf', + role: 'value.powerFactor', read: true, write: false, def: 0, @@ -307,7 +307,7 @@ const refossem06 = { common: { name: 'Power Factor', type: 'number', - role: 'value.pf', + role: 'value.powerFactor', read: true, write: false, def: 0, @@ -432,7 +432,7 @@ const refossem06 = { common: { name: 'Power Factor', type: 'number', - role: 'value.pf', + role: 'value.powerFactor', read: true, write: false, def: 0, @@ -557,7 +557,7 @@ const refossem06 = { common: { name: 'Power Factor', type: 'number', - role: 'value.pf', + role: 'value.powerFactor', read: true, write: false, def: 0, @@ -682,7 +682,7 @@ const refossem06 = { common: { name: 'Power Factor', type: 'number', - role: 'value.pf', + role: 'value.powerFactor', read: true, write: false, def: 0, diff --git a/lib/protocol/base.js b/lib/protocol/base.js index 65e6b4e..89a5d3d 100644 --- a/lib/protocol/base.js +++ b/lib/protocol/base.js @@ -21,76 +21,9 @@ class Base { } async initObjects() { this.getDeviceId(this.deveiceInfo) - await this.deleteOldObjects() await this.createObjects() await this.httpState() } - async deleteOldObjects() { - const objList = await this.adapter.getAdapterObjectsAsync(); - const dps = datapoints.getDeviceByClass() - if (dps) { - for (const o in objList) { - const tmpObj = objList[o]; - if (tmpObj && tmpObj._id && tmpObj.type) { - // Remove namespace - const stateId = tmpObj._id.replace(`${this.adapter.namespace}.${this.deviceId}.`, ''); - // Just delete states of this device! - if (tmpObj.type === 'state' && tmpObj._id.startsWith(`${this.adapter.namespace}.${this.deviceId}`)) { - if (!dps[stateId]) { - try { - if (this.objectHelper.getObject(tmpObj._id)) { - this.objectHelper.deleteObject(tmpObj._id); - } else { - await this.adapter.delForeignObjectAsync(tmpObj._id); - } - - delete objList[tmpObj._id]; - delete this.device[stateId]; - - this.adapter.log.debug(`Deleted unused state "${tmpObj._id}"`); - } catch (err) { - this.adapter.log.error(`Could not delete unused state "${tmpObj._id}": ${err}`); - } - } - } - } - } - } - // Delete empty channels - for (const o in objList) { - const tmpObj = objList[o]; - if (tmpObj && tmpObj.type && tmpObj._id && tmpObj.type === 'channel') { - // Search for states in current channel - let found = false - for (const j in objList) { - const tmpidj = objList[j]; - if (!tmpidj) { - continue; - } - - if (tmpidj && tmpidj.type && tmpidj._id && tmpidj.type === 'state' && tmpidj._id.startsWith(tmpObj._id)) { - found = true; - break; - } - } - if (found === false) { - try { - if (this.objectHelper.getObject(tmpObj._id)) { - this.objectHelper.deleteObject(tmpObj._id); - } else { - await this.adapter.delForeignObjectAsync(tmpObj._id, { recursive: true }); - } - - delete objList[tmpObj._id]; - - this.adapter.log.debug(`Deleted unused channel "${tmpObj._id}"`); - } catch (err) { - this.adapter.log.error(`Could not delete unused channel "${tmpObj._id}": ${err}`); - } - } - } - } - } async createObjects() { return new Promise(async (resolve, reject) => { try { diff --git a/lib/protocol/http.js b/lib/protocol/http.js index 8a3fc32..e740dbf 100644 --- a/lib/protocol/http.js +++ b/lib/protocol/http.js @@ -21,14 +21,18 @@ function createHttp(adapter, httpInfo) { "payload": httpInfo.http_payload } // @ts-ignore - axios.post(`http://${httpInfo.http_ip}/config`, data).then(res => { + axios.post(`http://${httpInfo.http_ip}/config`, data, { timeout: 15000 }).then(res => { resolve(res.data.payload) return res.data.payload }).catch(error => { - adapter.log.debug(`axios Error ${error}`) + if (error.code === 'ECONNABORTED') { + adapter.log.error(`request timed out`) + } else { + adapter.log.error(`axios Error ${error}`) + } }); } catch (error) { - adapter.log.debug(`axios Error ${error}`) + adapter.log.error(`axios Error ${error}`) } }) } diff --git a/lib/protocol/udp4.js b/lib/protocol/udp4.js index bdfe566..196a4cb 100644 --- a/lib/protocol/udp4.js +++ b/lib/protocol/udp4.js @@ -50,7 +50,7 @@ class BaseServer{ start() { const that = this server.on("error", function (err) { - that.adapter.log.debug(`[UDP] server error ${err.stack}`) + that.adapter.log.error(`[UDP] server error ${err.stack}`) server.close(); }); // Server receiving diff --git a/main.js b/main.js index aef09de..d1d129e 100644 --- a/main.js +++ b/main.js @@ -25,15 +25,12 @@ class Refoss extends utils.Adapter { this.onlineCheckTimeout = null; this.onlineDevices = {} this.on('ready', this.onReady.bind(this)); - this.on('stateChange', this.onStateChange.bind(this)); // this.on('objectChange', this.onObjectChange.bind(this)); // this.on('message', this.onMessage.bind(this)); this.on('unload', this.onUnload.bind(this)); } async onReady() { try { - await this.mkdirAsync(this.namespace, 'scripts'); - this.subscribeForeignFiles(this.namespace, '*'); this.subscribeStates('*'); objectHelper.init(this); @@ -72,20 +69,6 @@ class Refoss extends utils.Adapter { callback(); } } - /** - * Is called if a subscribed state changes - * @param {string} id - * @param {ioBroker.State | null | undefined} state - */ - onStateChange(id, state) { - if (state) { - // The state was changed - this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`); - } else { - // The state was deleted - this.log.info(`state ${id} deleted`); - } - } async initOnlineStatus() { const deviceIds = await this.getAllDeviceIds(); for (const d in deviceIds) { diff --git a/package-lock.json b/package-lock.json index e292a78..ac2e099 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "iobroker.refoss", - "version": "0.1.5", + "version": "0.1.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "iobroker.refoss", - "version": "0.1.5", + "version": "0.1.6", "license": "MIT", "dependencies": { "@iobroker/adapter-core": "^3.2.2", diff --git a/package.json b/package.json index 577b51a..549ce3c 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,12 @@ { "name": "iobroker.refoss", - "version": "0.1.5", + "version": "0.1.6", "description": "Integrate your Refoss devices", "author": { "name": "zhaochuanling", "email": "zhaochuanling8@gmail.com" }, "contributors": [ - { - "name": "Bluefox", - "email": "dogafox@gmail.com" - }, { "name": "Refoss", "email": "support@refoss.net"