Skip to content

Latest commit

 

History

History
138 lines (85 loc) · 6.75 KB

Software_Docker.md

File metadata and controls

138 lines (85 loc) · 6.75 KB

Docker Image Installation

Docker Installation

Using the Latest Image (development version)

These instructions will result in the latest version of the TWCManager code being run. This is development code and may not be stable, but will provide access to the newer features. The latest image is automatically updated every time that new features or fixes are added to TWCManager, and will change regularly.

sudo apt-get update
sudo apt-get install -y curl docker.io

sudo pip3 install docker-compose

curl https://raw.githubusercontent.com/ngardiner/TWCManager/main/contrib/docker/docker-compose.yml -o docker-compose.yml

Using Stable Versions (Recommended)

If you would like to opt for a more stable version, specify the version of TWCmanager that you would like to use. For example, to use the latest Stable version v1.2.4, use the following commands:

sudo apt-get update
sudo apt-get install -y docker.io

sudo pip3 install docker-compose

curl https://raw.githubusercontent.com/ngardiner/TWCManager/main/contrib/docker/docker-compose-v1.2.4.yml -o docker-compose.yml

Configuring TWCManager for Docker

You may need to perform some configuration of TWCManager in your environment.

  • docker-compose.yml

The default docker-compose.yml file assumes that you will be using Serial interface /dev/ttyUSB0 on the host machine as the serial port to communicate with the TWCs you are managing. If this is not the case, you will need to edit the file and specify the correct interface.

The default docker-compose.yml file also contains a default timezone Environment variable, commented out. Some systems will not require this to be set, however if you find the graphs and schedules are operating in a different timezone to your location (such as UTC/GMT), then you can specify the TZ attribute here with the linux value for timezone definitions. Uncomment this line to have it take effect.

  • /etc/twcmanager/config.json

On your first start of the TWCManager docker container, a directory on the host will be created if it does not currently exist, and the default configuration file will be copied there. The location of this volume is /etc/twcmanager. If you need to edit the configuration file, run the Docker container in interactive mode (instructions below), exit with Ctrl+C and then edit the /etc/twcmanager/config.json file that was created.

Starting TWCManager

To start up TWCManager in interactive mode, run the following command:

sudo docker-compose -f docker-compose.yml up

To start up TWCManager in background mode, run the following command:

sudo docker-compose -f docker-compose.yml up -d

Monitoring the container operation

After starting TWCManager, the script will run in the foreground and will regularly update with the current status. If you specified detach mode (with the -d parameter), the information can be viewed by using the docker logs docker_twcmanager_1 -f command.

An example output is as follows:

twcmanager_1  | 11:57:49: SHA 1234: 00 00.00/00.00A 0000 0000  M: 09 00.00/17.00A 0000 0000
twcmanager_1  | 11:57:49: Green energy generates 4956W, Consumption 726W, Charger Load 0W
twcmanager_1  |          Limiting car charging to 20.65A - 3.03A = 17.62A.
twcmanager_1  |          Charge when above 6A (minAmpsPerTWC).
  • SHA 1234 is the reported TWC code for each of the Slave TWCs that the Master is connected to.

  • The 00.00/00.00A next to the Slave TWC code is the current number of amps being utilised and the total number of amps available to that slave. The master divides the total amperage available for use between the connected slaves.

  • M is the same values for the Master device (our script). It shows current utilization and total available amps (in this case, 17A) available for all connected slaves.

  • The second line shows the green energy values detected. In this case, the attached green energy device (solar inverter) is reporting 4956W being generated from solar, 726W being used by other household appliances, and no load being generated by the charger. As we charge a vehicle, that value will increase and maybe subtracted from the consumption value if configured to do so.

  • The line below this reports the same values but in amps instead of watts.

  • The final line shows the minAmpsPerTWC value, which is the minimum number of amps that the master must offer each slave before we tell the attached vehicle to charge (via the Tesla API).

Upgrading TWCManager

Using the Latest Image

The latest image gives you up to the minute access to TWCManager features and changes. This includes changes that may not be fully tested or could break functions that were previously working. We try to keep these to a minimum by testing prior to merging these changes, but if stability is important to you we recommend a stable version instead.

If you are using the latest Docker image instead of the current Stable version, you can fetch the latest TWCManager updates by executing the following commands:

sudo docker-compose -f docker-compose.yml down
sudo docker-compose -f docker-compose.yml pull
sudo docker-compose -f docker-compose.yml up -d

You can tell if you are running the latest image vs a stable release with the following command:

grep -q :latest docker-compose.yml; [[ $? -eq 1 ]] && echo "Stable Version" || echo "Latest Image"

Using a Stable version

If you are running a stable version of the Docker Image, you can upgrade to the latest stable version v1.2.4 with the following commands:

sudo docker-compose -f docker-compose.yml down

curl https://raw.githubusercontent.com/ngardiner/TWCManager/main/contrib/docker/docker-compose-v1.2.4.yml -o docker-compose.yml
sudo docker-compose -f docker-compose.yml pull
sudo docker-compose -d -f docker-compose.yml up

Stopping TWCManager

You may stop the TWCManager container in the following ways:

  • Interactive Mode

Press Ctrl + C in the console of the Docker Container to stop TWCManager from running

  • Background Mode

Use the following command to stop TWCManager's docker container from running in Background Mode:

sudo docker-compose -f docker-compose.yml down

Starting TWCManager at Boot

The default restart policy for the Docker Container is to always restart the container if it is stopped. This is in the form of the following config stanza:

restart: always

This means that by default, after a docker-compose up, TWCManager will start on boot automatiacally.

If you'd like to change the behaviour of TWCManager's restart policy, edit the docker-compose.yml file and refer to the following for available restart options:

https://github.com/compose-spec/compose-spec/blob/master/spec.md