Jump to content

paulcb

Members
  • Posts

    4
  • Joined

  • Last visited

  • Days Won

    1

paulcb last won the day on May 30 2023

paulcb had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

paulcb's Achievements

  1. Hi. To be honest the answer is that I was not aware of anything that could do this. If there is a simpler solution to control Sonoff switches based on Sunsynk data then please so share here for anyone who comes across this. I did some basic searching and didn't find anything hence the DIY solution.
  2. Ok sure. Here goes. This assumes you know some basic linux. If not maybe this is not for you but perhaps I can help if needed: 1) Make sure your Sunsynk connect App is working and you know your username/password. 2) Make sure your Sonoff switches are working in the Ewelink app and you know your username/password. 3) Fire up an Ubuntu VM on AWS/Azure/GCP or even on a Pi or home PC. It can be really small like 512MB RAM and needs internet access 4) Install docker in the linux vm. Follow something like this: https://kinsta.com/blog/install-docker-ubuntu/ 5) Someone wrote a nodejs gateway to mimic the calls done by the Ewelink App see: https://github.com/DoganM95/Ewelink-Rest-Api-Server I leverage this as a way to control the Sonoff Switches. To run this listening on port 8089 run this. It needs your Ewelink username/password you registered in the App so it can call into Ewelink servers: docker run -d --restart=always -p 8089:3000 -e "EWELINK_USERNAME=yourusername" -e "EWELINK_PASSWORD=yourpassword" -e "EWELINK_REGION=eu" -e "PASSWORD_HASHING_ALGORITHM=sha512" -e "SERVER_MODE=prod" doganm95/ewelink-rest-api-server 6) Test you can turn a switch on like this (Replace "Your Switch Name" with the switch name as it appears in the Ewelink App): curl -m20 -sX POST "http://localhost:8089" -H "content-type: application/json" -d"{\"devicenameincludes\":[\"Your Switch Name\"],\"params\":{\"switch\":\"on\"}}" 7) Install a json parser utility: sudo apt install jq 8. In your home folder add the attached script.sh and make it executable with chmod +x ./script.sh 9) In the script set your Sunsynk connect username and password on rows 4 & 5 for SUNSYNK_USER and SUNSYNK_PASS. Then set SUNSYNK_PLANT on row 6 with the plant ID you see if you login to sunsynk connect in your browser. E.g. mine is 88663: 9) Create a cron schedule to run the script every 5 minutes: crontab -e -> then add a row like this: */5 * * * * /home/ubuntu/script.sh >> /home/ubuntu/solar.log 10) Edit the script to suit your needs and refer to your Sonoff switch names. I've got a simple example of a switch called "My Switch" that will turn on if we have excess power and Off if we don't. If you don't know what going on, ping me with your switch names and basic rules and I can help. You have a huge amount of control. I have some fairly complex rules around hour of day etc. 11) To see what the script is doing, run tail -f /home/ubuntu/solar.log I'd love it if this is useful to anyone so let me know if you need help and add any things I might have missed to make the instructions foolproof. My script generates a basic HTML page of the current status but I deleted that part as it just makes the script more complex than necessary. Anyone with basic bash scripting can go wild. If you comfortable with python or something else then use that - its really just some HTTP GET and POST commands surrounded with JSON parsing. script.sh
  3. After some experimenting, I've come up with a reliable way to turn various Sonoff Switches on/off based on current Sunsynk stats such as SOV, Grid load, Solar generation, time of day etc. It even has a simple dashboard I'm displaying on an old phone stuck to the wall so that the family knows when is a good time to fire up the washing machine, dishwasher etc. I have various rules (in a bash script) that looks at the Sunsynk stats every 5 minutes and takes decisions on what to turn on/off based on current conditions. This is especially useful if like me you have the entire house on essential load and want fine-grained control of where excess power is used, while minimising Eskom usage. Sonoff switches are like R150 so it does not break the bank to add this level of automation. For the geyser, I have a 20A Sonoff which is a bit more but not crazy price. In my basic searching, I'm not sure if anyone has done this before as I have seen posts about waiting for the Sunsynk smart switch to do this kind of thing. If this is novel and people would like to know how to get this right, please let me know and I'll do a write up. I didn't want to do a long post, only to find that I've reinvented the wheel.
  4. What was the solution exactly? What cable did u end up using?
×
×
  • Create New...