Code Monkey home page Code Monkey logo

ecoflow-powerstream-nodejs's People

Contributors

bogdancs92 avatar flexy2dd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ecoflow-powerstream-nodejs's Issues

[Documentation] How I got this nodejs solution running

Edit 07.09.2023: moved/follow up with documentation for HA Automation in separate place for no longer spamming this repo/issue ;-)

https://github.com/giovanne123/Ecoflow_Powerstream_HomeAssistant_Automation_Documentation/blob/main/README.md


Work in Progress:

For documentation reference for myself and maybe useful for others also (on your own risk ;-)…
Information on how I got this nodejs solution running - some is Quick&Dirty and needs optimization but intention was to get it running and I can test further requirements ;-)

First of all some notes:

  • My main intention, control Powerstream via Home Assistant (ideally directly in local network – but seems not possible in short term, so waiting for cloud solution when HA integration “ecoflow_cloud” is able to not only read Powerstream values but also control it), so following came up for me:

  • I started also using iobroker and the provided script (see readme, https://forum.iobroker.net/topic/66743/ecoflow-connector-script-zur-dynamischen-leistungsanpassung) with interfacing to Home Assistant (where my Smartmeter values are, send relevant value via mqtt to iobroker for using in iobrober script and not the whole HA integration in iobroker because of performance reason and because I don’t need all the HA entities in iobroker, …)
    I find the script and work very good, but in general/for the beginning I only want to control AC Output and maybe Power Supply Mode of Powerstream from my already running Home Assistant installation (where I have the Smartmeter Live Usage already available), therefore the script got to detailed for me (maybe haven’t spent enough time for understand all the options) over the last time and also I don’t want to maintain an iobrober installation in parallel.
    But – the script and the work Waly_de spent into it is GREAT - maybe later I will continue using the script or whatever will popup in the near future ;-)

  • Then I found (was mentioned in the iobroker thread https://forum.iobroker.net/topic/66743/ecoflow-connector-script-zur-dynamischen-leistungsanpassung/245) this nodesjs solution (which was set up by @bogdancs92 based on the above iobroker script)

- SO THANKS TO BOTH TO GET TO THIS STAGE ;-)

My plan now was to use this nodejs solution in a docker container beside my already running Home Assistant docker container (but this is optional, can also be used without container directly within nodejs on OS level)

For my first PoC I started with:

ecoflow-powerstream-nodejs

NODE_ENV=development
KEY_MAIL=your_email_ecoflow_app
KEY_URL=cmd
KEY_PASSWORD=your_password_ecoflow_app
KEY_POWERSTREAM_SN=HW51xxxxxxxxxxxxx
KEY_QUERY_AC=ac_output_watt
KEY_QUERY_PRIO=power_supply_mode
TOKEN=my_token
TOKEN_VAL=my_secret_for_token
  • (optional) Nodejs Powerstream Container with nodejs-server waiting for request to change AC output Watts or Power Supply Mode on Powerstream
    o Without container: “node server.js” can be used also without a container when nodejs is installed in OS, container usage is currently my preferred way
    o Docker already running for my HA
    o Create Container (may vary on the personal needs)
    Dockerfile:
FROM node:latest
ENV NODE_ENV=development
EXPOSE 8000
WORKDIR /usr/src/app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install --development
RUN apt-get update
RUN apt-get install -y vim
COPY . .
CMD ["node", "server.js"]
    Build:
  

 `docker build --tag ecoflow-nodejs .`

o Start Container
docker run -d -p 8888:8000 --restart unless-stopped --name=ecoflow-nodejs ecoflow-nodejs
(Port 8888 for me because 8000 is already used elsewhere on my used Pi)
o Test by calling URL:
http://192.168.0.xxx:8888/cmd?my_token=my_secret_for_token&ac_output_watt=150&power_supply_mode=0)
(for 150W AC Output and Power Supply Mode to AC Output)
o (Optional) Check the output from inside the container:
docker logs --follow <containerID>

30/08/2023 08:09:10:  set Ac => 150 Watts
30/08/2023 08:09:10:  setPrio => 0
30/08/2023 10:47:08:  set Ac => 75 Watts
30/08/2023 10:47:09:  setPrio => 0
30/08/2023 10:47:44:  set Ac => 150 Watts
30/08/2023 10:47:44:  setPrio => 0

