Skip to content

Commit

Permalink
yaml cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yoziru committed Aug 5, 2024
1 parent 42f7713 commit e35aa6a
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 85 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Tested with M5Stack NanoC6 and Tesla firmwares 2024.26.3.1.

## Usage

> For ESPHome dashboard, see [`tesla-ble-example.yml`](./tesla-ble.example.yml)
### Pre-requisites
- Python 3.10+
- GNU Make
Expand Down
10 changes: 1 addition & 9 deletions boards/esp32-generic.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
substitutions:
friendly_name: "ESP32 Tesla BLE"
devicename: "esp32-tesla-ble"
device_description: "ESP32"

esp32:
board: esp32dev
variant: esp32
flash_size: 4MB
framework:
type: esp-idf
version: 5.3.0
platform_version: 6.8.1
12 changes: 2 additions & 10 deletions boards/m5stack-atoms3.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
substitutions:
friendly_name: "AtomS3 Tesla BLE"
devicename: "atoms3-tesla-ble"
device_description: "M5AtomS3"

esp32:
board: m5stack-atoms3
board: esp32-s3-devkitc-1
variant: esp32s3
flash_size: 8MB
framework:
type: esp-idf
version: 5.3.0
platform_version: 6.8.1

# Board specific entities
# Output that blinks the LED
output:
- platform: template
Expand Down
11 changes: 3 additions & 8 deletions boards/m5stack-nanoc6.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
substitutions:
friendly_name: "NanoC6 Tesla BLE"
devicename: "nanoc6-tesla-ble"
device_description: "M5NanoC6"

esp32:
board: esp32-c6-devkitm-1
variant: esp32c6
flash_size: 4MB

esp32:
framework:
type: esp-idf
version: 5.3.0
platform_version: 6.8.1
sdkconfig_options:
CONFIG_OPENTHREAD_ENABLED: n
CONFIG_ENABLE_WIFI_STATION: y
CONFIG_USE_MINIMAL_MDNS: y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB: y

# Board specific entities
light:
- platform: status_led
name: "Status LED"
Expand Down
26 changes: 8 additions & 18 deletions packages/base.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
substitutions:
friendly_name: ESPHome Tesla BLE
friendly_name: Tesla BLE
device_name: tesla-ble
device_description: Tesla BLE
device_description: Interact with Tesla vehicles over BLE using ESPHome and Home Assistant

packages:
board: !include board.yml
common: !include common.yml
project: !include project.yml

esphome:
name: ${device_name}
Expand All @@ -10,7 +15,7 @@ esphome:
comment: ${device_description}
project:
name: yoziru.esphome-tesla-ble
version: "2024.8.0"
version: "2024.8.1"
libraries:
- https://github.com/yoziru/tesla-ble.git#v2.2.1

Expand All @@ -25,26 +30,11 @@ ota:
platform: esphome
password: !secret ota_password


esp32_ble_tracker:
scan_parameters:
# Depending on the model and state, BLE advertisements come every 20ms or every 150ms.
interval: 150ms
# Activate scan only after wifi connect, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
continuous: false

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
password: !secret wifi_hotspot_password
# Activate scan only after wifi connect, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
on_connect:
- esp32_ble_tracker.start_scan:
continuous: true
on_disconnect:
- esp32_ble_tracker.stop_scan:

captive_portal:

12 changes: 12 additions & 0 deletions packages/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
substitutions:
espidf_version: "5.3.0"
platformio_version: "6.8.1"

esp32:
board: $board
variant: $variant
flash_size: $flash_size
framework:
type: esp-idf
version: $espidf_version
platform_version: $platformio_version
16 changes: 8 additions & 8 deletions packages/client.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
substitutions:
ble_mac_address: !secret ble_mac_address
tesla_vin: !secret tesla_vin
charging_amps_max: "32"

ble_client:
- mac_address: !secret ble_mac_address
- mac_address: $ble_mac_address
id: ble_tesla_id

tesla_ble_vehicle:
ble_client_id: ble_tesla_id
id: tesla_ble_vehicle_id
vin: !secret tesla_vin
vin: $tesla_vin
update_interval: 1min # default
is_asleep:
name: "Asleep"
Expand All @@ -17,11 +22,6 @@ tesla_ble_vehicle:
name: "Charge flap"

button:
- platform: restart
name: Restart
icon: mdi:restart
entity_category: diagnostic

- platform: template
id: ble_pair
name: Pair BLE key
Expand Down Expand Up @@ -84,7 +84,7 @@ number:
unit_of_measurement: "A"
mode: slider
min_value: 0
max_value: 32
max_value: $charging_amps_max
step: 1
optimistic: true
restore_value: true
Expand Down
15 changes: 12 additions & 3 deletions packages/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ sensor:
update_interval: 60s
icon: mdi:clock-outline

time:
- platform: homeassistant
id: esptime
binary_sensor:
- platform: status
name: "Status"

text_sensor:
- platform: version
Expand All @@ -21,3 +21,12 @@ text_sensor:
ip_address:
name: "IP Address"

