Skip to content

Commit

Permalink
style: linter findings for md and mdx files
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobLichterfeld committed Sep 18, 2024
1 parent fa612f1 commit aaf9949
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 182 deletions.
2 changes: 1 addition & 1 deletion website/docs/configuration/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_label: Environment Variables
TeslaMate accepts the following environment variables for runtime configuration:

| Variable Name | Description | Default Value |
|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | |
| **DATABASE_USER** | Username (**required**) | |
| **DATABASE_PASS** | User password (**required**) | |
Expand Down
8 changes: 4 additions & 4 deletions website/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ For TeslaMate:

```yml
teslamate:
# image: teslamate/teslamate:latest
image: ghcr.io/teslamate-org/teslamate/teslamate:pr-3836
# image: teslamate/teslamate:latest
image: ghcr.io/teslamate-org/teslamate/teslamate:pr-3836
```
For Grafana:
```yml
grafana:
# image: teslamate/grafana:latest
image: ghcr.io/teslamate-org/teslamate/grafana:pr-3836
# image: teslamate/grafana:latest
image: ghcr.io/teslamate-org/teslamate/grafana:pr-3836
```
## Making Changes to Grafana Dashboards
Expand Down
4 changes: 2 additions & 2 deletions website/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ HTTPS (TCP/443)
auth.tesla.com
owner-api.teslamotors.com
streaming.vn.teslamotors.com
nominatim.openstreetmap.org
nominatim.openstreetmap.org

HTTP (TCP/80)
step.esa.int
step.esa.int

