Skip to content

Commit

Permalink
feat: add pedestrian speaker and remote_boombox (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
InTheDaylight14 committed Dec 21, 2022
1 parent 8477106 commit 81cbb13
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
19 changes: 19 additions & 0 deletions teslajsonpy/car.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,13 @@ def steering_wheel_heater(self) -> bool:
is not None
)

@property
def pedestrian_speaker(self) -> bool:
"""Return pedestrian warning speaker option."""
if "P3WS" in self._vehicle_data.get("option_codes", {}):
return True
return False

@property
def tpms_pressure_fl(self) -> float:
"""Return tire pressure sensor for front left tire."""
Expand Down Expand Up @@ -1269,3 +1276,15 @@ async def set_scheduled_charging(self, enable: bool, time: int) -> None:
"scheduled_charging_pending": enable,
}
self._vehicle_data["charge_state"].update(params)

async def remote_boombox(self) -> None:
"""Remote boombox."""
data = await self._send_command("REMOTE_BOOMBOX")

if data and data["response"]:
result = data["response"]["result"]
reason = data["response"]["reason"]
if result is False:
_LOGGER.debug("Error calling remote boombox: %s", reason)
else:
_LOGGER.debug("Remote boombox called successfully.")
7 changes: 6 additions & 1 deletion teslajsonpy/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,11 @@
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/remote_auto_seat_climate_request"
},
"REMOTE_BOOMBOX": {
"AUTH": true,
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/remote_boombox"
},
"REMOTE_SEAT_COOLING_REQUEST": {
"AUTH": true,
"TYPE": "POST",
Expand Down Expand Up @@ -2001,4 +2006,4 @@
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/window_control"
}
}
}
8 changes: 4 additions & 4 deletions tests/tesla_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def controller_get_battery_summary(self):
async def controller_get_vehicle_data(self):
"""Monkeypatch for controller.get_vehicle_data()."""
return self._vehicle_data

async def controller_get_vehicle_summary(self):
"""Monkeypatch for controller.get_vehicle_summary()."""
return self._product_list[0]
Expand Down Expand Up @@ -305,7 +305,7 @@ def command_ok():
"vehicle_id": 1234567890,
"vin": "5YJSA11111111111",
"display_name": "My Model S",
"option_codes": "AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0",
"option_codes": "AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0,P3WS",
"color": None,
"access_type": "OWNER",
"tokens": ["abcdef1234567890", "1234567890abcdef"],
Expand Down Expand Up @@ -412,7 +412,7 @@ def command_ok():
"vehicle_id": 1234567890,
"vin": "5YJSA11111111111",
"display_name": "My Model S",
"option_codes": "AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0",
"option_codes": "AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0,P3WS",
"color": None,
"access_type": "OWNER",
"tokens": ["redacted", "redacted"],
Expand Down Expand Up @@ -646,7 +646,7 @@ def command_ok():
"vehicle_id": 1234567890,
"vin": "5YJSA11111111111",
"display_name": "My Model S",
"option_codes": "AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0",
"option_codes": "AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0,P3WS",
"color": None,
"access_type": "OWNER",
"tokens": ["redacted", "redacted"],
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 @@ -238,6 +238,8 @@ async def test_car_properties(monkeypatch):
VEHICLE_DATA["climate_state"].get("steering_wheel_heater") is not None
)

assert _car.pedestrian_speaker == ("P3WS" in VEHICLE_DATA["option_codes"])

assert _car.third_row_seats == str(
VEHICLE_DATA["vehicle_state"].get("third_row_seats")
)
Expand Down Expand Up @@ -720,3 +722,15 @@ async def test_set_scheduled_charging(monkeypatch):
assert await _car.set_scheduled_charging(True, 420) is None

assert await _car.set_scheduled_charging(False, 420) is None


@pytest.mark.asyncio
async def test_remote_boombox(monkeypatch):
"""Test remote boombox."""
TeslaMock(monkeypatch)
_controller = Controller(None)
await _controller.connect()
await _controller.generate_car_objects()
_car = _controller.cars[VIN]

assert await _car.remote_boombox() is None

0 comments on commit 81cbb13

Please sign in to comment.