diff --git a/teslajsonpy/car.py b/teslajsonpy/car.py index df9e568..a659fb0 100644 --- a/teslajsonpy/car.py +++ b/teslajsonpy/car.py @@ -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. @@ -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: diff --git a/tests/tesla_mock.py b/tests/tesla_mock.py index ae0a0c8..9733650 100644 --- a/tests/tesla_mock.py +++ b/tests/tesla_mock.py @@ -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, diff --git a/tests/unit_tests/test_car.py b/tests/unit_tests/test_car.py index bbcf630..94347b0 100644 --- a/tests/unit_tests/test_car.py +++ b/tests/unit_tests/test_car.py @@ -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"] @@ -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."""