Core: BOND fan control errors

Created on 26 Jul 2020  路  21Comments  路  Source: home-assistant/core

The problem


The BOND fan integration is generating errors when I try to turn fans on/off. I am using fans with on/off toggle control and speed increase / speed decrease remotes.
Also the fan speed increase/decrease control did not transfer over from the BOND application. In the Bond app I have a fan power toggle button and a fan speed increase and fan decrease button, but these did not show up in the HA bond integration for these fans.

Environment


I am using Home Assistant 0.113.1

  • Home Assistant Core release with the issue:
  • Last working Home Assistant Core release (if known):
  • Operating environment (OS/Container/Supervised/Core):
  • Integration causing this issue:
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml


Traceback/Error logs


Logger: homeassistant.core
Source: components/bond/fan.py:79
First occurred: 6:44:23 PM (7 occurrences)
Last logged: 6:57:40 PM

Error executing service: Error executing service: Error executing service: Error executing service: Error executing service: Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1281, in catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1300, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 471, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 277, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
sstate = self.state
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 607, in state
return STATE_ON if self.is_on else STATE_OFF
File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 146, in is_on
return self.speed not in [SPEED_OFF, None]
File "/usr/src/homeassistant/homeassistant/components/bond/fan.py", line 79, in speed
return self.speed_list[ha_speed]
IndexError: list index out of range


Additional information

Thanks in advance for your help.

bond

Most helpful comment

@marciogranzotto , I will do that after work and put up the results.

All 21 comments

This seems to happen if a Bond only commands with actions IncreaseSpeed and DecreaseSpeed, but not SetSpeed.
For this to work properly, HA would need to support +speed and -speed instead of a stateful speed list.
@prystupa any ideas?

Maybe we should do the same that is implemented on the custom component. Only make speed available if max_speed exists in the properties:
https://github.com/nguyer/homeassistant-bond-home/blob/master/custom_components/bond/fan.py#L52

@tetragram55 just to narrow down the problem...
Are you seeing the errors in logs, even though the fan turns on and off correctly using HA turn on/turn off controls? Or the fan does not respond to on/off controls?

Also, @terminet85 @marciogranzotto Is one of you able to pull the state from the fan using HTTP? I am curious what the value of "speed" is in the Bond's state when the error occurs. Something like:
http://your_bond_ip/v2/devices/your_fan_device_id/state

@prystupa The fan will turn on with an error generated. The off command works with no error. If I just toggle the off button it operates the fan on and off with no errors.

So, here's a useful tool for debugging the local API:
http://bond-react-js.s3.amazonaws.com/index.html
(@prystupa I think that will help you as well)

It connects locally to your bond, so you need to be on the same network.
You can turn on Live so it updates whenever you do something on the app.
@tetragram55 if you can, please send a screenshot of your device's state and properties so we can try to figure this out.

I tried to create a raw-recorded fan with Increase/Decrease Speed, but the behavior I'm seeing is no max_speed and speed always 0:

image

What I think could be happening there is the speed state returning a number greater than 3, which is the fallback for max_speed in the component

@marciogranzotto , I will do that after work and put up the results.

@marciogranzotto thanks for state log. Unfortunately, speed == 0 is not going to cause the IndexError here:

ha_speed = math.ceil(self._speed * (len(self.speed_list) - 1) / max_speed)
return self.speed_list[ha_speed]

This would return 0-th speed, which is Off. I will wait for @tetragram55 to get the state from real device before I can do an educated fix.

@marciogranzotto I am unable to get the debugging tool to work. I have tried on different PC's but it just won't connect with the debug tool. I can connect with HTTP commands and via the web interface so my connection is good, there's just something with the the tool that isn't working for me. Any suggestions?

@tetragram55 if you are comfortable with HTTP commands, would you be able to pull the state from your fan with GET like this: http://your_bond_ip/v2/devices/your_fan_device_id/state using Postman or similar? You need to configure the following header for requests:

BOND-Token: "your_token"

Alternatively, if you can run HA locally from dev branch, I added logging that will dump device state on debug level. You need to enable bond debug level like this in the configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.bond: debug

@prystupa maybe a mistake 'cause I'm not involved to this, sorry.

@prystupa maybe a mistake 'cause I'm not involved to this, sorry.

Sorry, meant to mention @tetragram55

@tetragram55 oh sorry, looks like an FW change that is necessary to use that tool is not yet on the release version, only in beta.
That change is support to CORS, which is basically adding a header to all requests.

You can do manual HTTP communication or use the tool opening chrome with this commands, that turns off the CORS requirement:

open -n -a "Google Chrome" --args --user-data-dir=/tmp/temp_chrome_user_data_dir --disable-web-security 

@marciogranzotto I will give it a try again tonight, thanks for the help.

@marciogranzotto Here is the screen shot of the bond.
Let me know what else I can do to help.
image

That speed 14 is definitely the problem! But I think that the bond should not allow that...
I'll investigate that, but what you can do now is use Decrease Speed 14 times so speed gets back to 0, then it should probably work with the integration

@tetragram55 https://github.com/home-assistant/core/pull/38382 should fix exceptions in the log. As for increase/decrease controls not transferring to HA - I don't think HA has this concept for fans, I don't think this can be done.

The fan will now turn off and on with no errors.
The speed control is sending errors.(See below) when I use the call service to change the fan speed.
Maybe it is because my fan has speed increase and decrease instead of a 3 speed option?

Log Details (ERROR)
Logger: homeassistant.components.websocket_api.http.connection.139950326709936
Source: components/bond/fan.py:113
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 7:18:47 PM (6 occurrences)
Last logged: 7:22:05 PM

b'{"_error_id":7,"_error_msg":"bad argument"}rn'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 125, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1265, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1300, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 454, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 595, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 485, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 113, in async_set_speed
await self.hass.async_add_job(self.set_speed, speed)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(self.args, *self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/bond/fan.py", line 113, in set_speed
self._hub.bond.setSpeed(self._device.device_id, speed=bond_speed)
File "/usr/local/lib/python3.8/site-packages/bond/bond.py", line 45, in setSpeed
return self.doAction(deviceId,
File "/usr/local/lib/python3.8/site-packages/bond/bond.py", line 121, in doAction
raise Exception(r.content)
Exception: b'{"_error_id":7,"_error_msg":"bad argument"}rn'

@prystupa @marciogranzotto Thanks for your help. I can turn fans off and on without errors. As for the speed increase/decrease I can only hope this will one day work. :-)

@tetragram55 did you manually apply my patch to your existing HA installation? From the logs I do see that it is calling old bond library. dev branch using a different one now.

If you can run dev branch locally test against it when PR is merged?

@prystupa no I did not. Can you point me in the direction of a tutorial on how to do that?

@prystupa no I did not. Can you point me in the direction of a tutorial on how to do that?

Yes, take a look here: https://developers.home-assistant.io/docs/development_environment
I run my development instance on Mac directly, but there is also a Docker option (which didn't work for me as I could not configure shared network between docker and my home devices).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Elmardus picture Elmardus  路  3Comments

neonandu picture neonandu  路  3Comments

kirichkov picture kirichkov  路  3Comments

arangates picture arangates  路  3Comments

moskovskiy82 picture moskovskiy82  路  3Comments