I want to bring control of some large loads via eWeLink switches into existing Node-RED flows of mine on the Cerbo GX…the switches are CoolKit ones - model CK-BL602-W102SW18-01…no matter what I try I run into brick walls and am looking for someone to set me on the right path here please
The old stuff (node-red-contrib-ewelink) has been broken by design as they moved to OAuth 2.0, then the easier to use fix to put in support for that (node-red-contrib-ewelink-apikey) has no public codebase and gets permission problems (error 407 meaning the cloud servers are blocking it functioning), then the properly (or at least partially) documented and community supported one (@floflal/node-red-ewelink-v2-oauth) falls in a heap because of locked down permissions in the Venus OS Large Node-RED implementation preventing creation of a “logs” directory amongst a host of other errors that mostly seem to relate to restrictions on the nodered user and the design of the Venus file system.
I accept that these switches do not support LAN mode and have to be controlled via the cloud, I have gotten myself set up as an eWeLink Developer and created my AppID and App Secret, I believe I’ve even managed to figure out getting the Node-RED authorization trick in the last pallete item mentioned to work via the arcane call back to the Node-RED self-hosted web-page made for the purpose of catching the redirect, but I can’t move forward and I just keep going around in circles through the same few community posts and documents in various places that may or may not hold the right clues.
I don’t have Home Assistant and don’t have a suitable piece of hardware to run it on to port all this over to and start using tools designed for HA to get around this. I don’t have the Sonoff iHost or any way to use eWeLink CUBE either. I could probably figure out how to call the API direct from scripts on the Cerbo, but it would be kludgy because my long ago programming chops were never in Linux and Python and Bash, and I wouldn’t have a clue then how to build the Node-RED stuff to interface to all that.
Is there anyone who can point the way please?
Well I’m still pretty stuck but I have made some progress which it seems worthwhile to share: I’ve managed to edit one of the .js files in my locally running copy of @floflal/node-red-ewelink-v2-oauth to substitute the console for the originally used call to ewelink-api-next’s createLogger function and that enables the rest of the package to work up to the point that I have my authentication token and am successfully able to read the status of a switch. I’m still not able to set the status (I get error 4002 when trying along with Chinese characters that apparently translate to “control failure”) and the documentation for the package does not clearly explain how to retrieve the required apikey for the coolkit interfaces which is a necessary property to make the Event Messages node work so I’m not getting far on trying to listen out on a websocket for events either…
Update: very shortly after this I figured out that the apikey is actually associated with the home in eWeLink and can be read off the results from either of the two multiple result nodes I hadn’t tried using yet because I was focused on getting a single device to work…so now in theory the Event Messages node could work although in practice it’s giving a 401 error that authentication failed
Update again: have the event listening working…I’m using the recommended approach of a second account with eWeLink to allow the flows to co-exist with the primary app account as otherwise the app being in use would conflict with the use of the api for this, as evidenced by the 401 error a little earlier. Using the apikey associated with the default home on the secondary profile rather than on the one shared to it from my main profile appears to work for listening to events from the shared home - ie. these keys appear more associated to the owning accounts than the homes themselves.
Update yet again: And finally I have updating statuses working and can control my switches…all examples I can find use the string “on” in the parameter json but this device (UIID 226) requires an unquoted true or false for the “switch” parameter. I will continue with my project and come back at some point soon I hope to clean this up and post it as a solution…if any of the people who’ve been checking the post out without saying anything are interested in getting more detail though, or can motivate me to figure out officially publishing this as a fork of the package for use on the venus version of node-red specifically, now’s your chance to say so…
Last update for now: The Event Messages node is getting more events than I bargained for…it’s even notifying me when other smart devices that have nothing to do with the current project momentarily lose WiFi connectivity so I’m going to be able to proactively respond to conditions that would otherwise prevent my scenes firing correctly. When no specific Device ID is used it listens to everything connected to the original app user’s account as long as the homes are shared in full to the secondary account.