Skip to content

Latest commit

 

History

History
93 lines (63 loc) · 2.16 KB

development.md

File metadata and controls

93 lines (63 loc) · 2.16 KB

Development

Requirements

  • Elixir >= 1.9
  • Postgres >= 10
  • An MQTT broker e.g. mosquitto (optional)

Initial Setup

To run the TeslaMate test suite you need a database named teslamate_test:

# download dependencies
mix deps.get

# create the dev database and run migrations
mix ecto.setup

# create the test database
MIX_ENV=test mix ecto.setup

# download JavaScript dependencies
npm install --prefix ./assets

Running locally

Start an iex session in another terminal window:

iex -S mix phx.server

Then sign in with a Tesla account.

Hot reloading

To immediately apply your local changes open or reload http://localhost:4000. You can also reload specific modules via iex, for example:

iex> r TeslaMate.Vehicles.Vehicle

To only compile the changes:

mix compile

Code formatting

mix format

Testing

To ensure a commit passes CI you should run mix ci locally, which executes the following commands:

  • Check formatting (mix format --check-formatted)
  • Run all tests (mix test)

Making Changes to Grafana Dashboards

To update dashboards you need Grafana running locally. The following docker-compose.yml can be used for this purpose:

version: '3'
services:
  grafana:
    image: teslamate-grafana:latest
    environment:
      - DATABASE_USER=postgres
      - DATABASE_PASS=postgres
      - DATABASE_NAME=teslamate_dev
      - DATABASE_HOST=host.docker.internal
    ports:
      - 3000:3000
    volumes:
      - grafana-data:/var/lib/grafana

volumes:
    grafana-data:

(on Linux use the actual IP address of the host as DATABASE_HOSTinstead of host.docker.internal)

Then build the image with make grafana and run the container via docker-compose up grafana.

Access the Grafana at http://localhost:3000 and sign in with the default user admin and password admin.

Then edit the respective dashboard(s) locally. To export a dashboard hit the 'Save' button and select Save JSON to file. The final JSON file belongs in the directory ./grafana/dashboards/. To apply the changes rebuild the image and start the container.