diff --git a/README.md b/README.md index 7c384430..aefecf3d 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ This integration provides the following entities for vehicles: - Device tracker - car location1. - Locks - door lock, and charge port latch lock. **Note:** Set `state` to `heat_cool` or `off` to enable/disable your Tesla's climate system via a scene. -- Selects - seat heaters and cabin overheat protection2. +- Selects - seat heaters and cabin overheat protection2. **Note:** Turning on a heated seat will cause the climate to turn on. - Sensors - battery level, charge rate, energy added, inside/outside temperature, odometer and estimated range. - Switches - heated steering wheel, charger, sentry mode and polling1. - Update - software update2 diff --git a/custom_components/tesla_custom/select.py b/custom_components/tesla_custom/select.py index 081e8149..92c41a45 100644 --- a/custom_components/tesla_custom/select.py +++ b/custom_components/tesla_custom/select.py @@ -105,6 +105,9 @@ async def async_select_option(self, option: str, **kwargs): """Change the selected option.""" level: int = HEATER_OPTIONS.index(option) + if not self._car.is_climate_on and level > 0: + await self._car.set_hvac_mode("on") + _LOGGER.debug("Setting %s to %s", self.name, level) await self._car.remote_seat_heater_request(level, SEAT_ID_MAP[self._seat_name]) diff --git a/tests/test_select.py b/tests/test_select.py index 16fc3a25..ead86b10 100644 --- a/tests/test_select.py +++ b/tests/test_select.py @@ -74,6 +74,16 @@ async def test_car_heated_seat_select(hass: HomeAssistant) -> None: ) mock_remote_seat_heater_request.assert_awaited_with(3, 0) + with patch("teslajsonpy.car.TeslaCar.set_hvac_mode") as mock_set_hvac_mode: + # Test selecting "Low" + assert await hass.services.async_call( + SELECT_DOMAIN, + SERVICE_SELECT_OPTION, + {ATTR_ENTITY_ID: "select.my_model_s_heated_seat_left", "option": "Low"}, + blocking=True, + ) + mock_set_hvac_mode.assert_awaited_with("on") + async def test_cabin_overheat_protection(hass: HomeAssistant) -> None: """Tests car cabin overheat protection select."""