Sign inSign up

petrovoronov/ecoflow-mqtt-to-svitlobot

By petrovoronov

•Updated almost 2 years ago

A tool to reflect the AC-input status of EcoFlow device to the appropriate SvitloBot channel.

Image
Monitoring & observability
0

2.9K

petrovoronov/ecoflow-mqtt-to-svitlobot repository overview

⁠Ecoflow MQTT to SvitloBot

GitHub release Docker Image Version Docker Pulls GitHub license GitHub last commit GitHub issues GitHub pull requests

Ukrainian translation

⁠About

This project integrates Ecoflow MQTT broker with SvitloBot API and report the presence or absence of AC input on Ecoflow device.

⁠Features

  • Connects to Ecoflow MQTT broker;
  • Subscribes to MQTT topics to monitor AC input parameters;
  • "Ping" svitlobot API in case of AC input presence.

⁠Prerequisites

⁠Installation

⁠Docker image installation
docker pull petrovoronov/ecoflow-mqtt-to-svitlobot
⁠Node.js installation from the source code
  1. Clone the repository:

    git clone https://github.com/PetroVoronov/ecoflow-mqtt-to-svitlobot.git
    cd ecoflow-mqtt-to-svitlobot
    
  2. Install dependencies:

    npm install
    

⁠Passing the basic configuration parameters

Basic configuration parameters, including Ecoflow and SvitloBot credentials can be passed as environment variables:

export ECOFLOW_USERNAME=your_ecoflow_username
export ECOFLOW_PASSWORD=your_ecoflow_password
export ECOFLOW_DEVICE_SN=your_ecoflow_device_sn
export SVITLOBOT_CHANNEL_KEY=your_svitlobot_channel_key

or

export ECOFLOW_ACCESS_KEY=your_ecoflow_access_key
export ECOFLOW_SECRET_KEY=your_ecoflow_secret_key
export ECOFLOW_DEVICE_SN=your_ecoflow_device_sn
export SVITLOBOT_CHANNEL_KEY=your_svitlobot_channel_key

or you can skip it and application will ask you to enter it interactively.

After first run these parameters will be stored in the config directory and will be used for the next runs. So you will be asked to enter the parameters only once (or you should pass it as environment variables only on the first run).

Important notice: if you want to change the parameters you should pass it again as environment variables at any time.

⁠Command-line Options

The application can be configured using the following command-line options:

OptionShortDescriptionTypeDefaultRequired
--api-url-aURL of the Ecoflow APIStringhttps://api.ecoflow.comNo
--svitlobot-update-interval-iUpdate status of the svitlobot every X secondsNumber60No
--keep-alive-kCheck if the MQTT client is alive every Y update intervalsNumber3No
--log-pingLog the "ping" status of the SvitloBot APIBooleanfalseNo
--log-alive-status-interval-lLog the MQTT client alive status every Z minutesNumber0No
--errors-count-max-eMaximum number of errors count for the SvitloBot pingNumber5No
--auth-via-access-keyUse the access key for the Ecoflow API authenticationBooleanfalseNo
--auth-via-username-passwordUse the username and password for the Ecoflow API authenticationBooleanfalseNo
--test-only-tRun without sending messages to the SvitloBot APIBooleanfalseNo
--debug-dDebug level of loggingBooleanfalseNo

⁠Running the Application

⁠Node.js

There is an example with all possible command-line options:

node src/index.js -i 60 -k 3 -l 60 -d true
⁠Docker

By default the application will run without any additional command-line options.

Due to the limitations of the Docker environment, the application will not be able to ask for the missing configuration parameters interactively. That's why you need to make a first run in interactive mode to provide the missing parameters.

⁠Docker Volumes

You must to map the application data directory to the container:

  • /app/config - for the application configurations. Mandatory for the mapping! You can map in on any local directory on the host system or docker volume.
⁠Docker first run