Note: This may change when Teslamate is updated!
11 changes: 6 additions & 5 deletions website/docs/guides/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ MyTeslaMate also provides streaming by [reproducing the old streaming from the d

1. Set up a third-party account at [developer.tesla.com](https://developer.tesla.com) as described on the [Tesla docs](https://developer.tesla.com/docs/fleet-api#setup)
1. Add the following environment variable with your own domain :
1. Use [the correct region](https://developer.tesla.com/docs/fleet-api#endpoints-and-regional-requirements) in the `TESLA_API_HOST` field:
- North America, Asia-Pacific (excluding China): [https://fleet-api.prd.na.vn.cloud.tesla.com](https://fleet-api.prd.na.vn.cloud.tesla.com)
- Europe, Middle East, Africa: [https://fleet-api.prd.eu.vn.cloud.tesla.com](https://fleet-api.prd.eu.vn.cloud.tesla.com)
- China: [https://fleet-api.prd.cn.vn.cloud.tesla.cn](https://fleet-api.prd.cn.vn.cloud.tesla.cn)
1. Update the `TESLA_AUTH_CLIENT_ID` with the client ID of your Tesla application.

1. Use [the correct region](https://developer.tesla.com/docs/fleet-api#endpoints-and-regional-requirements) in the `TESLA_API_HOST` field:
- North America, Asia-Pacific (excluding China): [https://fleet-api.prd.na.vn.cloud.tesla.com](https://fleet-api.prd.na.vn.cloud.tesla.com)
- Europe, Middle East, Africa: [https://fleet-api.prd.eu.vn.cloud.tesla.com](https://fleet-api.prd.eu.vn.cloud.tesla.com)
- China: [https://fleet-api.prd.cn.vn.cloud.tesla.cn](https://fleet-api.prd.cn.vn.cloud.tesla.cn)
1. Update the `TESLA_AUTH_CLIENT_ID` with the client ID of your Tesla application.

```yml
# API Fleet
Expand Down
31 changes: 16 additions & 15 deletions website/docs/guides/unix_domain_sockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
title: Using Unix Domain Sockets with a reverse-proxy
---

It is possible to configure Teslamate to communicate over unix-domain sockets (UDS) instea of a typical network socket. This can be useful to improve security by restricting which applications can communicate to the application. A typical configuration would be to use a UDS between a reverse-proxy (like Nginx) and Teslamate. When paired with something like rootless-podman and [socket-activation](https://github.com/containers/podman/blob/main/docs/tutorials/socket_activation.md), Nginx can be configured with `--network=none` providing external access to Teslmate without the Nginx container having any networking at all. While setting up socket-activation and Podman is beyond the scope of this document, it will explain how to configure UDS between Teslamate and an Nginx reverse-proxy.

It is possible to configure Teslamate to communicate over unix-domain sockets (UDS) instea of a typical network socket. This can be useful to improve security by restricting which applications can communicate to the application. A typical configuration would be to use a UDS between a reverse-proxy (like Nginx) and Teslamate. When paired with something like rootless-podman and [socket-activation](https://github.com/containers/podman/blob/main/docs/tutorials/socket_activation.md), Nginx can be configured with `--network=none` providing external access to Teslmate without the Nginx container having any networking at all. While setting up socket-activation and Podman is beyond the scope of this document, it will explain how to configure UDS between Teslamate and an Nginx reverse-proxy.

## Requirements

- Linux system configured with Teslamate installed and working
- These instructions will document the procedure for using a UDS with docker-compose, but it is not difficult to adapt them to a system running Teslamate natively via systemd.
- Nginx configured as a reverse proxy


## Instructions

Nginx requires that the UDS exist when it is started, but Teslamate will (re)create the UDS on startup. This means that Teslamate must be configured to start before Nginx, or Nginx must be configured to detect a socket change and reload (for example the [socket-gen](https://github.com/PhracturedBlue/socket-gen) utility designed for this purpose). Additionally, because docker-compose does not provide a method to run host-commands prior to starting a container, the directory containing the UDS must be manually created before Teslamate starts. It is easiest to manually create this directory on a persistent volume.
- Create a directory for the UDS:
`mkdir -p /opt/nginx_uds/teslamate`
- Allow Nginx to access the directory:
`chown <nginx user> /opt/nginx_uds/teslamate`
- Allow Teslamate to create the UDS:
`chgrp 10001 /opt/nginx_uds/teslamate`
`chmod 770 /opt/nginx_uds/teslamate`
An alternative to using owner/group access would be to use [ACLs](https://wiki.debian.org/Permissions#Access_Control_Lists_in_Linux) to control access to the UDS directory.

Next configure Teslamate to use the UDS. Modify the teslamate service in docker-compose.yml to include:
Nginx requires that the UDS exist when it is started, but Teslamate will (re)create the UDS on startup. This means that Teslamate must be configured to start before Nginx, or Nginx must be configured to detect a socket change and reload (for example the [socket-gen](https://github.com/PhracturedBlue/socket-gen) utility designed for this purpose). Additionally, because docker-compose does not provide a method to run host-commands prior to starting a container, the directory containing the UDS must be manually created before Teslamate starts. It is easiest to manually create this directory on a persistent volume.

- Create a directory for the UDS:
`mkdir -p /opt/nginx_uds/teslamate`
- Allow Nginx to access the directory:
`chown <nginx user> /opt/nginx_uds/teslamate`
- Allow Teslamate to create the UDS:
`chgrp 10001 /opt/nginx_uds/teslamate`
`chmod 770 /opt/nginx_uds/teslamate`
An alternative to using owner/group access would be to use [ACLs](https://wiki.debian.org/Permissions#Access_Control_Lists_in_Linux) to control access to the UDS directory.

Next configure Teslamate to use the UDS. Modify the teslamate service in docker-compose.yml to include:

```
volumes:
...
Expand All @@ -37,7 +37,8 @@ Next configure Teslamate to use the UDS. Modify the teslamate service in docker
# - 4000:4000
```

Lastly, configure the Nginx reverse-proxy to forward connections to the UDS. The relevant configuration would look something like:
Lastly, configure the Nginx reverse-proxy to forward connections to the UDS. The relevant configuration would look something like:

```
upstream teslamate.uds {
server unix:/opt/nginx_uds/teslamate/teslamate.sock;
Expand Down
1 change: 0 additions & 1 deletion website/docs/import/tesla_apiscraper.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,3 @@ All of this is experimental and has not been extensively tested. If you encounte
### Part 3: Importing the processed CSV data into TeslaMate

- Proceed with the [TeslaFi import](teslafi.md) steps using the CSV files you just created.

1 change: 1 addition & 0 deletions website/docs/integrations/Node-RED.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ done
docker compose stop node-red
docker compose start node-red
```

Note that if your function nodes need additional NPM packages, you can add those into 'MODULES'. You can import those in the function node 'Setup' page, like add module 'linq-js' and import it as variable 'Enumerable'.

## Import Flows
Expand Down
50 changes: 24 additions & 26 deletions website/docs/integrations/home_assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Don't forget to replace `<teslamate url>` and `<your tesla model>` with correct
unique_id: teslamate_1_display_name # internal id, used for device grouping
availability: &teslamate_availability
- topic: teslamate/cars/1/healthy
payload_available: 'true'
payload_not_available: 'false'
payload_available: "true"
payload_not_available: "false"
device: &teslamate_device_info
identifiers: [teslamate_car_1]
configuration_url: https://teslamate.zxxz.io/
Expand All @@ -81,7 +81,7 @@ Don't forget to replace `<teslamate url>` and `<your tesla model>` with correct
device: *teslamate_device_info
json_attributes_topic: "teslamate/cars/1/location"
icon: mdi:crosshairs-gps
- device_tracker:
name: Active route location
object_id: tesla_active_route_location
Expand Down Expand Up @@ -305,7 +305,7 @@ Don't forget to replace `<teslamate url>` and `<your tesla model>` with correct
device_class: battery
unit_of_measurement: "%"
icon: mdi:battery-80
- sensor:
name: Usable Battery Level
object_id: tesla_usable_battery_level
Expand Down Expand Up @@ -642,83 +642,82 @@ Don't forget to replace `<teslamate url>` and `<your tesla model>` with correct
payload_on: "true"
payload_off: "false"
icon: mdi:ev-plug-tesla
```

### sensor.yaml (sensor: section of configuration.yaml)

```yml title="sensor.yaml"
- platform: template
sensors:
- platform: template
sensors:
tesla_est_battery_range_mi:
friendly_name: Estimated Range (mi)
unit_of_measurement: mi
icon_template: mdi:gauge
value_template: >
{{ (states('sensor.tesla_est_battery_range_km') | float / 1.609344) | round(2) }}
{{ (states('sensor.tesla_est_battery_range_km') | float / 1.609344) | round(2) }}
tesla_rated_battery_range_mi:
friendly_name: Rated Range (mi)
unit_of_measurement: mi
icon_template: mdi:gauge
value_template: >
{{ (states('sensor.tesla_rated_battery_range_km') | float / 1.609344) | round(2) }}
{{ (states('sensor.tesla_rated_battery_range_km') | float / 1.609344) | round(2) }}
tesla_ideal_battery_range_mi:
friendly_name: Ideal Range (mi)
unit_of_measurement: mi
icon_template: mdi:gauge
value_template: >
{{ (states('sensor.tesla_ideal_battery_range_km') | float / 1.609344) | round(2) }}
{{ (states('sensor.tesla_ideal_battery_range_km') | float / 1.609344) | round(2) }}
tesla_odometer_mi:
friendly_name: Odometer (mi)
unit_of_measurement: mi
icon_template: mdi:counter
value_template: >
{{ (states('sensor.tesla_odometer') | float / 1.609344) | round(2) }}
{{ (states('sensor.tesla_odometer') | float / 1.609344) | round(2) }}
tesla_speed_mph:
friendly_name: Speed (MPH)
unit_of_measurement: mph
icon_template: mdi:speedometer
value_template: >
{{ (states('sensor.tesla_speed') | float / 1.609344) | round(2) }}
{{ (states('sensor.tesla_speed') | float / 1.609344) | round(2) }}
tesla_elevation_ft:
friendly_name: Elevation (ft)
unit_of_measurement: ft
icon_template: mdi:image-filter-hdr
value_template: >
{{ (states('sensor.tesla_elevation') | float * 3.2808 ) | round(2) }}
{{ (states('sensor.tesla_elevation') | float * 3.2808 ) | round(2) }}
tesla_tpms_pressure_fl_psi:
friendly_name: Front Left Tire Pressure (psi)
unit_of_measurement: psi
icon_template: mdi:car-tire-alert
value_template: >
{{ (states('sensor.tesla_tpms_pressure_fl') | float * 14.50377) | round(2) }}
{{ (states('sensor.tesla_tpms_pressure_fl') | float * 14.50377) | round(2) }}
tesla_tpms_pressure_fr_psi:
friendly_name: Front Right Tire Pressure (psi)
unit_of_measurement: psi
icon_template: mdi:car-tire-alert
value_template: >
{{ (states('sensor.tesla_tpms_pressure_fr') | float * 14.50377) | round(2) }}
{{ (states('sensor.tesla_tpms_pressure_fr') | float * 14.50377) | round(2) }}
tesla_tpms_pressure_rl_psi:
friendly_name: Rear Left Tire Pressure (psi)
unit_of_measurement: psi
icon_template: mdi:car-tire-alert
value_template: >
{{ (states('sensor.tesla_tpms_pressure_rl') | float * 14.50377) | round(2) }}
{{ (states('sensor.tesla_tpms_pressure_rl') | float * 14.50377) | round(2) }}
tesla_tpms_pressure_rr_psi:
friendly_name: Rear Right Tire Pressure (psi)
unit_of_measurement: psi
icon_template: mdi:car-tire-alert
value_template: >
{{ (states('sensor.tesla_tpms_pressure_rr') | float * 14.50377) | round(2) }}
{{ (states('sensor.tesla_tpms_pressure_rr') | float * 14.50377) | round(2) }}
tesla_active_route_distance_to_arrival_km:
friendly_name: Active route distance to arrival (km)
Expand All @@ -731,17 +730,17 @@ Don't forget to replace `<teslamate url>` and `<your tesla model>` with correct
### binary_sensor.yaml (binary_sensor: section of configuration.yaml)

```yml title="binary_sensor.yaml"
- platform: template
sensors:
- platform: template
sensors:
tesla_park_brake:
friendly_name: Parking Brake
icon_template: mdi:car-brake-parking
value_template: >-
{% if is_state('sensor.tesla_shift_state', 'P') %}
ON
{% else %}
OFF
{% endif %}
{% if is_state('sensor.tesla_shift_state', 'P') %}
ON
{% else %}
OFF
{% endif %}
```

### ui-lovelace.yaml
Expand Down Expand Up @@ -1100,7 +1099,7 @@ notify_tesla_windows_open:
data:
variables:
whatsopen: "windows"
- id: plugin-tesla-notify
alias: Notify if Tesla not plugged in at night
trigger:
Expand All @@ -1120,4 +1119,3 @@ conditions:
initial_state: true
mode: single
```

Loading

0 comments on commit aaf9949

Please sign in to comment.