Skip to content

Commit

Permalink
Improve roller shutter initial update
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogeniola committed Apr 16, 2024
1 parent 78706f4 commit c3de604
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions meross_iot/controller/mixins/roller_shutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async def async_update(self, timeout: Optional[float] = None, *args, **kwargs) -
await super().async_update(*args, **kwargs)
# Update the configuration at the same time
await self.async_fetch_config()
await self.async_fetch_position()

async def async_fetch_config(self, timeout: Optional[float] = None, *args, **kwargs) -> None:
data = await self._execute_command(method="GET",
Expand All @@ -124,6 +125,16 @@ async def async_fetch_config(self, timeout: Optional[float] = None, *args, **kwa
channel_config = d.copy()
self._shutter__config_by_channel[channel] = channel_config

async def async_fetch_position(self, timeout: Optional[float] = None, *args, **kwargs) -> None:
data = await self._execute_command(method="GET",
namespace=Namespace.ROLLER_SHUTTER_POSITION,
payload={},
timeout=timeout)
positions = data.get('position')
for p in positions:
channel = p['channel']
self._shutter__position_by_channel[channel] = p["position"]

def get_open_timer_duration_millis(self, channel: int = 0, *args, **kwargs) -> int:
self.check_full_update_done()
return self._shutter__config_by_channel.get(channel).get("signalOpen")
Expand Down

0 comments on commit c3de604

Please sign in to comment.