MTrab / danfoss_ally

Danfoss Ally integration for Home Assistant
GNU General Public License v3.0
45 stars 10 forks source link

missing setmode attribute #24

Closed mjbendixen closed 2 years ago

mjbendixen commented 2 years ago

Hey there I'm having an issue with home assistant reporting missing setmode attribute when tryin to change preset, home/away etc. i'm getting a AllyConnector object has no attribute ´setmode` error. Anyone know about a fix for this ?

MTrab commented 2 years ago

Probably something missing in the API definition. Please show the full error so I have a possibility to fix this.

mjbendixen commented 2 years ago

this is the error log i get:

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/danfoss_ally/climate.py:181 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 6:48:35 PM (21 occurrences) Last logged: 8:18:55 PM

[547411706928] 'AllyConnector' object has no attribute 'setMode' [547429417360] 'AllyConnector' object has no attribute 'setMode' [547417570080] 'AllyConnector' object has no attribute 'setMode' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 189, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1627, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1664, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 677, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 964, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 714, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 488, in async_set_preset_mode await self.hass.async_add_executor_job(self.set_preset_mode, preset_mode) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/danfoss_ally/climate.py", line 181, in set_preset_mode self._ally.setMode(self._device_id, mode) AttributeError: 'AllyConnector' object has no attribute 'setMode'

jnxxx commented 2 years ago

In climate.py change: self._ally.setMode(self._device_id, mode) to: self._ally.set_mode(self._device_id, mode)

Then it is working.

MTrab commented 2 years ago

Oh - must be some change I forgot to follow thru. Will push an update to this ASAP.

MTrab commented 2 years ago

Okay - it actually was already fixed in latest version, so please update to v1.0.7 :)

allanedk commented 2 years ago

@MTrab first of all: Thanks a lot for your work on this. Much appreciated!

I still get this error when trying to set preset / mode. The line numbers in the stack trace are different though:

_2022-09-19 12:28:45.217 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547558331232] 'AllyConnector' object has no attribute 'setMode'

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 488, in async_set_preset_mode await self.hass.async_add_executor_job(self.set_preset_mode, preset_mode) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/danfoss_ally/climate.py", line 181, in set_preset_mode self._ally.setMode(self._deviceid, mode) AttributeError: 'AllyConnector' object has no attribute 'setMode'

I see this error in the logs as well, but I'm not sure if it's related. It might be from activating a scene that also tries to set the temp:

_2022-09-19 14:46:54.196 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547555910528] 'bool' object is not subscriptable Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/scene/init.py", line 114, in _async_activate await self.async_activate(kwargs) File "/usr/src/homeassistant/homeassistant/components/homeassistant/scene.py", line 334, in async_activate await async_reproduce_state( File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 116, in async_reproduce_state await asyncio.gather( File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 110, in worker await platform.async_reproduce_states( File "/usr/src/homeassistant/homeassistant/components/climate/reproduce_state.py", line 90, in async_reproduce_states await asyncio.gather( File "/usr/src/homeassistant/homeassistant/components/climate/reproduce_state.py", line 64, in _async_reproduce_states await call_service( File "/usr/src/homeassistant/homeassistant/components/climate/reproduce_state.py", line 49, in call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 588, in async_service_temperature_set await entity.async_set_temperature(kwargs) File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 446, in async_set_temperature await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/danfoss_ally/climate.py", line 215, in set_temperature self._ally.set_temperature(self._device_id, temperature) File "/config/custom_components/danfoss_ally/init.py", line 174, in set_temperature self.ally.setTemperature(device_id, temperature) File "/usr/local/lib/python3.10/site-packages/pydanfossally/init.py", line 116, in setTemperature result = self._api.set_temperature(device_id, temperature) File "/usr/local/lib/python3.10/site-packages/pydanfossally/danfossallyapi.py**", line 151, in settemperature return callData['result'] TypeError: 'bool' object is not subscriptable

allanedk commented 2 years ago

Solved by changing climate.py line 181 to: _self._ally.setmode(...

(version 1.0.7)