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

fix: seat map different for auto climate command vs remote seat command #435

Merged
merged 2 commits into from
Dec 18, 2022
Merged
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
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