diff --git a/custom_components/teslafi/switch.py b/custom_components/teslafi/switch.py index 788074e..5043502 100644 --- a/custom_components/teslafi/switch.py +++ b/custom_components/teslafi/switch.py @@ -23,6 +23,17 @@ available=lambda u, v, h: u and _convert_to_bool(v.get("is_climate_on")), cmd=lambda c, v: c.execute_command("steering_wheel_heater", statement=v), ), + TeslaFiSwitchEntityDescription( + key="_set_charging", + name="Charging", + icon="mdi:ev-station", + entity_registry_enabled_default=False, + device_class=SwitchDeviceClass.SWITCH, + entity_category=EntityCategory.DIAGNOSTIC, + available=lambda u, v, h: u and v.is_plugged_in, + value=lambda d, h: d.is_charging, + cmd=lambda c, v: c.execute_command("charge_start" if v else "charge_stop"), + ), ] @@ -38,10 +49,12 @@ def _handle_coordinator_update(self) -> None: async def async_turn_on(self, **kwargs: Any) -> None: await self.entity_description.cmd(self.coordinator, True) + self._attr_is_on = True return self.async_write_ha_state() async def async_turn_off(self, **kwargs: Any) -> None: await self.entity_description.cmd(self.coordinator, False) + self._attr_is_on = False return self.async_write_ha_state()