Skip to content

Commit

Permalink
feature: use config to save credentials issue #9
Browse files Browse the repository at this point in the history
fix: Cannot set brightness value on node issue #7
  • Loading branch information
sanlike0911 committed Nov 3, 2021
1 parent 0f15099 commit c113fd6
Show file tree
Hide file tree
Showing 18 changed files with 4,991 additions and 295 deletions.
2,556 changes: 2,437 additions & 119 deletions README.md

Large diffs are not rendered by default.

2,556 changes: 2,437 additions & 119 deletions examples/example-1.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/nodes/tplink_brightness.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: { value: "" },
email: { value: "", required: true },
password: { type: "password", required: true },
deviceIp: { value: "", required: false },
deviceAlias: { value: "", required: false },
deviceIpRange: { value: "", required: false },
searchMode: { value: "ip", required: true }
searchMode: { value: "ip", required: true },
brightness: { value: "", required: false }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs: 1,
outputs: 1,
Expand Down
15 changes: 10 additions & 5 deletions src/nodes/tplink_brightness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const nodeInit: NodeInitializer = (RED): void => {
/**
* tplinkTapoConnectApiConstructor
*
* @param {brightnessType.appNode} this
* @param {any} this
* @param {brightnessType.appNodeDef} config
*/
function tplinkTapoConnectApiConstructor(
this: brightnessType.appNode,
this: any,
config: brightnessType.appNodeDef
): void {
RED.nodes.createNode(this, config);
let node: brightnessType.appNode = this;

try {
node.email = config?.email ?? "";
node.password = config?.password ?? "";
node.email = this?.credentials?.email ?? "";
node.password = this?.credentials?.password ?? "";
node.deviceIp = config?.deviceIp ?? "";
node.deviceAlias = config?.deviceAlias ?? "";
node.deviceIpRange = config?.deviceIpRange ?? "";
Expand Down Expand Up @@ -108,7 +108,12 @@ const nodeInit: NodeInitializer = (RED): void => {
node.send(msg);
});
}
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor);
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor, {
credentials: {
email: { type:"text" },
password: { type:"password" }
}
});
};

export = nodeInit;
6 changes: 4 additions & 2 deletions src/nodes/tplink_colour.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: { value: "" },
email: { value: "", required: true },
password: { type: "password", required: true },
deviceIp: { value: "", required: false },
deviceAlias: { value: "", required: false },
deviceIpRange: { value: "", required: false },
colour: { value: "", required: true },
searchMode: { value: "ip", required: true }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs: 1,
outputs: 1,
align: "left",
Expand Down
16 changes: 11 additions & 5 deletions src/nodes/tplink_colour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const nodeInit: NodeInitializer = (RED): void => {
/**
* tplinkTapoConnectApiConstructor
*
* @param {colourType.appNode} this
* @param {any} this
* @param {colourType.appNodeDef} config
*/
function tplinkTapoConnectApiConstructor(
this: colourType.appNode,
this: any,
config: colourType.appNodeDef
): void {
RED.nodes.createNode(this, config);
let node: colourType.appNode = this;

try {
node.email = config?.email ?? "";
node.password = config?.password ?? "";
node.email = this?.credentials?.email ?? "";
node.password = this?.credentials?.password ?? "";
node.deviceIp = config?.deviceIp ?? "";
node.deviceAlias = config?.deviceAlias ?? "";
node.deviceIpRange = config?.deviceIpRange ?? "";
Expand Down Expand Up @@ -109,7 +109,13 @@ const nodeInit: NodeInitializer = (RED): void => {
node.send(msg);
});
}
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor);
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor, {
credentials: {
email: { type:"text" },
password: { type:"password" }
}
});

};

export = nodeInit;
6 changes: 4 additions & 2 deletions src/nodes/tplink_command.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: { value: "" },
email: { value: "", required: true },
password: { type: "password", required: true },
deviceIp: { value: "", required: false },
deviceAlias: { value: "", required: false },
deviceIpRange: { value: "", required: false },
searchMode: { value: "ip", required: true }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs: 1,
outputs: 1,
align: "left",
Expand Down
15 changes: 10 additions & 5 deletions src/nodes/tplink_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const nodeInit: NodeInitializer = (RED): void => {
/**
* tplinkTapoConnectApiConstructor
*
* @param {commandType.appNode} this
* @param {any} this
* @param {commandType.appNodeDef} config
*/
function tplinkTapoConnectApiConstructor(
this: commandType.appNode,
this: any,
config: commandType.appNodeDef
): void {
RED.nodes.createNode(this, config);
let node: commandType.appNode = this;

try {
node.email = config?.email ?? "";
node.password = config?.password ?? "";
node.email = this?.credentials?.email ?? "";
node.password = this?.credentials?.password ?? "";
node.deviceIp = config?.deviceIp ?? "";
node.deviceAlias = config?.deviceAlias ?? "";
node.deviceIpRange = config?.deviceIpRange ?? "";
Expand Down Expand Up @@ -187,7 +187,12 @@ const nodeInit: NodeInitializer = (RED): void => {
node.send(msg);
});
}
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor);
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor, {
credentials: {
email: { type:"text" },
password: { type:"password" }
}
});
};

