Skip to content

Commit 15f06fb

Browse files
committed
Removed polling for outlets
1 parent 7a5034d commit 15f06fb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

custom_components/dirigera_platform/base_classes.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __init__(self, hass, hub, json_data, get_by_id_fx) -> None:
4242
self._json_data = json_data
4343
self._get_by_id_fx = get_by_id_fx
4444
self._listeners : list[Entity] = []
45+
self._skip_update = False
4546

4647
# inject properties based on attr
4748
induce_properties(ikea_base_device, self._json_data.attributes.dict())
@@ -50,6 +51,14 @@ def __init__(self, hass, hub, json_data, get_by_id_fx) -> None:
5051
if self.should_register_with_listener:
5152
hub_event_listener.register(self._json_data.id, registry_entry(self))
5253

54+
@property
55+
def skip_update(self)->bool:
56+
return self._skip_update
57+
58+
@skip_update.setter
59+
def skip_update(self, value:bool):
60+
self._skip_update = value
61+
5362
def add_listener(self, entity : Entity) -> None:
5463
self._listeners.append(entity)
5564

@@ -84,6 +93,10 @@ def name(self):
8493
return self._json_data.attributes.custom_name
8594

8695
async def async_update(self):
96+
if self.skip_update:
97+
logger.debug(f"update skipped for {self.name} as marked to skip...")
98+
return
99+
87100
logger.debug(f"update called {self.name}")
88101
try:
89102
self._json_data = await self._hass.async_add_executor_job(self._get_by_id_fx, self._json_data.id)
@@ -160,7 +173,8 @@ async def async_update(self):
160173
class ikea_outlet_device(ikea_base_device):
161174
def __init__(self, hass, hub, json_data):
162175
super().__init__(hass, hub, json_data, hub.get_outlet_by_id)
163-
176+
self.skip_update = True
177+
164178
async def async_turn_on(self):
165179
logger.debug("outlet turn_on")
166180
try:

0 commit comments

Comments
 (0)