(docker logs timestamp is because of timezone/setting 2h behind)

Home Assistant

  • Home Assistant with an Webservice call to the URL of the Nodejs-Powerstream-server, therefore I created some (similiar to example on Bogdans readme):
    o input_numer (for AC Output Watts), input_text (for Mode) by HA Helpers functionalities
    o Webservice (powerstream_command) in configuration (in my case rest_commands.yaml)
    o Automation for state change of the input_numer (AC OutPut Watts) and input_text (Power Supply Mode) and calling Webservice (powerstream_command)
    o For testing some buttons to change the input_numer (AC OutPut Watts) or input_text (Power Supply Mode)
    o TODO: some intelligence/automation to change values / call Webservice in regards to my Smartmeter Live value in HA

  • input_number/-text and some buttons created by Helpers in HA:
    image

e.g. powerstream_ac_output:
image

image

  • Webservice (powerstream_command):
    Rest_command.yaml (included in configuration.yaml):
powerstream_command: 
    url: "http://192.168.0.xxx:8888/cmd?my_token=my_secret_for_token&ac_output_watt={{ states('input_number.powerstream_ac_output') }}&power_supply_mode={{ states('input_text.powerstream_power_supply_mode') }}"
    verify_ssl: false
  • Automations:
    image

e.g. AC Output Watts
image

  • For Testing added the input_number/-text and buttons on HA card/view:
    image

By pressing the buttons I can now change the AC Output Watts to 0, 75, 150 or the Power Supply Mode to Storage or AC Output/Grid.
Also because the AC Output Watt (input_number) is defined as slider I can select the entity and change the output in between 0-600W (defined for input_number).

First tests are working and I will go on testing
and when it is working fine I will try to set AC Output Watts (Powerstream) depending on my live Smartmeter Current Power (Grid) value (or to what else is helping me in my home and local environment):

image

Work in Progress: HA Automations for trying to narrow zero to grid by controlling the Powerstream via the ecoflow-powerstream-nodejs from HA

  • created some Automations, WebServices, ... for controlling the Powerstream
    • One Automation for trying to narrow the supply to grid near zero (currently called every 10 seconds)
    • working for first tests, optimization for some tactful devices like heating phase of oven maybe needed, ...
    • several other Automations for e.g. switching Zero Automation on/off, switching to Storage Mode if battery is full, switching to supply mode for the night to deliver AC output and empty the battery, ...
    • in nodejs (in my case the docker logs) monitor the calls to the ecoflow mqt API for analysing reasons

Now need to monitor if it is working fine and Automations are triggered, optimization afterwards (e.g. skip tactful devices) and thought about how to deal with battery in wintertime ;-)

image
(docker logs timestamp is because of timezone/setting 2h behind)

Automation triggered when Delta 2 Max gets full (currently 100% defined in Automation), inactivated zero automation (until next morning), switched to Storage mode to supply all solar to AC Output and in preparation set AC output to 150W for the night (Automation will be triggered at 20:00):
(potential overload solar for switching other devices on or maybe additional little battery, ... - but this overload will end at our location in a few days ...)
image
(docker logs timestamp is because of timezone/setting 2h behind)

...

Edit 07.09.2023: moved/follow up with documentation for HA Automation in separate place for no longer spamming this repo/issue ;-)

https://github.com/giovanne123/Ecoflow_Powerstream_HomeAssistant_Automation_Documentation/blob/main/README.md

Not found

Hiya,

I keep trying different ways and keep getting "Not found" when running the below

http://192.168.87.80:8000/cmd?token_key=token_value&ac_output_watt=150

I have copied files to c:\ecoflow folder

I have updated env file to

NODE_ENV=development
KEY_MAIL=[email protected]
KEY_URL=cmd
KEY_PASSWORD=Password - correct password with no quotes or spaces etc
KEY_POWERSTREAM_SN=HW51ZEH4SF5XXXXXX - My correct serial taken from the app, also works in HA with [hassio-ecoflow-cloud
KEY_QUERY_AC=100
KEY_QUERY_PRIO=0
TOKEN=token_key
TOKEN_VAL=token_value
TARGET=2

in CMD I run

node C:\ecoflow\server.js
27/11/2023 16:13:14: Starting app listening at port 8000 -------------------- sticks on this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.