time:
- platform: homeassistant
id: homeassistant_time

button:
- platform: restart
name: Restart
icon: mdi:restart
entity_category: diagnostic
2 changes: 2 additions & 0 deletions packages/external_components.dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- components: [tesla_ble_vehicle, tesla_ble_listener]
source: github://yoziru/esphome-tesla-ble/components@main
5 changes: 2 additions & 3 deletions packages/external_components.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
external_components:
- components: [tesla_ble_vehicle, tesla_ble_listener]
source: components
- components: [tesla_ble_vehicle, tesla_ble_listener]
source: components
3 changes: 0 additions & 3 deletions packages/external_components_dashboard.yml

This file was deleted.

5 changes: 4 additions & 1 deletion packages/listener.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
substitutions:
tesla_vin: !secret tesla_vin

# Enable this to scan for BLE devices
tesla_ble_listener:
vin: !secret tesla_vin
vin: $tesla_vin
14 changes: 14 additions & 0 deletions packages/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
esp32_ble_tracker:
scan_parameters:
# Depending on the model and state, BLE advertisements come every 20ms or every 150ms.
interval: 150ms
# Activate scan only after wifi connect, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
continuous: false

wifi:
# Activate scan only after wifi connect, see https://github.com/esphome/issues/issues/2941#issuecomment-1842369092
on_connect:
- esp32_ble_tracker.start_scan:
continuous: true
on_disconnect:
- esp32_ble_tracker.stop_scan:
10 changes: 0 additions & 10 deletions tesla-ble-dashboard.yml

This file was deleted.

4 changes: 4 additions & 0 deletions tesla-ble-esp32-generic.dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<<: !include tesla-ble-esp32-generic.yml

# override external_components to use the dashboard version
external_components: !include packages/external_components.dashboard.yml
8 changes: 4 additions & 4 deletions tesla-ble-esp32-generic.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
external_components: !include packages/external_components.yml

packages:
device_base: !include boards/esp32-generic.yml
base: !include packages/base.yml
common: !include packages/common.yml
device_base: !include boards/esp32-generic.yml
client: !include packages/client.yml
# listener: !include packages/listener.yml # Uncomment this to scan find your VIN BLE MAC address
external_components: !include packages/external_components.yml

dashboard_import:
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble-dashboard.yml
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble-esp32-generic.dashboard.yml
4 changes: 4 additions & 0 deletions tesla-ble-m5stack-atoms3-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<<: !include tesla-ble-m5stack-atoms3.yml

# override external_components to use the dashboard version
external_components: !include packages/external_components.dashboard.yml
9 changes: 5 additions & 4 deletions tesla-ble-m5stack-atoms3.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
external_components: !include packages/external_components.yml

packages:
device_base: !include boards/m5stack-atoms3.yml
base: !include packages/base.yml
common: !include packages/common.yml
device_base: !include boards/m5stack-atoms3.yml
client: !include packages/client.yml
# listener: !include packages/listener.yml # Uncomment this to scan find your VIN BLE MAC address
external_components: !include packages/external_components.yml
# for ESPHome Dashboard, use this instead of external_components

dashboard_import:
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble-dashboard.yml
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble-m5stack-atoms3.dashboard.yml
4 changes: 4 additions & 0 deletions tesla-ble-m5stack-nanoc6-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<<: !include tesla-ble-m5stack-nanoc6.yml

# override external_components to use the dashboard version
external_components: !include packages/external_components.dashboard.yml
8 changes: 4 additions & 4 deletions tesla-ble-m5stack-nanoc6.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
external_components: !include packages/external_components.yml

packages:
device_base: !include boards/m5stack-nanoc6.yml
base: !include packages/base.yml
common: !include packages/common.yml
device_base: !include boards/m5stack-nanoc6.yml
client: !include packages/client.yml
# listener: !include packages/listener.yml # Uncomment this to scan find your VIN BLE MAC address
external_components: !include packages/external_components.yml

dashboard_import:
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble-dashboard.yml
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble-nanoc6.dashboard.yml
25 changes: 25 additions & 0 deletions tesla-ble.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
substitutions:
# all substitutions for this project
espidf_version: 5.3.0
platformio_version: 6.8.1
friendly_name: Tesla BLE
device_name: tesla-ble
device_description: Tesla BLE
board: esp32dev
variant: esp32
flash_size: 4MB
ble_mac_address: "A0:B1:C2:D3:E4:F5" # vehicle BLE MAC address
tesla_vin: "5YJ30123456789ABC" # vehicle VIN
charging_amps_max: "32"

external_components: !include packages/external_components.dashboard.yml

packages:
base: !include packages/base.yml
client: !include packages/client.yml
common: !include packages/common.yml
# listener: !include packages/listener.yml # Uncomment this to scan find your VIN BLE MAC address
# for ESPHome Dashboard, use this instead of external_components

dashboard_import:
package_import_url: github://yoziru/esphome-tesla-ble/tesla-ble.example.yml

0 comments on commit e35aa6a

Please sign in to comment.