Skip to content

fix send on when ac is on #990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions custom_components/smartir/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def __init__(self, hass, config, device_data):
self._current_fan_mode = self._fan_modes[0]
self._current_swing_mode = None
self._last_on_operation = None
self._last_operation = None

self._current_temperature = None
self._current_humidity = None
Expand Down Expand Up @@ -166,6 +167,9 @@ async def async_added_to_hass(self):
if 'last_on_operation' in last_state.attributes:
self._last_on_operation = last_state.attributes['last_on_operation']

if 'last_operation' in last_state.attributes:
self._last_operation = last_state.attributes['last_operation']

if self._temperature_sensor:
async_track_state_change(self.hass, self._temperature_sensor,
self._async_temp_sensor_changed)
Expand Down Expand Up @@ -243,6 +247,11 @@ def last_on_operation(self):
"""Return the last non-idle operation ie. heat, cool."""
return self._last_on_operation

@property
def last_operation(self):
"""Return the last operation ie. heat, cool."""
return self._last_operation

@property
def fan_modes(self):
"""Return the list of available fan modes."""
Expand Down Expand Up @@ -283,6 +292,7 @@ def extra_state_attributes(self):
"""Platform specific attributes."""
return {
'last_on_operation': self._last_on_operation,
'last_operation': self._last_operation,
'device_code': self._device_code,
'manufacturer': self._manufacturer,
'supported_models': self._supported_models,
Expand Down Expand Up @@ -322,8 +332,11 @@ async def async_set_hvac_mode(self, hvac_mode):

if not hvac_mode == HVAC_MODE_OFF:
self._last_on_operation = hvac_mode

await self.send_command()

self._last_operation = hvac_mode

await self.async_update_ha_state()

async def async_set_fan_mode(self, fan_mode):
Expand Down Expand Up @@ -366,7 +379,7 @@ async def send_command(self):
await self._controller.send(self._commands['off'])
return

if 'on' in self._commands:
if 'on' in self._commands and self._last_operation == 'off':
await self._controller.send(self._commands['on'])
await asyncio.sleep(self._delay)

Expand Down