Skip to content

Commit

Permalink
feat:Review Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanlingZhao committed Feb 7, 2025
1 parent 007b1b3 commit ebebcec
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 117 deletions.
16 changes: 16 additions & 0 deletions .github/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
67 changes: 67 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions admin/jsonConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
22 changes: 16 additions & 6 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -57,7 +70,6 @@
"zh-cn": "集成Reforss设备"
},
"authors": [
"Bluefox <[email protected]>",
"zhaochuanling <[email protected]>",
"Refoss <[email protected]>"
],
Expand Down Expand Up @@ -94,9 +106,7 @@
}
]
},
"native": {
"port": 9989
},
"native": {},
"objects": [],
"instanceObjects": [
{
Expand Down Expand Up @@ -166,4 +176,4 @@
"native": {}
}
]
}
}
12 changes: 6 additions & 6 deletions lib/devices/refossem06.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const refossem06 = {
common: {
name: 'Power Factor',
type: 'number',
role: 'value.pf',
role: 'value.powerFactor',
read: true,
write: false,
def: 0,
Expand Down Expand Up @@ -182,7 +182,7 @@ const refossem06 = {
common: {
name: 'Power Factor',
type: 'number',
role: 'value.pf',
role: 'value.powerFactor',
read: true,
write: false,
def: 0,
Expand Down Expand Up @@ -307,7 +307,7 @@ const refossem06 = {
common: {
name: 'Power Factor',
type: 'number',
role: 'value.pf',
role: 'value.powerFactor',
read: true,
write: false,
def: 0,
Expand Down Expand Up @@ -432,7 +432,7 @@ const refossem06 = {
common: {
name: 'Power Factor',
type: 'number',
role: 'value.pf',
role: 'value.powerFactor',
read: true,
write: false,
def: 0,
Expand Down Expand Up @@ -557,7 +557,7 @@ const refossem06 = {
common: {
name: 'Power Factor',
type: 'number',
role: 'value.pf',
role: 'value.powerFactor',
read: true,
write: false,
def: 0,
Expand Down Expand Up @@ -682,7 +682,7 @@ const refossem06 = {
common: {
name: 'Power Factor',
type: 'number',
role: 'value.pf',
role: 'value.powerFactor',
read: true,
write: false,
def: 0,
Expand Down
67 changes: 0 additions & 67 deletions lib/protocol/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions lib/protocol/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/udp4.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ebebcec

Please sign in to comment.