export = nodeInit;
6 changes: 4 additions & 2 deletions src/nodes/tplink_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: { value: "" },
email: { value: "", required: true },
password: { type: "password", required: true },
deviceIp: { value: "", required: false },
deviceAlias: { value: "", required: false },
deviceIpRange: { value: "", required: false },
searchMode: { value: "ip", required: true }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs: 1,
outputs: 1,
align: "left",
Expand Down
15 changes: 10 additions & 5 deletions src/nodes/tplink_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const nodeInit: NodeInitializer = (RED): void => {
/**
* tplinkTapoConnectApiConstructor
*
* @param {statusType.appNode} this
* @param {any} this
* @param {statusType.appNodeDef} config
*/
function tplinkTapoConnectApiConstructor(
this: statusType.appNode,
this: any,
config: statusType.appNodeDef
): void {
RED.nodes.createNode(this, config);
let node: statusType.appNode = this;

try {
node.email = config?.email ?? "";
node.password = config?.password ?? "";
node.email = this?.credentials?.email ?? "";
node.password = this?.credentials?.password ?? "";
node.deviceIp = config?.deviceIp ?? "";
node.deviceAlias = config?.deviceAlias ?? "";
node.deviceIpRange = config?.deviceIpRange ?? "";
Expand Down Expand Up @@ -106,7 +106,12 @@ const nodeInit: NodeInitializer = (RED): void => {
node.send(msg);
});
}
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor);
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor, {
credentials: {
email: { type:"text" },
password: { type:"password" }
}
});
};

export = nodeInit;
6 changes: 4 additions & 2 deletions src/nodes/tplink_tapo_connect_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: {value:""},
email: {value:"", required: true },
password: { type: "password", required: true },
deviceIp: {value:"", required: false },
deviceAlias: {value:"", required: false },
deviceIpRange: {value:"", required: false },
mode:{value:"command", required: true }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs:1,
outputs:1,
align: "left",
Expand Down
17 changes: 12 additions & 5 deletions src/nodes/tplink_tapo_connect_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { tplinkTapoConnectWrapper, tplinkTapoConnectWrapperType } from "./tplink

const nodeInit: NodeInitializer = (RED): void => {

const REGISTER_TYPE: string = 'tplink_tapo_connect_api';

/**
* checkParameter
*
Expand All @@ -25,19 +27,19 @@ const nodeInit: NodeInitializer = (RED): void => {
/**
* tplinkTapoConnectApiConstructor
*
* @param {tplinkTapoConnectApiType.appNode} this
* @param {any} this
* @param {tplinkTapoConnectApiType.appNodeDef} config
*/
function tplinkTapoConnectApiConstructor(
this: tplinkTapoConnectApiType.appNode,
this: any,
config: tplinkTapoConnectApiType.appNodeDef
): void {
RED.nodes.createNode(this, config);
let node: tplinkTapoConnectApiType.appNode = this;

try {
node.email = config?.email ?? "";
node.password = config?.password ?? "";
node.email = this?.credentials?.email ?? "";
node.password = this?.credentials?.password ?? "";
node.deviceIp = config?.deviceIp ?? "";
node.deviceAlias = config?.deviceAlias ?? "";
node.deviceIpRange = config?.deviceIpRange ?? "";
Expand Down Expand Up @@ -177,7 +179,12 @@ const nodeInit: NodeInitializer = (RED): void => {
node.send(msg);
});
}
RED.nodes.registerType('tplink_tapo_connect_api', tplinkTapoConnectApiConstructor);
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor, {
credentials: {
email: { type:"text" },
password: { type:"password" }
}
});
};

export = nodeInit;
6 changes: 4 additions & 2 deletions src/nodes/tplink_toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: { value: "" },
email: { value: "", required: true },
password: { type: "password", required: true },
deviceIp: { value: "", required: false },
deviceAlias: { value: "", required: false },
deviceIpRange: { value: "", required: false },
searchMode: { value: "ip", required: true }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs: 1,
outputs: 1,
align: "left",
Expand Down
15 changes: 10 additions & 5 deletions src/nodes/tplink_toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const nodeInit: NodeInitializer = (RED): void => {
/**
* tplinkTapoConnectApiConstructor
*
* @param {toggleType.appNode} this
* @param {any} this
* @param {toggleType.appNodeDef} config
*/
function tplinkTapoConnectApiConstructor(
this: toggleType.appNode,
this: any,
config: toggleType.appNodeDef
): void {
RED.nodes.createNode(this, config);
let node: toggleType.appNode = this;

try {
node.email = config?.email ?? "";
node.password = config?.password ?? "";
node.email = this?.credentials?.email ?? "";
node.password = this?.credentials?.password ?? "";
node.deviceIp = config?.deviceIp ?? "";
node.deviceAlias = config?.deviceAlias ?? "";
node.deviceIpRange = config?.deviceIpRange ?? "";
Expand Down Expand Up @@ -160,7 +160,12 @@ const nodeInit: NodeInitializer = (RED): void => {
node.send(msg);
});
}
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor);
RED.nodes.registerType(REGISTER_TYPE, tplinkTapoConnectApiConstructor, {
credentials: {
email: { type:"text" },
password: { type:"password" }
}
});
};

export = nodeInit;
6 changes: 4 additions & 2 deletions src/nodes/tplink_turn_off.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
color: 'rgb( 63, 173, 181)',
defaults: {
name: { value: "" },
email: { value: "", required: true },
password: { type: "password", required: true },
deviceIp: { value: "", required: false },
deviceAlias: { value: "", required: false },
deviceIpRange: { value: "", required: false },
searchMode: { value: "ip", required: true }
},
credentials: {
email: { type:"text" },
password: { type:"password" }
},
inputs: 1,
outputs: 1,
align: "left",
Expand Down
Loading

0 comments on commit c113fd6

Please sign in to comment.