So, the first run should be like one of the following:

  • to set all basic configuration parameters interactively, but with some additional command-line options:

    docker run -it --name ecoflow-mqtt-to-svitlobot \
        -v /path/to/your/config:/app/config \
        petrovoronov/ecoflow-mqtt-to-svitlobot:latest \
        --svitlobot-update-interval 60 --keep-alive 3 --log-alive-status-interval 60
    
  • to set basic configuration parameters as environment variables to authenticate by username and password:

    docker run -d --name ecoflow-mqtt-to-svitlobot \
        -v /path/to/your/config:/app/config \
        -e ECOFLOW_USERNAME=your_ecoflow_username \
        -e ECOFLOW_PASSWORD=your_ecoflow_password \
        -e ECOFLOW_DEVICE_SN=your_ecoflow_device_sn \
        -e SVITLOBOT_CHANNEL_KEY=your_svitlobot_channel_key \
        petrovoronov/ecoflow-mqtt-to-svitlobot:latest
    
  • to set basic configuration parameters as environment variables to authenticate by access key:

    docker run -d --name ecoflow-mqtt-to-svitlobot \
        -v /path/to/your/config:/app/config \
        -e ECOFLOW_ACCESS_KEY=your_ecoflow_access_key \
        -e ECOFLOW_SECRET_KEY=your_ecoflow_secret_key \
        -e ECOFLOW_DEVICE_SN=your_ecoflow_device_sn \
        -e SVITLOBOT_CHANNEL_KEY=your_svitlobot_channel_key \
        petrovoronov/ecoflow-mqtt-to-svitlobot:latest
    

Important notice: pass all later needed command-line options at first run!*

After the first run the application will store the configuration parameters and additional info - please stop the container by pressing Ctrl+C and start it again with the commands from the next section.

⁠Docker next runs

After the first run you can run the application with the same configuration parameters as the previous run without any additional command-line options.

To start the application, run the following command:

docker start ecoflow-mqtt-to-svitlobot

To stop the application, run the following command:

docker stop ecoflow-mqtt-to-svitlobot
⁠Docker Compose

To run the application using Docker Compose, create a docker-compose.yml file with the following content:

  • to authenticate by username and password:

    version: '3'
    services:
        ecoflow-mqtt-to-svitlobot:
            image: petrovoronov/ecoflow-mqtt-to-svitlobot:latest
            volumes:
                - /path/to/your/config:/app/config
            environment:
                - ECOFLOW_USERNAME=your_ecoflow_username
                - ECOFLOW_PASSWORD=your_ecoflow_password
                - ECOFLOW_DEVICE_SN=your_ecoflow_device_sn
                - SVITLOBOT_CHANNEL_KEY=your_svitlobot_channel_key
            command: --svitlobot-update-interval 60 --keep-alive 3 --log-alive-status-interval 60
    
  • to authenticate by access key:

    version: '3'
    services:
        ecoflow-mqtt-to-svitlobot:
            image: petrovoronov/ecoflow-mqtt-to-svitlobot:latest
            volumes:
                - /path/to/your/config:/app/config
            environment:
                - ECOFLOW_ACCESS_KEY=your_ecoflow_access_key
                - ECOFLOW_SECRET_KEY=your_ecoflow_secret_key
                - ECOFLOW_DEVICE_SN=your_ecoflow_device_sn
                - SVITLOBOT_CHANNEL_KEY=your_svitlobot_channel_key
            command: --svitlobot-update-interval 60 --keep-alive 3 --log-alive-status-interval 60
    

Replace /path/to/your/config with the actual paths on your system where you want to store the application config.

Then, run the following command to start the application:

docker-compose up -d

This will start the application with the specified configuration parameters.

⁠License

This project is licensed under the MIT License - see the LICENSE⁠ file for details.

Tag summary

Content type

Image

Digest

sha256:18f8830ea…

Size

69.6 MB

Last updated

almost 2 years ago

docker pull petrovoronov/ecoflow-mqtt-to-svitlobot