Skip to content

Commit

Permalink
deb updates 1
Browse files Browse the repository at this point in the history
  • Loading branch information
bolliy committed Jun 5, 2024
1 parent 6f049bb commit 2277d55
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 83 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
steps:
- uses: ioBroker/testing-action-check@v1
with:
node-version: '18.x'
node-version: '20.x'
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: true
Expand All @@ -40,7 +40,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
steps:
- uses: ioBroker/testing-action-deploy@v1
with:
node-version: '18.x'
node-version: '20.x'
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
npm-token: ${{ secrets.NPM_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ browse in the [wiki](https://github.com/bolliy/ioBroker.sun2000/wiki)
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* dependency and configuration updates

### 0.9.0 (2024-05-09)
* dependency and configuration updates
* modbus device remains active in standby on the inverter M2,M3
Expand Down
10 changes: 5 additions & 5 deletions lib/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Registers {
//state
async initState(path, state) {
//this.adapter.log.debug('[_initStat] path+id '+path+state.id);
await this.adapter.extendObjectAsync(path+state.id, {
await this.adapter.extendObject(path+state.id, {
type: 'state',
common: {
name: state.name,
Expand All @@ -157,7 +157,7 @@ class Registers {
if (stateEntry.value !== null) {
try {
stateEntry.stored = true;
await this.adapter.setStateAsync(stateEntry.id, {val: stateEntry.value , ack: true});
await this.adapter.setState(stateEntry.id, {val: stateEntry.value , ack: true});
this.adapter.logger.debug(`Fetched ${stateEntry.id}, val=${stateEntry.value}`);
} catch (err) {
stateEntry.stored = false;
Expand Down Expand Up @@ -203,11 +203,11 @@ class Registers {

//state
async _loadStates() {
let state = await this.adapter.getStateAsync('collected.gridExportStart');
let state = await this.adapter.getState('collected.gridExportStart');
this.stateCache.set('collected.gridExportStart',state?.val, {type : 'number', stored : true });
state = await this.adapter.getStateAsync('collected.gridImportStart');
state = await this.adapter.getState('collected.gridImportStart');
this.stateCache.set('collected.gridImportStart',state?.val, {type : 'number', stored : true });
state = await this.adapter.getStateAsync('collected.consumptionStart');
state = await this.adapter.getState('collected.consumptionStart');
this.stateCache.set('collected.consumptionStart',state?.val, {type : 'number', stored : true });
}

Expand Down
48 changes: 24 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ class Sun2000 extends utils.Adapter {

async initPath() {
//inverter
await this.extendObjectAsync('meter', {
await this.extendObject('meter', {
type: 'device',
common: {
name: 'device meter'
},
native: {}
});
await this.extendObjectAsync('collected', {
await this.extendObject('collected', {
type: 'channel',
common: {
name: 'channel collected'
},
native: {}
});

await this.extendObjectAsync('inverter', {
await this.extendObject('inverter', {
type: 'device',
common: {
name: 'device inverter'
Expand All @@ -101,7 +101,7 @@ class Sun2000 extends utils.Adapter {
if (item.driverClass == driverClasses.inverter) {
const path = 'inverter.'+item.index.toString();
item.path = path;
await this.extendObjectAsync(path, {
await this.extendObject(path, {
type: 'channel',
common: {
name: 'channel inverter '+item.index.toString(),
Expand All @@ -110,15 +110,15 @@ class Sun2000 extends utils.Adapter {
native: {}
});

await this.extendObjectAsync(path+'.grid', {
await this.extendObject(path+'.grid', {
type: 'channel',
common: {
name: 'channel grid'
},
native: {}
});

await this.extendObjectAsync(path+'.info', {
await this.extendObject(path+'.info', {
type: 'channel',
common: {
name: 'channel info',
Expand All @@ -127,23 +127,23 @@ class Sun2000 extends utils.Adapter {
native: {}
});

await this.extendObjectAsync(path+'.battery', {
await this.extendObject(path+'.battery', {
type: 'channel',
common: {
name: 'channel battery'
},
native: {}
});

await this.extendObjectAsync(path+'.string', {
await this.extendObject(path+'.string', {
type: 'channel',
common: {
name: 'channel string'
},
native: {}
});

await this.extendObjectAsync(path+'.derived', {
await this.extendObject(path+'.derived', {
type: 'channel',
common: {
name: 'channel derived'
Expand All @@ -154,7 +154,7 @@ class Sun2000 extends utils.Adapter {

if (item.driverClass == driverClasses.sdongle) {
item.path = '';
await this.extendObjectAsync(item.path+'sdongle', {
await this.extendObject(item.path+'sdongle', {
type: 'device',
common: {
name: 'device SDongle'
Expand All @@ -166,7 +166,7 @@ class Sun2000 extends utils.Adapter {
//v0.5.x
if (item.driverClass == driverClasses.logger) {
item.path = '';
await this.extendObjectAsync(item.path+'slogger', {
await this.extendObject(item.path+'slogger', {
type: 'device',
common: {
name: 'device SmartLogger'
Expand Down Expand Up @@ -295,7 +295,7 @@ class Sun2000 extends utils.Adapter {
this.logger.warn('Please check your configuration!');
}
}
await this.setStateAsync('info.modbusUpdateInterval', {val: newHighInterval, ack: true});
await this.setState('info.modbusUpdateInterval', {val: newHighInterval, ack: true});
}

/**
Expand All @@ -308,13 +308,13 @@ class Sun2000 extends utils.Adapter {
this.config.timeout = this.config.timeout*1000;
this.updateConfig(this.config);
}
await this.setStateAsync('info.ip', {val: this.config.address, ack: true});
await this.setStateAsync('info.port', {val: this.config.port, ack: true});
await this.setStateAsync('info.modbusIds', {val: this.config.modbusIds, ack: true});
await this.setStateAsync('info.modbusTimeout', {val: this.config.timeout, ack: true});
await this.setStateAsync('info.modbusConnectDelay', {val: this.config.connectDelay, ack: true});
await this.setStateAsync('info.modbusDelay', {val: this.config.delay, ack: true});
await this.setStateAsync('info.modbusTcpServer', {val: this.config.ms_active, ack: true});
await this.setState('info.ip', {val: this.config.address, ack: true});
await this.setState('info.port', {val: this.config.port, ack: true});
await this.setState('info.modbusIds', {val: this.config.modbusIds, ack: true});
await this.setState('info.modbusTimeout', {val: this.config.timeout, ack: true});
await this.setState('info.modbusConnectDelay', {val: this.config.connectDelay, ack: true});
await this.setState('info.modbusDelay', {val: this.config.delay, ack: true});
await this.setState('info.modbusTcpServer', {val: this.config.ms_active, ack: true});
// Load user settings
if (this.config.address != '' && this.config.port > 0 && this.config.modbusIds != '' && this.config.updateInterval > 0 ) {
this.settings.address = this.config.address;
Expand All @@ -341,9 +341,9 @@ class Sun2000 extends utils.Adapter {
this.settings.cb.tou = this.config.cb_tou;

if (this.settings.modbusAdjust) {
await this.setStateAsync('info.JSONhealth', {val: '{message: "Adjust modbus settings"}', ack: true});
await this.setState('info.JSONhealth', {val: '{message: "Adjust modbus settings"}', ack: true});
} else {
await this.setStateAsync('info.JSONhealth', {val: '{message : "Information is collected"}', ack: true});
await this.setState('info.JSONhealth', {val: '{message : "Information is collected"}', ack: true});
}

if (this.settings.modbusIds.length > 0 && this.settings.modbusIds.length < 6) {
Expand Down Expand Up @@ -443,7 +443,7 @@ class Sun2000 extends utils.Adapter {
if (this.isConnected !== lastIsConnected ) this.setState('info.connection', this.isConnected, true);
if (!this.settings.modbusAdjust) {
if (!this.isConnected) {
this.setStateAsync('info.JSONhealth', {val: '{errno:1, message: "Can\'t connect to inverter"}', ack: true});
this.setState('info.JSONhealth', {val: '{errno:1, message: "Can\'t connect to inverter"}', ack: true});
}
const ret = this.state.CheckReadError(this.settings.lowInterval*2);
const obj = {...ret,modbus: {...this.modbusClient.info}};
Expand All @@ -453,7 +453,7 @@ class Sun2000 extends utils.Adapter {
// after 2 Minutes
if (this.alreadyRunWatchDog) {
if (ret.errno) this.logger.warn(ret.message);
this.setStateAsync('info.JSONhealth', {val: JSON.stringify(obj), ack: true});
this.setState('info.JSONhealth', {val: JSON.stringify(obj), ack: true});
if (this.modbusServer) {
!this.modbusServer.isConnected && this.modbusServer.connect();
if (this.settings.ms.log) {
Expand All @@ -471,7 +471,7 @@ class Sun2000 extends utils.Adapter {
this.lastStateUpdatedHigh = 0;

if (sinceLastUpdate > this.settings.highInterval*10) {
this.setStateAsync('info.JSONhealth', {val: '{errno:2, message: "Internal loop error"}', ack: true});
this.setState('info.JSONhealth', {val: '{errno:2, message: "Internal loop error"}', ack: true});
this.logger.warn('watchdog: restart Adapter...');
this.restart();
}
Expand Down
Loading

0 comments on commit 2277d55

Please sign in to comment.