kk7ds / somecomfort

A python client and utility for interacting with Honeywell thermostats
GNU General Public License v3.0
35 stars 27 forks source link

Emergency Heat #23

Open apetrycki opened 5 years ago

apetrycki commented 5 years ago

I'm guessing the Emergency Heat changed from when it was first implemented. I hacked around the issue by doing:

    def system_mode(self, mode):
        try:
            mode_index = SYSTEM_MODES.index(mode)
        except ValueError:
            raise SomeComfortError('Invalid system mode `%s`' % mode)
        if mode == 'emheat':
            key = 'SwitchEmergencyHeatAllowed'
        else:
            key = 'Switch%sAllowed' % mode.title()
        try:
            if not self._data['uiData'][key]:
                raise SomeComfortError('Device does not support %s' % mode)
        except KeyError:
            raise APIError(
                'Unknown Key: %s' % key)
        self._client._set_thermostat_settings(
            self.deviceid, {'SystemSwitch': mode_index})
        self._data['uiData']['SystemSwitchPosition'] = mode_index

in client.py

It isn't pretty, but it maintains backwards compatibility.