22
33from __future__ import annotations
44
5- import logging
6-
75from homeassistant .components .roborock .coordinator import RoborockDataUpdateCoordinator
86from homeassistant .components .roborock .entity import RoborockCoordinatedEntityV1
97from homeassistant .components .select import SelectEntity
2220 SIGNAL_ROTATION_CHANGED ,
2321)
2422
25- _LOGGER = logging .getLogger (__name__ )
26-
2723PARALLEL_UPDATES = 0
2824
2925
@@ -52,6 +48,7 @@ class RoborockMapRotationSelect(RoborockCoordinatedEntityV1, RestoreEntity, Sele
5248
5349 _attr_has_entity_name = True
5450 _attr_entity_category = EntityCategory .CONFIG
51+ _attr_translation_key = "rotation"
5552
5653 def __init__ (
5754 self ,
@@ -66,14 +63,14 @@ def __init__(
6663
6764 self .config_entry = config_entry
6865 self .map_flag = map_flag
66+ self .rotation_key = f"{ coordinator .duid_slug } _{ map_flag } "
6967
7068 if not map_name :
7169 map_name = f"Map { map_flag } "
7270
7371 self ._attr_name = f"{ map_name } rotation"
7472 self ._attr_options = [str (v ) for v in MAP_ROTATION_OPTIONS ]
7573 self ._attr_current_option = str (DEFAULT_MAP_ROTATION )
76- self ._attr_translation_key = "rotation"
7774
7875 async def async_added_to_hass (self ) -> None :
7976 """Restore previous rotation setting and store in hass.data."""
@@ -85,7 +82,7 @@ async def async_added_to_hass(self) -> None:
8582
8683 # Persist selection for the image entity to read
8784 self .hass .data [DOMAIN ][self .config_entry .entry_id ][CONF_MAP_ROTATION ][
88- self .map_flag
85+ self .rotation_key
8986 ] = int (self ._attr_current_option )
9087
9188 self .async_write_ha_state ()
@@ -98,13 +95,13 @@ async def async_select_option(self, option: str) -> None:
9895 self ._attr_current_option = option
9996
10097 self .hass .data [DOMAIN ][self .config_entry .entry_id ][CONF_MAP_ROTATION ][
101- self .map_flag
98+ self .rotation_key
10299 ] = int (option )
103100
104101 # Notify the image entity to bust the cache via image_last_updated bump
105102 async_dispatcher_send (
106103 self .hass ,
107- f"{ SIGNAL_ROTATION_CHANGED } _{ self .config_entry .entry_id } _{ self .map_flag } " ,
104+ f"{ SIGNAL_ROTATION_CHANGED } _{ self .config_entry .entry_id } _{ self .rotation_key } " ,
108105 )
109106
110107 self .async_write_ha_state ()
0 commit comments