Created
December 21, 2024 03:46
-
-
Save pccr10001/8a6394db1dc2922433517435ccf8689c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
name: ble-tesla-8bubu | |
friendly_name: ble-tesla-8bubu | |
project: | |
name: yoziru.esphome-tesla-ble | |
version: "2024.8.1" | |
libraries: | |
- https://github.com/yoziru/tesla-ble.git#v2.2.1 | |
on_boot: | |
then: | |
output.turn_off: tcsLed | |
platformio_options: | |
board_build.flash_mode: dio | |
substitutions: | |
espidf_version: "5.3.0" | |
platformio_version: "6.8.1" | |
ble_mac_address: !secret ble_mac_address_8bubu | |
tesla_vin: !secret tesla_vin_8bubu | |
charging_amps_max: "32" | |
esp32: | |
board: esp32-c3-devkitm-1 | |
variant: ESP32C3 | |
framework: | |
type: esp-idf | |
version: $espidf_version | |
platform_version: $platformio_version | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: "////////////////////////////////////" | |
ota: | |
- platform: esphome | |
password: "000000000000000000000000000000000" | |
external_components: | |
- components: [tesla_ble_vehicle, tesla_ble_listener] | |
source: github://yoziru/esphome-tesla-ble/components@main | |
ble_client: | |
- mac_address: $ble_mac_address | |
id: ble_tesla_id | |
tesla_ble_vehicle: | |
ble_client_id: ble_tesla_id | |
id: tesla_ble_vehicle_id | |
vin: $tesla_vin | |
update_interval: 5s | |
is_asleep: | |
name: "Asleep" | |
is_user_present: | |
name: "User presence" | |
is_unlocked: | |
name: "Doors" | |
is_charge_flap_open: | |
name: "Charge flap" | |
button: | |
- platform: restart | |
name: Restart | |
icon: mdi:restart | |
entity_category: diagnostic | |
- platform: template | |
id: ble_pair | |
name: Pair BLE key | |
icon: mdi:key-wireless | |
on_press: | |
- lambda: id(tesla_ble_vehicle_id)->startPair(); | |
entity_category: diagnostic | |
- platform: template | |
name: Wake up | |
icon: mdi:sleep-off | |
on_press: | |
- lambda: id(tesla_ble_vehicle_id)->wakeVehicle(); | |
- platform: template | |
name: Regenerate key | |
icon: mdi:key-change | |
on_press: | |
- lambda: id(tesla_ble_vehicle_id)->regenerateKey(); | |
entity_category: diagnostic | |
disabled_by_default: true | |
- platform: template | |
name: Force data update | |
icon: mdi:database-sync | |
on_press: | |
- lambda: id(tesla_ble_vehicle_id)->enqueueVCSECInformationRequest(true); | |
entity_category: diagnostic | |
switch: | |
- platform: template | |
name: "Charger switch" | |
optimistic: true | |
assumed_state: true # we can't read the state of the charger over | |
restore_mode: RESTORE_DEFAULT_OFF | |
turn_on_action: | |
- lambda: id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_CHARGING_SWITCH, 1); | |
turn_off_action: | |
- lambda: id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_CHARGING_SWITCH, 0); | |
- platform: ble_client | |
ble_client_id: ble_tesla_id | |
name: "BLE Connection" | |
entity_category: diagnostic | |
number: | |
- platform: template | |
name: "Charging amps" | |
id: charging_amps | |
icon: mdi:ev-station | |
unit_of_measurement: "A" | |
mode: slider | |
min_value: 0 | |
max_value: $charging_amps_max | |
step: 1 | |
optimistic: true | |
restore_value: true | |
on_value: | |
then: | |
- lambda: |- | |
int var_x = static_cast<int>(x); | |
id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_CHARGING_AMPS, var_x); | |
- platform: template | |
name: "Charging limit" | |
id: charging_limit | |
icon: mdi:ev-station | |
unit_of_measurement: "%" | |
mode: slider | |
min_value: 50 | |
max_value: 100 | |
step: 1 | |
optimistic: true | |
restore_value: true | |
on_value: | |
then: | |
- lambda: |- | |
int var_x = static_cast<int>(x); | |
id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_CHARGING_LIMIT, var_x); | |
sensor: | |
- platform: wifi_signal | |
name: "WiFi Signal" | |
update_interval: 60s | |
icon: mdi:wifi | |
- platform: uptime | |
name: "Uptime" | |
update_interval: 60s | |
icon: mdi:clock-outline | |
- platform: ble_client | |
type: rssi | |
ble_client_id: ble_tesla_id | |
name: "BLE Signal" | |
icon: mdi:bluetooth | |
update_interval: 60s | |
entity_category: diagnostic | |
- platform: tcs34725 | |
red_channel: | |
name: "TCS34725 Red Channel" | |
green_channel: | |
name: "TCS34725 Green Channel" | |
blue_channel: | |
name: "TCS34725 Blue Channel" | |
clear_channel: | |
name: "TCS34725 Clear Channel" | |
glass_attenuation_factor: 1.0 | |
address: 0x29 | |
integration_time: 50ms | |
update_interval: 1s | |
binary_sensor: | |
- platform: status | |
name: "Status" | |
text_sensor: | |
- platform: version | |
name: "Version" | |
icon: mdi:cube-outline | |
- platform: wifi_info | |
ip_address: | |
name: "IP Address" | |
time: | |
- platform: homeassistant | |
id: homeassistant_time | |
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: | |
ssid: "Ble-Tesla-9Bi Fallback Hotspot" | |
password: "aaaaaaaaaaaaa" | |
# 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: | |
output: | |
- platform: gpio | |
pin: GPIO1 | |
id: tcsLed | |
i2c: | |
sda: GPIO3 | |
scl: GPIO4 | |
scan: true | |
id: bus_a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment