From 9e4368cfd44a2d1a2c44f72c1e1b5a4b39e24ee9 Mon Sep 17 00:00:00 2001 From: Nikolay Vasilchuk Date: Fri, 22 Nov 2024 13:44:04 +0300 Subject: [PATCH] Add StarLine flex logic and panic buttons (#130819) Co-authored-by: Joost Lekkerkerker --- homeassistant/components/starline/button.py | 14 ++++++++++++++ homeassistant/components/starline/icons.json | 9 ++++++--- homeassistant/components/starline/strings.json | 6 ++++++ homeassistant/components/starline/switch.py | 4 ---- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/starline/button.py b/homeassistant/components/starline/button.py index ea1a27adc15..6fb307cda74 100644 --- a/homeassistant/components/starline/button.py +++ b/homeassistant/components/starline/button.py @@ -16,6 +16,20 @@ BUTTON_TYPES: tuple[ButtonEntityDescription, ...] = ( key="poke", translation_key="horn", ), + ButtonEntityDescription( + key="panic", + translation_key="panic", + entity_registry_enabled_default=False, + ), + *[ + ButtonEntityDescription( + key=f"flex_{i}", + translation_key="flex", + translation_placeholders={"num": str(i)}, + entity_registry_enabled_default=False, + ) + for i in range(1, 10) + ], ) diff --git a/homeassistant/components/starline/icons.json b/homeassistant/components/starline/icons.json index e240978ce74..d7d20ae03bd 100644 --- a/homeassistant/components/starline/icons.json +++ b/homeassistant/components/starline/icons.json @@ -20,6 +20,12 @@ "button": { "horn": { "default": "mdi:bullhorn-outline" + }, + "flex": { + "default": "mdi:star-circle-outline" + }, + "panic": { + "default": "mdi:alarm-note" } }, "device_tracker": { @@ -63,9 +69,6 @@ "on": "mdi:access-point-network" } }, - "horn": { - "default": "mdi:bullhorn-outline" - }, "service_mode": { "default": "mdi:car-wrench", "state": { diff --git a/homeassistant/components/starline/strings.json b/homeassistant/components/starline/strings.json index a330354e5a9..0a30ea5b5be 100644 --- a/homeassistant/components/starline/strings.json +++ b/homeassistant/components/starline/strings.json @@ -124,6 +124,12 @@ "button": { "horn": { "name": "Horn" + }, + "flex": { + "name": "Flex logic {num}" + }, + "panic": { + "name": "Panic mode" } } }, diff --git a/homeassistant/components/starline/switch.py b/homeassistant/components/starline/switch.py index 1b48a72c732..05193d98c8a 100644 --- a/homeassistant/components/starline/switch.py +++ b/homeassistant/components/starline/switch.py @@ -78,8 +78,6 @@ class StarlineSwitch(StarlineEntity, SwitchEntity): @property def is_on(self): """Return True if entity is on.""" - if self._key == "poke": - return False return self._device.car_state.get(self._key) def turn_on(self, **kwargs: Any) -> None: @@ -88,6 +86,4 @@ class StarlineSwitch(StarlineEntity, SwitchEntity): def turn_off(self, **kwargs: Any) -> None: """Turn the entity off.""" - if self._key == "poke": - return self._account.api.set_car_state(self._device.device_id, self._key, False)