tonesto7 / homebridge-smartthings

SmartThings Homebridge Plugin
384 stars 767 forks source link

(BUG) 4-Speed Fan #418

Open damienemmerson opened 3 years ago

damienemmerson commented 3 years ago

Verify the following before opening an trouble issue

Go over all the following points, and put an x in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!


About Your Setup

Expected Behavior

  1. When fan is set to high, device command setFanSpeed should have a value of 4.
  2. When fan speed is set to low / med /med-high / high, the tile in the home app should report 25% / 50% / 75% / 100% respectively.

Current Behavior

  1. setFanSpeed command is sent with a value of 3.
  2. in all cases the correct percentage is shown momentarily before changing to 0%. This is similar to issue #326 but for the 4-speed fan.

Steps to Reproduce (for bugs)

Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant

  1. Add Device Handler to Smartthings IDE
metadata {
    definition(name: "Fan Controller v3.0", namespace: "Damien Emmerson", author: "Damien Emmerson", vid: "generic-fan", ocfDeviceType: "oic.d.fan") {
    capability "switch"
        capability "Actuator"
        capability "Fan Speed"

        command "setStatus"
    }

    simulator {
    }

    preferences {
            input "defaultOnSpeed", "number", title: "Default On Speed", description: "Set the default On speed", defaultValue: 4, range: "1..4", required: false, displayDuringSetup: false
    }
}

def parse(String description) {
    log.debug(description)
}

def setFanSpeed(speed) {
    sendEvent(name: "fanSpeed", value: speed, displayed: true)
    if (speed == 0) {
        sendEvent(name: "switch", value: "off", displayed: true)
    } else {
        sendEvent(name: "switch", value: "on", displayed: true)
    }
}

def on() {
    setFanSpeed(defaultOnSpeed ?: state.defaultOnSpeed ?: 4)
}

def off() {
    setFanSpeed(0)
}

def setStatus(type, status) {
    sendEvent(name: type, value: status)
}
  1. Create a simulated fan device using the device handler above.
  2. Add the simulated fan device to the 4-speed fan category in the homebridge smartapp
  3. [Issue 1] Turn the fan on to high in the Home app. The fan turns on to med-high. See log output below.

Log output: NOTICE: Sending Device Command: on | Name: (Simulated Fan) | DeviceID: (9c001bc6-6f3b-4ffd-bfb1-93f9a0c0d709) | SendToLocalHub: (false) NOTICE: Sending Device Command: setFanSpeed | Value: {"value1":3} | Name: (Simulated Fan) | DeviceID: (9c001bc6-6f3b-4ffd-bfb1-93f9a0c0d709) | SendToLocalHub: (false)

  1. [Issue 2] Set the fan so any speed in the home app. The fan will change speed but fan speed slider in the Home App will change to 0%.

Context

The issue means you can never turn a fan on to high. It also means that the reported speed in the Home app is different to that in Smartthings.