node-red-contrib-ewelink icon indicating copy to clipboard operation
node-red-contrib-ewelink copied to clipboard

Limit 6 devices

Open E1cid opened this issue 5 years ago • 24 comments

E1cid avatar Dec 30 '19 15:12 E1cid

Hi thank you for your efforts.

While trying to implement a dynamic flow i came across a limitation. It seems you can only connect six devices on a single account. to connect more you have to use another account. Also generic device do not produce a response object

E1cid avatar Dec 30 '19 15:12 E1cid

Hello @E1cid,

Are you getting an "Authentication error" or a "Service Temporary Unavailable"? (https://github.com/ottoszika/node-red-contrib-ewelink/issues/74)

Thanks, Otto

ottoszika avatar Dec 30 '19 20:12 ottoszika

i got the service temp unavailable in html format. As i said it happens after the 6th device. i workred around it by add multiple accounts and sharing devices.

E1cid avatar Dec 30 '19 20:12 E1cid

Ditto. #503 temporarily unavailable.

rozza-m avatar Apr 20 '20 15:04 rozza-m

Im having disconected error after some hours, already shared my devices with 3 accounts but the error still appears, only 2 devices are connected per account the 6 devices can be all shared between accounts? or just the 6 of them?

bmgmo-iscteiulpt avatar Jun 04 '20 16:06 bmgmo-iscteiulpt

I share all my devices with other accounts, just found that easier. I find that you can not log in on mobile app without the ewelink nodes losing connection. I therefore use one account for mobile app and other accounts for node-red.

E1cid avatar Jun 04 '20 18:06 E1cid

Yes I created 2 extra accounts just for node-red but I still loose the connection , only 2 devices per account stay connected

From: E1cidmailto:[email protected] Sent: 4 de junho de 2020 19:30 To: ottoszika/node-red-contrib-ewelinkmailto:[email protected] Cc: Bruno Miguel Matalotomailto:[email protected]; Commentmailto:[email protected] Subject: Re: [ottoszika/node-red-contrib-ewelink] Limit 6 devices (#77)

I share all my devices with other accounts, just found that easier. I find that you can not log in on mobile app without the ewelink nodes losing connection. I therefor use one account for mobile app and other accounts for node-red.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ottoszika/node-red-contrib-ewelink/issues/77#issuecomment-639032674, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHZRDZQWSPTEXVDQBFVSKO3RU7R4RANCNFSM4KBNYW4Q.

bmgmo-iscteiulpt avatar Jun 04 '20 18:06 bmgmo-iscteiulpt

Are they devices or listeners?

E1cid avatar Jun 04 '20 18:06 E1cid

All devices and just 1 listener

Com os melhores cumprimentos, Bruno Mataloto, nº70082 DCTI


From: E1cid [email protected] Sent: Thursday, June 4, 2020 7:33:19 PM To: ottoszika/node-red-contrib-ewelink [email protected] Cc: Bruno Miguel Mataloto [email protected]; Comment [email protected] Subject: Re: [ottoszika/node-red-contrib-ewelink] Limit 6 devices (#77)

Are they devices or listeners?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ottoszika/node-red-contrib-ewelink/issues/77#issuecomment-639034542, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHZRDZQTUFHAMWJZBSQNYC3RU7SG7ANCNFSM4KBNYW4Q.

bmgmo-iscteiulpt avatar Jun 04 '20 18:06 bmgmo-iscteiulpt

Same as my set up, i am not seeing any issues. Have you tried restarting the node_red server? I have 12 devices over 2 accounts and a listener on its own account.

E1cid avatar Jun 04 '20 19:06 E1cid

The listener should be in a separate account?

Com os melhores cumprimentos, Bruno Mataloto, nº70082 DCTI


From: E1cid [email protected] Sent: Thursday, June 4, 2020 8:28:10 PM To: ottoszika/node-red-contrib-ewelink [email protected] Cc: Bruno Miguel Mataloto [email protected]; Comment [email protected] Subject: Re: [ottoszika/node-red-contrib-ewelink] Limit 6 devices (#77)

Same as my set up, i am not seeing any issues. Have you tried restarting the node_red server? I have 12 devices over 2 accounts and a listener on its own account.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ottoszika/node-red-contrib-ewelink/issues/77#issuecomment-639068985, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHZRDZUBHMILABST67QFDODRU7YUVANCNFSM4KBNYW4Q.

bmgmo-iscteiulpt avatar Jun 04 '20 20:06 bmgmo-iscteiulpt

I don't think it has to be, but mine is.

E1cid avatar Jun 04 '20 20:06 E1cid

I am afraid I am still stucking on 401 authorizatio error issue. You have mentioned in previous conversations that you have made a global connection which use 1 login at the same time, but I did not find how to do it. Or - Is there a chance for example to specify deviceId as a node property over a JSON format in msg.payload? It could solve the problem as we will have only 1 node for switch on and off and deviceId we want to switch will be in msg.payload......

netgame123 avatar Aug 05 '20 17:08 netgame123

Here I have same issue, even after paid "Annual Advanced subscription"

sergey08 avatar Sep 29 '20 19:09 sergey08

I keep having 6 account limit. I shared the devices over 3 accounts (owner + 2 shared) but always only 6 nodes connected, no matter which account I use. Other nodes return: FetchError: invalid json response body at https://eu-api.coolkit.cc:8080/api/user/login reason: Unexpected token < in JSON at position 0

P.S.: I'm glad to try to help with the code if someone give me some hint about where to start.

1101101011011110 avatar Dec 01 '20 11:12 1101101011011110

Hi all,

I have found a solution to read Ewelink devices status, doest matter how many.

I have used Devices node to read all devices status, and after filtering any of them

image

To send a command to Ewelink I am using IFTTT

sergey08 avatar Dec 01 '20 13:12 sergey08

Hi all,

I have found a solution to read Ewelink devices status, doest matter how many.

I have used Devices node to read all devices status, and after filtering any of them

image

To send a command to Ewelink I am using IFTTT

Hi sergey08, that's smart. If we get an equivalent method to write status, we can solve every situation. Nonetheless, it would be nice to have the nodes working as they are now!

1101101011011110 avatar Dec 01 '20 14:12 1101101011011110

Node palette has an update 5 days ago!!!

Version 2.0

https://flows.nodered.org/node/node-red-contrib-ewelink

Maybe fix it

sergey08 avatar Dec 01 '20 16:12 sergey08

IMHO lib should use serverless mode: saving token and reuse it. Other thing I noticed is that if you send many commands at the same time (to different sonoff devices) they will fail. May be it is a similar problem for connection?

P.S: I'm using the latest version.

1101101011011110 avatar Dec 08 '20 22:12 1101101011011110

I managed to overcome the limit of 6 devices making a connection pool and reusing them when needed. I just modified the 'ready' promise function in file ewelink-connect.js like this:

ready (RED, node, config)  {
  // Get credentials node
  const credentialsNode = RED.nodes.getNode(config.auth);

  // Check for valid credential node
  if (!credentialsNode) {
    throw new Error('No credentials provided!');
  }

  // Set the node status to 'connecting'
  this.setNodeStatusToConnecting(node);

  if (globalThis.connectionPool == undefined)
    globalThis.connectionPool = [];
  
  // search for stored connection(Promise) in global array
  for (let storedConnection of globalThis.connectionPool) {
    if (storedConnection.credential == config.auth) {
      this.setNodeStatusToConnected(node);
      return storedConnection.connection;
    }
  }

  let connectionPromise = new Promise((resolve, reject) => {
    
    credentialsNode.connection.getCredentials().then(response => {
      if (response.error) {
        this.setNodeStatusToDisconnected(node);
        return reject(response);
      }
      
      this.setNodeStatusToConnected(node);
      return resolve (credentialsNode.connection);
    })
    .catch(error => {
      this.setNodeStatusToDisconnected (node);
      reject(error);
    });
  });
  
  let newConnection = {
    credential: config.auth,
    connection: connectionPromise
  };
  globalThis.connectionPool.push(newConnection); //append to global array for reuse
  
  return connectionPromise;
}

I'm a beginner with js so maybe this is not the best solution. Anyway it works on my setup. I'm happy to elaborate it in a better way if someone points me in the right direction.

1101101011011110 avatar Jan 06 '21 11:01 1101101011011110

Very interesting. Good job!!!

Look works!!!!!

I have found ewelink-connect.js in the path /.node-red/node_modules/node-red-contrib-ewelink/src/utils Is this file the one we have to edit?

I have tried and I think you miss a , at the end

.... }; globalThis.connectionPool.push(newConnection); //append to global array for reuse

return connectionPromise; },

That the only way node keep working for me.

Thanks a lot!!!!

sergey08 avatar Jan 06 '21 21:01 sergey08

Very interesting. Good job!!!

Look works!!!!!

I have found ewelink-connect.js in the path /.node-red/node_modules/node-red-contrib-ewelink/src/utils Is this file the one we have to edit?

I have tried and I think you miss a , at the end

.... }; globalThis.connectionPool.push(newConnection); //append to global array for reuse

return connectionPromise; },

That the only way node keep working for me.

Thanks a lot!!!!

I confirm, the file is that one. And you're right about the comma at the end. Sorry, it wasn't clear.

1101101011011110 avatar Jan 06 '21 21:01 1101101011011110

I also confirm this works perfectly, is there any reason this is not included in the codebase?

Great work @1101101011011110 , thank you very much!

Thank you @nareso for pointing this in another issue.

javiermarasco avatar May 10 '22 07:05 javiermarasco

Hallo zusammen, habe auch versucht oben genannten code zu verwenden. Leider habe ich immer noch das Problem das mindestens 2 meiner 8 Geräte als nicht conncted angezeigt werden. Was aber lustig ist..... 1 Gerät ist definiv offline da nicht eingesteckt wird aber manchmal als connected angezeigt?

einfach113 avatar Feb 25 '23 11:02 einfach113