File tree 1 file changed +14
-6
lines changed
custom_components/wemportal
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 9
9
from homeassistant .helpers .entity_platform import AddEntitiesCallback
10
10
from homeassistant .helpers .update_coordinator import CoordinatorEntity
11
11
12
- from .const import DOMAIN
12
+ from .const import DOMAIN , _LOGGER
13
13
from . import get_wemportal_unique_id
14
14
15
15
@@ -116,11 +116,19 @@ def options(self) -> list[str]:
116
116
@property
117
117
def current_option (self ) -> str :
118
118
"""Return the current option."""
119
- return self ._options_names [
120
- self ._options .index (
121
- self .coordinator .data [self ._device_id ][self ._name ]["value" ]
122
- )
123
- ]
119
+ try :
120
+ options = self ._options_names [
121
+ self ._options .index (
122
+ self .coordinator .data [self ._device_id ][self ._name ]["value" ]
123
+ )
124
+ ]
125
+ if options :
126
+ return options
127
+ except KeyError :
128
+ _LOGGER .warning ("Can't find %s" , self ._unique_id )
129
+ _LOGGER .debug ("Sensor data %s" , self .coordinator .data )
130
+
131
+ return None
124
132
125
133
async def async_added_to_hass (self ):
126
134
"""When entity is added to hass."""
You can’t perform that action at this time.
0 commit comments