diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 927ad5c5..4b1297f7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,14 +35,14 @@ repos: - id: check-yaml exclude: ^recipes/.* repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 # --- Commit msg checks --- - hooks: - id: commitizen stages: ["commit-msg"] repo: https://github.com/commitizen-tools/commitizen - rev: v3.13.0 + rev: v3.27.0 # --- Linters --- - hooks: - id: dockerfile_lint @@ -59,9 +59,9 @@ repos: (?x)^( CHANGELOG.md )$ - rev: v3.0.0 + rev: v4.0.0-alpha.8 - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 + rev: v3.16.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -80,7 +80,7 @@ repos: - --configfile=tests/bandit.yaml files: ^(tests)/.+\.py$ - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort # - repo: local diff --git a/custom_components/tesla_custom/climate.py b/custom_components/tesla_custom/climate.py index 1cab27f2..37961989 100644 --- a/custom_components/tesla_custom/climate.py +++ b/custom_components/tesla_custom/climate.py @@ -18,9 +18,9 @@ KEEPER_MAP = { - "Keep On": 1, - "Dog Mode": 2, - "Camp Mode": 3, + "keep": 1, + "dog": 2, + "camp": 3, } @@ -46,8 +46,12 @@ class TeslaCarClimate(TeslaCarEntity, ClimateEntity): | ClimateEntityFeature.FAN_MODE ) _attr_hvac_modes = [HVACMode.HEAT_COOL, HVACMode.OFF] - _attr_preset_modes = ["Normal", "Defrost", "Keep On", "Dog Mode", "Camp Mode"] - _attr_fan_modes = ["Off", "Bioweapon Mode"] + _attr_preset_modes = ["normal", "defrost", "keep", "dog", "camp"] + _attr_fan_modes = ["off", "bioweapon"] + + @property + def translation_key(self): + return "car_climate" @property def hvac_mode(self) -> HVACMode: @@ -121,21 +125,21 @@ def preset_mode(self): Requires SUPPORT_PRESET_MODE. """ if self._car.defrost_mode == 2: - return "Defrost" + return "defrost" if self._car.climate_keeper_mode == "dog": - return "Dog Mode" + return "dog" if self._car.climate_keeper_mode == "camp": - return "Camp Mode" + return "camp" if self._car.climate_keeper_mode == "on": - return "Keep On" + return "keep" - return "Normal" + return "normal" async def async_set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" _LOGGER.debug("%s: Setting preset_mode to: %s", self.name, preset_mode) - if preset_mode == "Normal": + if preset_mode == "normal": # If setting Normal, we need to check Defrost And Keep modes. if self._car.defrost_mode != 0: await self._car.set_max_defrost(0) @@ -143,7 +147,7 @@ async def async_set_preset_mode(self, preset_mode: str) -> None: if self._car.climate_keeper_mode != 0: await self._car.set_climate_keeper_mode(0) - elif preset_mode == "Defrost": + elif preset_mode == "defrost": await self._car.set_max_defrost(2) else: @@ -158,12 +162,12 @@ def fan_mode(self): Requires SUPPORT_FAN_MODE. """ if self._car.bioweapon_mode: - return "Bioweapon Mode" + return "bioweapon" - return "Off" + return "off" async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new fan mode as bioweapon mode.""" _LOGGER.debug("%s: Setting fan_mode to: %s", self.name, fan_mode) - await self._car.set_bioweapon_mode(fan_mode == "Bioweapon Mode") + await self._car.set_bioweapon_mode(fan_mode == "bioweapon") diff --git a/custom_components/tesla_custom/icons.json b/custom_components/tesla_custom/icons.json new file mode 100644 index 00000000..9c58cf7f --- /dev/null +++ b/custom_components/tesla_custom/icons.json @@ -0,0 +1,25 @@ +{ + "entity": { + "climate": { + "car_climate": { + "state_attributes": { + "fan_mode": { + "state": { + "bioweapon": "mdi:biohazard", + "off": "mdi:power" + } + }, + "preset_mode": { + "state": { + "normal": "mdi:fan", + "defrost": "mdi:car-defrost-rear", + "keep": "mdi:infinity", + "dog": "mdi:dog", + "camp": "mdi:tent" + } + } + } + } + } + } +} diff --git a/custom_components/tesla_custom/strings.json b/custom_components/tesla_custom/strings.json index 5a35b1af..e49cf120 100644 --- a/custom_components/tesla_custom/strings.json +++ b/custom_components/tesla_custom/strings.json @@ -82,5 +82,28 @@ } } } + }, + "entity": { + "climate": { + "car_climate": { + "state_attributes": { + "fan_mode": { + "state": { + "bioweapon": "Bioweapon Mode", + "off": "Normal" + } + }, + "preset_mode": { + "state": { + "normal": "Normal", + "defrost": "Defrost", + "keep": "Keep On", + "dog": "Dog Mode", + "camp": "Camp Mode" + } + } + } + } + } } } diff --git a/custom_components/tesla_custom/translations/en.json b/custom_components/tesla_custom/translations/en.json index 5a35b1af..e49cf120 100644 --- a/custom_components/tesla_custom/translations/en.json +++ b/custom_components/tesla_custom/translations/en.json @@ -82,5 +82,28 @@ } } } + }, + "entity": { + "climate": { + "car_climate": { + "state_attributes": { + "fan_mode": { + "state": { + "bioweapon": "Bioweapon Mode", + "off": "Normal" + } + }, + "preset_mode": { + "state": { + "normal": "Normal", + "defrost": "Defrost", + "keep": "Keep On", + "dog": "Dog Mode", + "camp": "Camp Mode" + } + } + } + } + } } } diff --git a/tests/test_climate.py b/tests/test_climate.py index f8d88097..51e88880 100644 --- a/tests/test_climate.py +++ b/tests/test_climate.py @@ -92,7 +92,7 @@ async def test_set_fan_mode(hass: HomeAssistant) -> None: "set_fan_mode", { ATTR_ENTITY_ID: DEVICE_ID, - "fan_mode": "Bioweapon Mode", + "fan_mode": "bioweapon", }, blocking=True, ) @@ -113,7 +113,7 @@ async def test_set_preset_mode(hass: HomeAssistant) -> None: "set_preset_mode", { ATTR_ENTITY_ID: DEVICE_ID, - "preset_mode": "Normal", + "preset_mode": "normal", }, blocking=True, ) @@ -131,7 +131,7 @@ async def test_set_preset_mode(hass: HomeAssistant) -> None: "set_preset_mode", { ATTR_ENTITY_ID: DEVICE_ID, - "preset_mode": "Normal", + "preset_mode": "normal", }, blocking=True, ) @@ -144,7 +144,7 @@ async def test_set_preset_mode(hass: HomeAssistant) -> None: "set_preset_mode", { ATTR_ENTITY_ID: DEVICE_ID, - "preset_mode": "Defrost", + "preset_mode": "defrost", }, blocking=True, ) @@ -159,7 +159,7 @@ async def test_set_preset_mode(hass: HomeAssistant) -> None: "set_preset_mode", { ATTR_ENTITY_ID: DEVICE_ID, - "preset_mode": "Dog Mode", + "preset_mode": "dog", }, blocking=True, )