MFornander / Hubitat

Learning Hubitat
MIT License
2 stars 3 forks source link

Provide Garage Door Option for Switch Dashboard #16

Open djw1191 opened 4 years ago

djw1191 commented 4 years ago

Please provide the capability to use a garage door as a sensor, providing all states including open, closed, opening, and closing.

In a self modified version of the code I made the follow changing to facilitate this ability. My groovy abilities are almost non-existent, so I'm not sure this was the best way to do it, but it worked for my basic needs.

input name: "sensorType", type: "enum", title: "Sensor Type", required: true, submitOnChange: true,
                options: [
                    "switch": "Switch",
                    "contact": "Door/Window Sensor",
                    "lock": "Lock",
                    "motion": "Motion Sensor",
                    "water": "Water Sensor",
                    "door": "Garage Door",
                    "valve": "Valve"
                ]
private attributeValues(attributeName) {
    switch (attributeName) {
        case "switch":
            return ["on","off"]
        case "contact":
        case "valve":
            return ["open","closed"]
        case "motion":
            return ["active","inactive"]
        case "water":
            return ["wet","dry"]
        case "door":
            return ["unknown", "open", "closing", "closed", "opening"]
        case "lock":
            return ["unlocked", "unlocked with timeout", "unknown", "locked"]
        default:
            return ["UNDEFINED"]
    }
}
private capabilityName(attributeName) {
    switch (attributeName) {
        case ["switch", "lock", "valve"]:
            return attributeName
        case "door":
            return "garageDoorControl"
        default:
            return "${attributeName}Sensor"
    }
}
MFornander commented 4 years ago

Epic write-up! I'll add this along with some Inovelli additions. Thanks for the code!