Skip to content

Flag to control if the climate is on before sending a command #1193

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
18 changes: 17 additions & 1 deletion custom_components/smartir/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def __init__(self, hass, config, device_data):

self._target_temperature = self._min_temperature
self._hvac_mode = HVAC_MODE_OFF

##ADDED
self._was_off = True

self._current_fan_mode = self._fan_modes[0]
self._current_swing_mode = None
self._last_on_operation = None
Expand Down Expand Up @@ -164,6 +168,11 @@ async def async_added_to_hass(self):

if last_state is not None:
self._hvac_mode = last_state.state

# ##ADDED
if self._hvac_mode.lower() != HVAC_MODE_OFF:
self._was_off = False

self._current_fan_mode = last_state.attributes['fan_mode']
self._current_swing_mode = last_state.attributes.get('swing_mode')
self._target_temperature = last_state.attributes['temperature']
Expand Down Expand Up @@ -295,6 +304,11 @@ def extra_state_attributes(self):
'commands_encoding': self._commands_encoding
}

# @property
# def was_off(self):
# """Return the value of the was_off flag"""
# return self._was_off

async def async_set_temperature(self, **kwargs):
"""Set new target temperatures."""
hvac_mode = kwargs.get(ATTR_HVAC_MODE)
Expand Down Expand Up @@ -369,9 +383,11 @@ async def send_command(self):

if operation_mode.lower() == HVAC_MODE_OFF:
await self._controller.send(self._commands['off'])
self._was_off = True
return

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

Expand Down