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

Added sentry mode switch #83

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/tesla_ble_vehicle/tesla_ble_vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,9 @@ namespace esphome
std::string action_str;
switch (action)
{
case SET_SENTRY_SWITCH:
action_str = "setSentrySwitch";
break;
case SET_CHARGING_SWITCH:
action_str = "setChargingSwitch";
break;
Expand All @@ -1247,6 +1250,10 @@ namespace esphome
ESP_LOGI(TAG, "[%s] Building message..", action_str.c_str());
switch (action)
{
case SET_SENTRY_SWITCH:
return_code = tesla_ble_client_->buildSentrySwitchMessage(
static_cast<bool>(param), message_buffer, &message_length);
break;
case SET_CHARGING_SWITCH:
return_code = tesla_ble_client_->buildChargingSwitchMessage(
static_cast<bool>(param), message_buffer, &message_length);
Expand Down
3 changes: 2 additions & 1 deletion components/tesla_ble_vehicle/tesla_ble_vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef enum BLE_CarServer_VehicleAction_E
{
SET_CHARGING_SWITCH,
SET_CHARGING_AMPS,
SET_CHARGING_LIMIT
SET_CHARGING_LIMIT,
SET_SENTRY_SWITCH
} BLE_CarServer_VehicleAction;

namespace esphome
Expand Down
10 changes: 10 additions & 0 deletions packages/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ switch:
turn_off_action:
- lambda: id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_CHARGING_SWITCH, 0);

- platform: template
name: "Sentry switch"
optimistic: true
assumed_state: true # we can't read the state
restore_mode: RESTORE_DEFAULT_OFF
turn_on_action:
- lambda: id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_SENTRY_SWITCH, 1);
turn_off_action:
- lambda: id(tesla_ble_vehicle_id)->sendCarServerVehicleActionMessage(SET_SENTRY_SWITCH, 0);

- platform: ble_client
ble_client_id: ble_tesla_id
name: "BLE Connection"
Expand Down