Skip to content

Commit

Permalink
feat: Add bioweapon mode (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandelionclock authored May 25, 2024
1 parent 5803719 commit 02c7175
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
25 changes: 25 additions & 0 deletions teslajsonpy/car.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ def charger_voltage(self) -> int:
"""Return charger voltage."""
return self._vehicle_data.get("charge_state", {}).get("charger_voltage")

@property
def bioweapon_mode(self) -> bool:
"""Return bioweapon defense mode."""
return self._vehicle_data.get("climate_state", {}).get("bioweapon_mode")

@property
def climate_keeper_mode(self) -> str:
"""Return climate keeper mode mode.
Expand Down Expand Up @@ -956,6 +961,26 @@ async def set_climate_keeper_mode(self, keeper_id: int) -> None:
}
self._vehicle_data["climate_state"].update(params)

async def set_bioweapon_mode(self, enable: bool) -> None:
"""Send command to set bioweapon mode.
Args
enable: 'True' to enable, 'False' to disable
"""
# If car is asleep, bioweapon is already off
data = await self._send_command(
"HVAC_BIOWEAPON_MODE",
on=enable,
manual_override=True,
)
if data and data["response"]["result"] is True:
params = {
"bioweapon_mode": enable,
"is_climate_on": True,
}
self._vehicle_data["climate_state"].update(params)

async def remote_auto_seat_climate_request(
self, seat_id: int, enable: bool
) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/tesla_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def command_ok():
"auto_steering_wheel_heat": True,
"battery_heater": False,
"battery_heater_no_power": False,
"bioweapon_mode": False,
"cabin_overheat_protection": "Off",
"climate_keeper_mode": "off",
"defrost_mode": 0,
Expand Down
14 changes: 14 additions & 0 deletions tests/unit_tests/test_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ async def test_car_properties(monkeypatch):

assert _car.battery_range == VEHICLE_DATA["charge_state"]["battery_range"]

assert _car.bioweapon_mode == VEHICLE_DATA["climate_state"]["bioweapon_mode"]

assert (
_car.cabin_overheat_protection
== VEHICLE_DATA["climate_state"]["cabin_overheat_protection"]
Expand Down Expand Up @@ -452,6 +454,18 @@ async def test_schedule_software_update(monkeypatch):
assert await _car.schedule_software_update() is None


@pytest.mark.asyncio
async def test_set_bioweapon_mode(monkeypatch):
"""Test setting bioweapon mode."""
TeslaMock(monkeypatch)
_controller = Controller(None)
await _controller.connect()
await _controller.generate_car_objects()
_car = _controller.cars[VIN]

assert await _car.set_bioweapon_mode(True) is None


@pytest.mark.asyncio
async def test_set_charging_amps(monkeypatch):
"""Test setting charging amps."""
Expand Down

0 comments on commit 02c7175

Please sign in to comment.