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

Limit 6 devices #77

Open E1cid opened 4 years ago

E1cid commented 4 years ago

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

ottoszika commented 4 years ago

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

E1cid commented 4 years ago

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.

rozza-m commented 4 years ago

Ditto. #503 temporarily unavailable.

bmgmo-iscteiulpt commented 4 years ago

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?

E1cid commented 4 years ago

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.

bmgmo-iscteiulpt commented 4 years ago

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:notifications@github.com Sent: 4 de junho de 2020 19:30 To: ottoszika/node-red-contrib-ewelinkmailto:node-red-contrib-ewelink@noreply.github.com Cc: Bruno Miguel Matalotomailto:Bruno_Mataloto@iscte-iul.pt; Commentmailto:comment@noreply.github.com 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.

E1cid commented 4 years ago

Are they devices or listeners?

bmgmo-iscteiulpt commented 4 years ago

All devices and just 1 listener

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


From: E1cid notifications@github.com Sent: Thursday, June 4, 2020 7:33:19 PM To: ottoszika/node-red-contrib-ewelink node-red-contrib-ewelink@noreply.github.com Cc: Bruno Miguel Mataloto Bruno_Mataloto@iscte-iul.pt; Comment comment@noreply.github.com 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.

E1cid commented 4 years ago

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.

bmgmo-iscteiulpt commented 4 years ago

The listener should be in a separate account?

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


From: E1cid notifications@github.com Sent: Thursday, June 4, 2020 8:28:10 PM To: ottoszika/node-red-contrib-ewelink node-red-contrib-ewelink@noreply.github.com Cc: Bruno Miguel Mataloto Bruno_Mataloto@iscte-iul.pt; Comment comment@noreply.github.com 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.

E1cid commented 4 years ago

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

netgame123 commented 3 years ago

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......

sergey08 commented 3 years ago

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

1101101011011110 commented 3 years ago

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.

sergey08 commented 3 years ago

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

1101101011011110 commented 3 years ago

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!

sergey08 commented 3 years ago

Node palette has an update 5 days ago!!!

Version 2.0

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

Maybe fix it

1101101011011110 commented 3 years ago

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 commented 3 years ago

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.

sergey08 commented 3 years ago

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!!!!

1101101011011110 commented 3 years ago

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.

javiermarasco commented 2 years ago

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.

einfach113 commented 1 year ago

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?