Feature Request: Virtual valve

we’ve got virtual devices for most everything else, I’d like a virtual valve too. I have a NC solenoid connected to a switch that I want to show up as a valve everywhere. I’d like to map the valve to the switch with RM and have it show up as a valve in homebridge.

thanks

Here you go:

// Copyright 2016, 2017, 2018, 2019 Hubitat Inc.  All Rights Reserved

metadata {
    definition (name: "Virtual Valve", namespace: "hubitat", author: "Mike Maxwell") {
        capability "Valve"

    }
    preferences {
        input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
    }
}

def installed() {
    log.warn "installed..."
    close()
}

def updated() {
    log.info "updated..."
    log.warn "description logging is: ${txtEnable == true}"
}

def parse(String description) {
}

def open() {
    def descriptionText = "${device.displayName} was opened"
    if (txtEnable) log.info "${descriptionText}"
    sendEvent(name: "valve", value: "open", descriptionText: descriptionText)
}

def close() {
    def descriptionText = "${device.displayName} was closed"
    if (txtEnable) log.info "${descriptionText}"
    sendEvent(name: "valve", value: "closed", descriptionText: descriptionText)
}
7 Likes

Perfect! Thanks