[EDGE] [ALPHA] Ewelink LAN control using edge driver

I am not making much progress.

The individual ewelink devices have shown up in the mobile app but I need the “Device Keys”

I down loaded ewelink.js

Ran your script in Power Shell and get the following error:

As you can see I am clue less about this process.

my Node version is Node.js v20.6.1. Would it possible for you to upgrade? crypto libraries are best used when bundled in the framework.

I’m using v20.6.1, this is what I’m seeing -

node:internal/deps/undici/undici:11600

Error.captureStackTrace(err, this);

      ^

TypeError: Failed to parse URL from undefined/v2/user/login

at Object.fetch (node:internal/deps/undici/undici:11600:11)

at async login (C:\Users\diese\ewelink.js:46:20) {

[cause]: TypeError [ERR_INVALID_URL]: Invalid URL

  at new NodeError (node:internal/errors:405:5)

  at new URL (node:internal/url:778:13)

  at new Request (node:internal/deps/undici/undici:7150:25)

  at fetch2 (node:internal/deps/undici/undici:10737:25)

  at Object.fetch (node:internal/deps/undici/undici:11598:18)

  at fetch (node:internal/process/pre_execution:274:25)

  at login (C:\Users\diese\ewelink.js:46:26) {

input: 'undefined/v2/user/login',

code: 'ERR_INVALID_URL'

}

}

You have to pass region as well. one of us, eu, as, or cn. url is prefixed for different regions

Thanks, yep this included correct region “eu”

The code is actually only few lines. The code uses this

API[region] + "/v2/user/login"

where

 const API = {
    "cn": "https://cn-apia.coolkit.cn",
    "as": "https://as-apia.coolkit.cc",
    "us": "https://us-apia.coolkit.cc",
    "eu": "https://eu-apia.coolkit.cc",
} 

so I guess region does not go as expected…

Correct, quick question: is it configured for the username to be an email address or a phone number?

I have added some asserts in new code. That should show you error. It works for both phone number and email address. It is a borrowed code logic from GitHub - AlexxIT/SonoffLAN: Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant so should work.

{

error: 400,

msg: ‘“phoneNumber” with value "+Redacted Email Address " fails to match the required pattern: /^\+\d+$/’,

data: {}

}

Ok, Just tried again and now works, Thanks

1 Like

Ok, I updated Node.js to v20.6.1 and I am still getting errors.

error2

Paul, Don’t include < >

1 Like

Making slow progress. With @DieselDaisey help I got the java script to run.

Now I get the following output.

error3

Now my question is what piece of information from the above is the Device Key that I need to enter in the mobile app?

Sorry I forgot to stringify the json output. update the code, please. It will give you string representation inplace of [Object]

1 Like

@Mystifier Have you had a chance to update the code in “ewelink.js”?

I am still getting the same results with the file I just downloaded.

error4

it was changed. perhaps delete and get the file again from https://github.com/bogusfocused/sonoff-edge/blob/main/hub/ewelink.js

Hi, Would it be possible to add RF Bridge, Thanks

RF bridge translates signals from RF to Wifi. I am not sure if it has any meaning within smartthings . What would you be able to do if RF Bridge is added ?

I was kind of hoping it would catch Keyfob presses to use in routines

Interesting. I do not have a RF bridge. To add any device we will have to listen to mDNS broadcasts and if they are encrypted we will have to download the associated device key. I typically work on a linux VM on my windows machine so access all linux tools. I do not know of any good windows mDNS client though a python script can do well. I can mash up a python script to listen to mDNS or look around to find something for windows. maybe you can use avahi on WSL?
mDNS = Zeroconf = Bonjour = DNS-SD