adey / bangali

bangali's random code stuff for smartthings
GNU General Public License v3.0
46 stars 52 forks source link

Number format exception when saving room with vents #40

Closed kmickeletto closed 6 years ago

kmickeletto commented 6 years ago

Hi, attempting to set this up and I am getting the following errors when choosing my vents.

2825231d-91d1-46f7-b8a9-ca431cca1e8e 9:44:18 PM: error java.lang.NumberFormatException @line 4563 (updateVentIndP) 2825231d-91d1-46f7-b8a9-ca431cca1e8e 9:44:16 PM: error java.lang.NumberFormatException @line 4563 (updateVentIndP) 2825231d-91d1-46f7-b8a9-ca431cca1e8e 9:44:14 PM: error java.lang.NumberFormatException @line 4563 (updateVentIndP)

The vents device handler I am using support these commands. There are others, but these are the ones I figured you would need to be able to utilize.

command "getVentInfo" command "getVentStates" command "getVentSensorReadings" command "getLevel" command "getOnOff" command "getPressure" command "getBattery" command "getTemperature" command "clearObstruction" command "ventFifty" command "ventHundred" command "ventLevelUp" command "ventLevelDown" command "setVent"

These are Flair vents. I can provide additional information or logs if needed.

Project seems really cool, excited to see what it can do for my house! Thanks! Ken

adey commented 6 years ago

could you please share the capabilities section? looking to check. if it support switch and level.

thank you.

kmickeletto commented 6 years ago

Here you are. I was able to create a temporary workaround by creating virtual switches and linking the state of the virtual switch to the physical vent switch, but this is obviously not ideal.

definition(name: "My Flair Vent", namespace: "yracine", author: "Yves Racine") {
    capability "Switch Level"
    capability "Switch"
    capability "Refresh"
    capability "Sensor"
    capability "Temperature Measurement"
    capability "Actuator"
    capability "Health Check"
adey commented 6 years ago

thats strange it has switch and level. please replace the function updateVentP(...) with the following code and share the output from it.

def updateVentIndP(evt)   {
//    ifDebug("updateVentIndP", 'info')
    def child = getChildDevice(getRoom())
    def lvl = 0
    if (roomVents)      {
        if (roomVents.hasAttribute('level'))        {
            lvl = roomVents.currentLevel
            ifDebug("updateVentIndP: level: $lvl")
        }
        else if (roomVents.hasAttribute('switchLevel'))     {
            lvl = roomVents.currentSwitchLevel
            ifDebug("updateVentIndP: switchLevel: $lvl")
        }
        if (lvl instanceof List)        lvl = lvl.sum() / lvl.size();
    }
    if (child)      child.updateVentIndC(!roomVents ? -1 : (roomVents.currentSwitch == 'off' ? 0 : lvl));
}
kmickeletto commented 6 years ago

Hi adey, I updated to the latest code and it is working. Sorry for the delay here.

I am assuming you integrated this into the update?

adey commented 6 years ago

cool. no worries.

yeah i add checking for switch level additional to level.