Giter Club home page Giter Club logo

Comments (2)

Ra7t0r avatar Ra7t0r commented on August 24, 2024

I made some modifications to your code in order the fan speed slider to work with Air Purifer 3H

def calFanLevel(speed){
	if(speed == 0){
    	return 0
    }else if(speed == 1){
    	return 33
    }else if(speed == 2){
    	return 66
    }else if(speed == 3){
    	return 100
    }else if(speed == 4){  // - - - - - - - - - - - new entry of silent mode
    	return -1          
    }                     
}

 // - - - - - - - - - - - modifications to support auto and silent modes
def setFanSpeed(speed){
	log.debug "setFanSpeed " + speed
	def level = calFanLevel(speed)
    if(level > 0){
    	setLevel(level)
    }else if (level == 0) {
    	setModeAuto()
    }else if (level < 0) {
    	setModeSilent()
    }
    //sendEvent(name:"fanSpeed", value: level)
}

def setLevel(level){
	def speed = Math.round(level/6.25)   

//    if(model == "MiAirPurifier3"){
//       level = Math.round(stf/7.14)
//    }

log.debug "setLevel >> " + level + " >> " + speed

 // - - - - - - - - - - - modifications to support auto and silent modes
	if(level == 33){
    	speed = "low"
        level = 1
    }else if(level == 66){
    	speed = "medium"
        level = 2
    }else if(level == 100){
    	speed = "high"
        level = 3
    }

   if(model != "MiAirPurifier"){
        def body = [
            "id": state.id,
            "cmd": "mode",
            "data": speed
        ]
        def options = makeCommand(body)
        sendEvent(name:"fanSpeed", value: level)
        sendCommand(options, null)
	}
}
def setModeAuto(){
	log.debug "setModeAuto >> ${state.id}"
    def body = [
        "id": state.id,
        "cmd": "mode",
        "data": "auto"
    ]
    def options = makeCommand(body)
    sendEvent(name:"fanSpeed", value: 0) // - - - - - - - - - - - entry for updating DHT of auto mode
    sendCommand(options, null)
}

def setModeSilent(){
    log.debug "setModeSilent >> ${state.id}"
    def body = [
        "id": state.id,
        "cmd": "mode",
        "data": "silent"
    ]
    def options = makeCommand(body)
    sendEvent(name:"fanSpeed", value: 4)  // - - - - - - - - - - - entry for updating DHT of silent mode
    sendCommand(options, null)
}

I have’t access to custom capabilities, so in silent mode (currently setFanSpeed 4) the label appears as MAX and for auto mode (currently setFanSpeed 0) the label apperas as off.

Can you please integrate this modifications to your repo code?
Also the dimmer slider should be updated to off->dimmed->bright, to supported by Air purifier 3H

from mi_connector.

Ra7t0r avatar Ra7t0r commented on August 24, 2024

Hello.
I saw that you released a new DTH for air purifier. (devicetypes/streamorange58819) (thanks so much btw..)
I test it out and I have faced some issues.

Do you need any feedback on anything?

from mi_connector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.