Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add daemon option to tesla-history and dockerize #281

Merged
merged 3 commits into from
May 20, 2023

Conversation

mcbirse
Copy link
Collaborator

@mcbirse mcbirse commented May 20, 2023

Changes to tesla-history script to add daemon option and create a docker container, for solar-only users as per #183

@jasonacox - when you have time, would you be able to run "upload.sh" to create the tesla-history docker container in your Docker Hub account please? No rush. If users wish to test this before then, I can make my container public for user testing instead.

Daemon mode changes:

  • Added "--daemon" option which enables the tesla-history script to run as a daemon
  • When running in daemon mode:
    • Continually polls Tesla Cloud for history data
    • By default, polls every 5 minutes and imports last 60 minutes of history data on each poll (can be changed in config)
    • Log output for each poll period (e.g. every 5 minutes) is suppressed by default (can be enabled in config)
    • NOTE: It is recommended to retrieve e.g. 60 minutes of history for every poll period. This ensures history data is filled in for greater than the poll period, as my testing shows Tesla Cloud sometimes does not update data frequently (there can be a lag, resulting in zero values). This also helps if for instance an Internet outage occurred
    • NOTE2: Because of above, daemon mode does NOT search for data gaps, so it will replace data in InfluxDB with the latest data retrieved (similar to --force option)

Setup changes:

  • Streamlined setup process: added hidden options to tesla-history script which are passed from "setup.sh"
  • Setup process will also detect multiple Tesla energy sites, and prompt the user to enter the site id to use
  • tesla-history.conf file will now be created with comments above the config options, describing the options and the new daemon section. Therefore, it is recommended to overwrite and re-create the tesla-history config during the setup/upgrade process when prompted to see these changes
  • NOTE: anyone can test this including Powerwall users! For Powerwall users, data will be retrieved from the Tesla Cloud instead of their gateway
    • Powerwall users should not set this up in their current environment however, as it will conflict. Instead, if you wish to test, create a new fresh install in a different host/environment and then run "setup.sh" from the tools/solar-only folder

Docker container notes:

  • Added tesla-history to docker compose to create a docker container for the script to run in daemon mode
    • The container must have write access to local tesla-history source directory (where .conf and .auth resides), since .auth file must be writable as it is updated periodically by TeslaPy
    • InfluxDB hostname and tesla-history config & auth files can be specified by environment variable in daemon mode. This is required for the docker compose configuration

Miscellaneous changes:

  • Migrated main project latest changes to solar-only (excluding dashboard changes)
  • Fixed up various typos and spelling errors throughout the project as discovered

TODO:

  • Update solar-only README to include setup and usage instructions
  • Post install/upgrade/testing instructions in solar-only testing thread #183
  • Migrate tesla-history changes to main script so there is only one source to maintain
  • Investigate consolidating solar-only setup option / files / directories to main project to make it easier to update and align with main project changes (only differences really are docker containers, some configuration options, and the dashboard)

@jasonacox jasonacox merged commit 7c75237 into jasonacox:main May 20, 2023
@jasonacox
Copy link
Owner

Thanks @mcbirse - this is amazing! Also, thanks for the spelling cleanup! Some of that has been around a while... embarrassing. 😊

I looked through the changes and didn't see any obvious issue.

Investigate consolidating solar-only setup option / files / directories to main project to make it easier to update and align with main project changes (only differences really are docker containers, some configuration options, and the dashboard)

I was thinking the same thing.

run "upload.sh" to create the tesla-history docker container

This is done. https://hub.docker.com/repository/docker/jasonacox/tesla-history/general

* VERIFY jasonacox/tesla-history:latest
  Platform:  linux/amd64
  Platform:  linux/arm64
  Platform:  linux/arm/v7

@jasonacox
Copy link
Owner

Container pushed - ready for testing for #183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants