Skip to content

Commit

Permalink
fix: fix seat map for auto climate command (#435)
Browse files Browse the repository at this point in the history
closes #433
  • Loading branch information
InTheDaylight14 authored Dec 18, 2022
1 parent 8a518c9 commit c96e5b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions custom_components/tesla_custom/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
"third row right": 7,
}

AUTO_SEAT_ID_MAP = {
"left": 1,
"right": 2,
}


async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities):
"""Set up the Tesla selects by config_entry."""
Expand Down Expand Up @@ -118,12 +123,12 @@ async def async_select_option(self, option: str, **kwargs):
if self._is_auto_available and option == FRONT_HEATER_OPTIONS[4]:
_LOGGER.debug("Setting %s to %s", SEAT_ID_MAP[self._seat_name], option)
await self._car.remote_auto_seat_climate_request(
SEAT_ID_MAP[self._seat_name], True
AUTO_SEAT_ID_MAP[self._seat_name], True
)
else:
if self.current_option == FRONT_HEATER_OPTIONS[4]:
await self._car.remote_auto_seat_climate_request(
SEAT_ID_MAP[self._seat_name], False
AUTO_SEAT_ID_MAP[self._seat_name], False
)

level: int = HEATER_OPTIONS.index(option)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def test_car_heated_seat_select(hass: HomeAssistant) -> None:
{ATTR_ENTITY_ID: "select.my_model_s_heated_seat_left", "option": "Auto"},
blocking=True,
)
mock_remote_auto_seat_climate_request.assert_awaited_once_with(0, True)
mock_remote_auto_seat_climate_request.assert_awaited_once_with(1, True)
# Test from "Auto" selection
car_mock_data.VEHICLE_DATA["climate_state"]["auto_seat_climate_left"] = True
assert await hass.services.async_call(
Expand All @@ -93,7 +93,7 @@ async def test_car_heated_seat_select(hass: HomeAssistant) -> None:
{ATTR_ENTITY_ID: "select.my_model_s_heated_seat_left", "option": "Low"},
blocking=True,
)
mock_remote_auto_seat_climate_request.assert_awaited_with(0, False)
mock_remote_auto_seat_climate_request.assert_awaited_with(1, False)

with patch("teslajsonpy.car.TeslaCar.set_hvac_mode") as mock_set_hvac_mode:
# Test climate_on check
Expand Down

0 comments on commit c96e5b0

Please sign in to comment.