herikw / home-assistant-custom-components

Atag One Custom components for Home-Assistant
GNU General Public License v3.0
11 stars 5 forks source link

UnboundLocalError: local variable 'mode' referenced before assignment #6

Closed RezzZ closed 4 years ago

RezzZ commented 5 years ago

Hi, I recently installed this great component for my new atag one but I'm facing difficulties setting the one back to mode 'auto'.

I receive the following error:

Log Details (ERROR)
Sat Dec 29 2018 22:44:10 GMT+0100 (CET)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 277, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/climate/atagone.py", line 237, in set_operation_mode
    jsonPayload = UPDATE_MODE.format(MAC_ADDRESS, mode)
UnboundLocalError: local variable 'mode' referenced before assignment

I found a similar issue with the nest thermostat pointing to a location where the bug might be: It shouldn't error even so though, that's a bug in the nest set_operation_mode method.

https://github.com/home-assistant/home-assistant/issues/10172

edit: hmm, problem might be my automation setting it to 'auto' instead of 'Auto'. Need to test it still, but setting it to 'manual' (not 'Manual') with temperature does work so it still shouldn't give this error.

RezzZ commented 5 years ago

diving further in the code I saw that I was using the following set_temperature service:

- service: climate.set_temperature
  data:
    entity_id: climate.atag_one_thermostat
    operation_mode: 'Manual'
    temperature: '22.5'

It seems the operation_mode is not part of your set_temperature function so it stays on auto mode but still sets the temperature and it starts heating. I'm switching back to setting two services, one to manual, the other for temp. Lets see if that works

herikw commented 5 years ago

Hi René,

In my perception you can still set the temperature in Auto mode if looking at the Atag One App. In Manual mode it no longer follows your schedule. In Auto mode it does.

I will have a look at the code to see if I can make the operation modes case insensitive.

Thanks for your analysis.

Regards, Wim

RezzZ commented 5 years ago

true, setting temp with auto still enabled works but than how to revert back to the original scheduled temp? Up side is that the schedule will resume when a new time/temp setting is scheduled but I'd rather set it to manual to keep control

RezzZ commented 4 years ago

not relevant any more after the alignment with the general climate.component