Skip to content

Commit

Permalink
Fix mclimate accounts with not only melissa components (home-assistan…
Browse files Browse the repository at this point in the history
…t#12427)

* Fixes for mclimate accounts with not only melissa components

* Fixes melissa sensor to only use HVAC

* Bumping version to 1.0.3 and remove OP_MODE that is not supported

* Removes STATE_AUTO from translation and tests
  • Loading branch information
kennedyshead authored and MartinHjelmare committed Feb 23, 2018
1 parent 485979c commit 7a44eee
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
15 changes: 6 additions & 9 deletions homeassistant/components/climate/melissa.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SUPPORT_ON_OFF | SUPPORT_TARGET_TEMPERATURE)

OP_MODES = [
STATE_AUTO, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT
STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT
]

FAN_MODES = [
Expand All @@ -42,8 +42,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
all_devices = []

for device in devices:
all_devices.append(MelissaClimate(
api, device['serial_number'], device))
if device['type'] == 'melissa':
all_devices.append(MelissaClimate(
api, device['serial_number'], device))

add_devices(all_devices)

Expand Down Expand Up @@ -199,9 +200,7 @@ def melissa_state_to_hass(self, state):

def melissa_op_to_hass(self, mode):
"""Translate Melissa modes to hass states."""
if mode == self._api.MODE_AUTO:
return STATE_AUTO
elif mode == self._api.MODE_HEAT:
if mode == self._api.MODE_HEAT:
return STATE_HEAT
elif mode == self._api.MODE_COOL:
return STATE_COOL
Expand All @@ -228,9 +227,7 @@ def melissa_fan_to_hass(self, fan):

def hass_mode_to_melissa(self, mode):
"""Translate hass states to melissa modes."""
if mode == STATE_AUTO:
return self._api.MODE_AUTO
elif mode == STATE_HEAT:
if mode == STATE_HEAT:
return self._api.MODE_HEAT
elif mode == STATE_COOL:
return self._api.MODE_COOL
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/melissa.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.discovery import load_platform

REQUIREMENTS = ["py-melissa-climate==1.0.1"]
REQUIREMENTS = ["py-melissa-climate==1.0.6"]

_LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/sensor/melissa.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
devices = api.fetch_devices().values()

for device in devices:
sensors.append(MelissaTemperatureSensor(device, api))
sensors.append(MelissaHumiditySensor(device, api))
if device['type'] == 'melissa':
sensors.append(MelissaTemperatureSensor(device, api))
sensors.append(MelissaHumiditySensor(device, api))
add_devices(sensors)


Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ py-canary==0.4.0
py-cpuinfo==3.3.0

# homeassistant.components.melissa
py-melissa-climate==1.0.1
py-melissa-climate==1.0.6

# homeassistant.components.camera.synology
py-synology==0.1.5
Expand Down
4 changes: 1 addition & 3 deletions tests/components/climate/test_melissa.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_current_operation(self):
def test_operation_list(self):
"""Test the operation list."""
self.assertEqual(
[STATE_AUTO, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT],
[STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT],
self.thermostat.operation_list
)

Expand Down Expand Up @@ -226,7 +226,6 @@ def test_melissa_state_to_hass(self):

def test_melissa_op_to_hass(self):
"""Test for translate melissa operations to hass."""
self.assertEqual(STATE_AUTO, self.thermostat.melissa_op_to_hass(0))
self.assertEqual(STATE_FAN_ONLY, self.thermostat.melissa_op_to_hass(1))
self.assertEqual(STATE_HEAT, self.thermostat.melissa_op_to_hass(2))
self.assertEqual(STATE_COOL, self.thermostat.melissa_op_to_hass(3))
Expand All @@ -245,7 +244,6 @@ def test_melissa_fan_to_hass(self):
@mock.patch('homeassistant.components.climate.melissa._LOGGER.warning')
def test_hass_mode_to_melissa(self, mocked_warning):
"""Test for hass operations to melssa."""
self.assertEqual(0, self.thermostat.hass_mode_to_melissa(STATE_AUTO))
self.assertEqual(
1, self.thermostat.hass_mode_to_melissa(STATE_FAN_ONLY))
self.assertEqual(2, self.thermostat.hass_mode_to_melissa(STATE_HEAT))
Expand Down

0 comments on commit 7a44eee

Please sign in to comment.