Skip to content

Commit

Permalink
Fix again async in iFan 3
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Feb 26, 2020
1 parent c6a064c commit b756fd1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions custom_components/sonoff/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ def _update(self, device: EWeLinkDevice):
if self.hass:
self.schedule_update_ha_state()

async def set_speed(self, speed: str) -> None:
async def async_set_speed(self, speed: str) -> None:
channels = IFAN02_STATES.get(speed)
await self.device.turn_bulk(channels)

async def turn_on(self, speed: Optional[str] = None, **kwargs) -> None:
async def async_turn_on(self, speed: Optional[str] = None, **kwargs):
if speed:
await self.set_speed(speed)
await self.async_set_speed(speed)
else:
await self.device.turn_on([2])

async def turn_off(self, **kwargs) -> None:
async def async_turn_off(self, **kwargs) -> None:
await self.device.turn_off([2])


Expand All @@ -128,15 +128,15 @@ def _update(self, device: EWeLinkDevice):
if self.hass:
self.schedule_update_ha_state()

async def set_speed(self, speed: str) -> None:
async def async_set_speed(self, speed: str) -> None:
speed = self.speed_list.index(speed)
await self.device.send('fan', {'fan': 'on', 'speed': speed})

async def turn_on(self, speed: Optional[str] = None, **kwargs) -> None:
async def async_turn_on(self, speed: Optional[str] = None, **kwargs):
if speed:
await self.set_speed(speed)
await self.async_set_speed(speed)
else:
await self.device.send('fan', {'fan': 'on'})

async def turn_off(self, **kwargs) -> None:
async def async_turn_off(self, **kwargs) -> None:
await self.device.send('fan', {'fan': 'off'})
4 changes: 2 additions & 2 deletions custom_components/sonoff/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def _update(self, device: EWeLinkDevice):
if self.hass:
self.schedule_update_ha_state()

async def turn_on(self, **kwargs) -> None:
async def async_turn_on(self, **kwargs) -> None:
await self.device.send('light', {'light': 'on'})

async def turn_off(self, **kwargs) -> None:
async def async_turn_off(self, **kwargs) -> None:
await self.device.send('light', {'light': 'off'})


Expand Down
2 changes: 1 addition & 1 deletion custom_components/sonoff/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def async_turn_on(self, **kwargs):
self._state = True
self.schedule_update_ha_state()

async def turn_off(self, **kwargs):
async def async_turn_off(self, **kwargs):
self._state = False
self.schedule_update_ha_state()

Expand Down

0 comments on commit b756fd1

Please sign in to comment.