diff --git a/custom_components/tesla_custom/climate.py b/custom_components/tesla_custom/climate.py index 150426b0..b1eea7f1 100644 --- a/custom_components/tesla_custom/climate.py +++ b/custom_components/tesla_custom/climate.py @@ -157,6 +157,7 @@ def refresh(self) -> None: vin = self.tesla_device.vin() # Get all the climate parameters so we can determine what is supported by this vin. + # pylint: disable=protected-access climate_params = self.tesla_device._controller.get_climate_params(vin=vin) if climate_params is None or len(climate_params) == 0: # No data available @@ -203,15 +204,18 @@ async def update_climate_related_devices(self): # We have to manually update the controller becuase changing the HVAC state only updates its state in Home assistant, # and not the underlying cache in cliamte_parms. This does mean we talk to Tesla, but we only do so Once. + # pylint: disable=protected-access await self.tesla_device._controller.update( self.tesla_device._id, wake_if_asleep=False, force=True ) + vin = self.tesla_device.vin() + for c_device in CLIMATE_DEVICES: _LOGGER.debug("Refreshing Device: %s.%s", c_device[0], c_device[1]) device = await get_device( - self.hass, self.config_entry_id, c_device[0], c_device[1] + self.hass, self.config_entry_id, c_device[0], c_device[1], vin ) if device is not None: class_name = device.__class__.__name__ diff --git a/custom_components/tesla_custom/helpers.py b/custom_components/tesla_custom/helpers.py index ffe7597e..3b60e77c 100644 --- a/custom_components/tesla_custom/helpers.py +++ b/custom_components/tesla_custom/helpers.py @@ -19,6 +19,7 @@ async def get_device( config_entry_id: str, device_category: str, device_type: str, + vin: str, ): """Get a tesla Device for a Config Entry ID.""" @@ -26,7 +27,7 @@ async def get_device( devices = entry_data["devices"].get(device_category, []) for device in devices: - if device.type == device_type: + if device.type == device_type and device.vin() == vin: return device return None @@ -68,14 +69,14 @@ def enable_entity( async def wait_for_climate( - hass: HomeAssistant, config_entry_id: str, timeout: int = 30 + hass: HomeAssistant, config_entry_id: str, vin: str, timeout: int = 30 ): """Wait for HVac. Optional Timeout. defaults to 30 seconds """ climate_device = await get_device( - hass, config_entry_id, "climate", "HVAC (climate) system" + hass, config_entry_id, "climate", "HVAC (climate) system", vin ) if climate_device is None: diff --git a/custom_components/tesla_custom/select.py b/custom_components/tesla_custom/select.py index 59682de1..8b91987f 100644 --- a/custom_components/tesla_custom/select.py +++ b/custom_components/tesla_custom/select.py @@ -35,7 +35,8 @@ async def async_select_option(self, option: str, **kwargs): """Change the selected option.""" level: int = OPTIONS.index(option) - await wait_for_climate(self.hass, self.config_entry_id) + vin = self.tesla_device.vin() + await wait_for_climate(self.hass, self.config_entry_id, vin) _LOGGER.debug("Setting %s to %s", self.name, level) await self.tesla_device.set_seat_heat_level(level) self.async_write_ha_state() diff --git a/custom_components/tesla_custom/switch.py b/custom_components/tesla_custom/switch.py index 24726825..f0d5b003 100644 --- a/custom_components/tesla_custom/switch.py +++ b/custom_components/tesla_custom/switch.py @@ -35,7 +35,10 @@ class HeatedSteeringWheelSwitch(TeslaDevice, SwitchEntity): async def async_turn_on(self, **kwargs): """Send the on command.""" _LOGGER.debug("Turn on Heating Steering Wheel: %s", self.name) - await wait_for_climate(self.hass, self.config_entry_id) + + vin = self.tesla_device.vin() + await wait_for_climate(self.hass, self.config_entry_id, vin) + await self.tesla_device.set_steering_wheel_heat(True) self.async_write_ha_state()