ottoszika / node-red-contrib-ewelink

NodeRED nodes for eWeLink smart devices
https://ottoszika.github.io/node-red-contrib-ewelink
MIT License
48 stars 28 forks source link

Add deviceId as an message input parameter #115

Open ckhmer1 opened 3 years ago

ckhmer1 commented 3 years ago

Hi, first of all, thanks for your great job. I'd like to specify the deviceId inside the message sent to the node and not always inside the node itself, like msg.deviceId= ..... It should is a simple fix, in ewelink-connect.js, just replaced the row:

    evaluatedParams.unshift(deviceId);
    // First parameter should be always the device ID

with following rows:

    let device_id = '';
    if (deviceId) {
      device_id = deviceId;
    } else if (typeof msg.deviceId !== "undefined") {
      device_id = msg.deviceId || '';
    }
    // First parameter should be always the device ID
    evaluatedParams.unshift(device_id);

In this way it the deviceId is not specified inside the node configuration, it will use the one specified inside the message.

Thanks Claudio

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 93


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utils/ewelink-connect.js 4 6 66.67%
<!-- Total: 4 6 66.67% -->
Totals Coverage Status
Change from base Build 84: -4.5%
Covered Lines: 101
Relevant Lines: 105

💛 - Coveralls
ckhmer1 commented 3 years ago

Don't use additional variables, use the same deviceId (you can modify declaration to let instead of const or and you can do all of this inline at line 48).

Done. Is it ok now?