Skip to content

Commit

Permalink
version 0.0.4
Browse files Browse the repository at this point in the history
* implement state change submits
* fix automated testing
* updated dependencys
  • Loading branch information
Dutchman committed Mar 14, 2019
1 parent 1d067b8 commit 12ecc35
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 967 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "multicast",
"version": "0.0.1",
"version": "0.0.4",
"news": {
"0.0.1": {
"en": "initial release",
Expand Down
24 changes: 15 additions & 9 deletions main.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ class Multicast extends utils.Adapter {
// To-Do : Implement cache for case JSON does not contain configuration data
const config = Object.keys(received_data.c);
for (const i in config){
const writable = true;

// Create state in info channel
this.createChannel(statename, "Config");

const writable = true;

// Define if state must be part of channel and create state name
let stateCreateName = statename + ".Config." + config[i];
this.log.info("stateCreateName before if : " + stateCreateName);
Expand Down Expand Up @@ -167,6 +166,12 @@ class Multicast extends utils.Adapter {
this.doStateCreate(stateCreateName, config[i] , received_data.c[config[i]].t, received_data.c[config[i]].r,received_data.c[config[i]].u, writable, min, max);
this.setState(stateCreateName, { val: received_data.c[config[i]].v,ack: true});

// if state has writable flag yes, subscribe on changes
if (writable === true) {
this.subscribeStates(stateCreateName);
this.log.debug("State subscribed!: "+ stateCreateName);
}

}

// Create states for all values received in JSON
Expand Down Expand Up @@ -316,18 +321,19 @@ class Multicast extends utils.Adapter {
//@ts-ignore ack is never null
if (state.ack === false) {
const deviceId = id.split(".");
const stateNameToSend = deviceId[3];
let stateNameToSend = "";
for (const i=3; i <= deviceId.length-1; i++) {
stateNameToSend += deviceId[i];
if(i < (deviceId.length -1)) stateNameToSend += ".";

this.log.warn("statename: "+stateNameToSend);
}
const objekt = await this.getObjectAsync(deviceId[2]);
this.log.debug("AsyncObject received while StateChange: " + JSON.stringify(objekt));
const sendMessage = {
//@ts-ignore objekt is not empty
i : objekt.common,
s : {
[stateNameToSend] : {
//@ts-ignore state is not empty
value : state.val
}
}
s : {[stateNameToSend] : state.val} //@ts-ignore state is not empty
};
// message here !
this.transmit(JSON.stringify(sendMessage));
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.multicast",
"version": "0.0.1",
"version": "0.0.4",
"description": "Receive and sent multicast information",
"author": {
"name": "Dutchman & Andiling",
Expand All @@ -26,7 +26,7 @@
"@types/chai-as-promised": "^7.1.0",
"@types/gulp": "^4.0.6",
"@types/mocha": "^5.2.6",
"@types/node": "^10.12.30",
"@types/node": "^10.14.1",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^7.0.9",
"@types/sinon-chai": "^3.2.2",
Expand Down
5 changes: 5 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = require("path");
const { tests } = require("@iobroker/testing");

// Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.integration(path.join(__dirname, ".."));
Loading

0 comments on commit 12ecc35

Please sign in to comment.