Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for myStrom Switch #3

Open
JK40105 opened this issue Nov 2, 2019 · 0 comments
Open

Suggestion for myStrom Switch #3

JK40105 opened this issue Nov 2, 2019 · 0 comments

Comments

@JK40105
Copy link

JK40105 commented Nov 2, 2019

As the myStrom switch node(s) already contain the IP address it would be nice to just only send a request in taskJSON by inserting the following in function myStromSwitch.js:
this.on("input", function(msg) { <= existing line
var taskJSON = msg["payload"] <= existing line
// allow for only receiving a reqest in taskJSON
if (!taskJSON.hasOwnProperty("ip")) {taskJSON.ip = this.device.host};
if (!taskJSON.hasOwnProperty("mac")) {taskJSON.mac = this.device.mac};
By this the same command can be sent to several switch nodes
As the requests 'on' and 'off' do not return an answer from the switch, there always results an error message, but the switch is correctly switching. The error message may be inhibited by faking a return message in function requests.js:
var http = require("http"); <= existing line
var body = ""; <= existing line
// 'on' and 'off' requests for a switch do not send a response
if (type === "switch") {
if (taskJSON.request === "on") {body = "ON sent"};
if (taskJSON.request === "off") {body = "OFF sent"};
};

Please see these as friendly suggestions, I know that there may be better solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant