finity69x2 / fan-control-entity-row

Provides a means to show a compact graphical control row for 2 or 3 speed fans in Home Assistant
68 stars 27 forks source link

Turning fan to "off" causes fan to set speed to "3" #32

Closed griley closed 3 years ago

griley commented 4 years ago

Using the Bond integration with 4 run-of-the-mill remote-controlled fans.

lovelace ui:

cards:
  - type: entities
    show_header_toggle: false
    title: Ceiling fans
    entities:
    - entity: fan.office_fan_3
      type: custom:fan-control-entity-row
      name: Office fan
      customTheme: false

Whenever I attempt to turn the fan off, the fan instead set its speed to 3. The logs show it:

# initial state is off 
Sep 25 15:25:10 cube docker-compose[3376158]: home-assistant   | 2020-09-25 15:25:10 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
Sep 25 15:25:10 cube docker-compose[3376158]: home-assistant   | {'power': 0, 'speed': 3, 'direction': 1, 'light': 1, '_': '449c0000'}

# turn the fan on (speed 1)
Sep 25 15:25:23 cube docker-compose[3376158]: home-assistant   | 2020-09-25 15:25:23 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
Sep 25 15:25:23 cube docker-compose[3376158]: home-assistant   | {'power': 1, 'speed': 1, 'direction': 1, 'light': 1, '_': '276a1988'}

# turn the fan off (speed is set to 3) ????
Sep 25 15:25:34 cube docker-compose[3376158]: home-assistant   | 2020-09-25 15:25:34 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
Sep 25 15:25:34 cube docker-compose[3376158]: home-assistant   | {'power': 1, 'speed': 3, 'direction': 1, 'light': 1, '_': '4b031e4f'}

Commenting out the set_speed call that is made when turning off the fan seemed to solve the issue:

    setSpeed(e) {
        const speed = e.currentTarget.getAttribute('name');
        if( speed == 'off' ){
            this.hass.callService('fan', 'turn_off', {entity_id: this._config.entity});
            // this.hass.callService('fan', 'set_speed', {entity_id: this._config.entity, speed: speed});
        } else {
            if(this._config.sendStateWithSpeed){
            this.hass.callService('fan', 'turn_on', {entity_id: this._config.entity});
            }
            this.hass.callService('fan', 'set_speed', {entity_id: this._config.entity, speed: speed});
        }
    }

I'm sure that call was put there at some point for a reason, but it sure breaks things for me.

finity69x2 commented 4 years ago

Actually the set_speed call has been there all along from day 1.

It was the state that was added later as a fix for some fans that needed both the state and the speed sent together to switch speeds.

I seem to be seeing a lot of issues with the "bond" fans lately.

What I don't get is where the speed 3 command is coming from. If the last speed before trying to turn it off was speed 1 then why did the speed get set to 3?

My fan control only takes the settings that HA itself sends to the fan so somewhere in HA the speed is getting changed to 3.

griley commented 3 years ago

What I don't get is where the speed 3 command is coming from. If the last speed before trying to turn it off was speed 1 then why did the speed get set to 3?

Ya - that's definitely weird. With the fan.office_fan_3 turned on and running on the low speed, I used the HA developer tools and called the fan.set_speed service:

entity_id: fan.office_fan_3
speed: 'off'

... and as expected, I saw a the "bond" component log:

2020-09-28 09:42:58 DEBUG (MainThread) [homeassistant.components.bond.entity] Device state for fan.office_fan_3 is:
{'power': 1, 'speed': 3, 'direction': 1, 'light': 0, '_': '5f244ae8'}

and the fan started running at the "3" speed.

I'll close this issue and open a new one on the Bond integration repo.

Thanks for the component and the help.