Virtual Switches

I am finally contemplating the move from SmartThings to Hubitat as it seems inevitable that SmartThings will later this year strip out much of what I have set up over the last 5 years with this platform. So I will have a number of questions for you all, the answers to which will be much appreciated.

The foremost of which is that I have a number of virtual switches set up in SmartThings that simply execute an http GET to a server on my LAN. These include momentary, toggle, and discrete ON and OFF commands. Is this doable in Hubitat?

I never used virtual switches in ST, but it sound like they are setup diffidently, someone else here will know more. Below is a screen shot of the virtual switch. It has auto off so I guess that could be considered momentary. As for toggle or ON/Off that would be handled by rules in Rule Machine (RM) or which ever automation app you were using.

If you have some sample rules/automations you would like looked at feel free to post em.

But yes what you are saying is doable in HE. I send http GET commands to automate my hubs reboot cycles.

1 Like

You can do this with a combination of virtual switch and rule machine.

1 Like

As @TechMedX and @potts.mike have described, you can do this using a virtual switch and Rule Machine. I wanted to mention a second way of doing it - using @ogiewon's HTTP Momentary Switch driver.

3 Likes

I think this can be summed up using a 2 part rule.

Part 1 - It's pretty safe to say anything you can do any ST you can do in Hubitat.

Part 2 - If you find something that "cannot" be done in HE, there is HubConnect to connect your ST hub to HE, refer to Part 1.

:rofl:

1 Like

There is also a simple driver on the HE github that can do what you want with a small modification.

1 Like

:point_up_2: ....sorry too muc to drink?

Thanks, that's good to hear. Does that include DeviceTypes?

I have a good number of Intermatic InTouch Z-Wave switches that are not listed in HE's compatibility list. But they are fairly generic devices that I use custom DeviceTypes with in SmartThings.

Will I be able to port those DeviceTypes to HE?

Intermatic InTouch Z-Wave : almost certainly, but the good news is you can use/keep them in SmartThings until you get them sorted, via Hubconnect. If you post the device handler, someone more knowledgeable will confirm whether it can be ported to Hubitat.

1 Like

Here is one for the loadless switches…

/**
 *  Intermatic CA5100
 *
 *  Scottin Pollock
 */
 
metadata {
	definition (name: "Intermatic CA5100", namespace: "scottinpollock.us", author: "Scottin Pollock") {
		capability "Switch"
        capability "Actuator"
		capability "Indicator"
		capability "Switch"
		capability "Polling"
		capability "Refresh"
		capability "Sensor"

		fingerprint inClusters: "0x25"
	}

	// simulator metadata
	simulator {
		status "on":  "command: 2003, payload: FF"
		status "off": "command: 2003, payload: 00"

		// reply messages
		reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
		reply "200100,delay 100,2502": "command: 2503, payload: 00"
	}

	// tile definitions
	tiles {
		standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
			state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
			state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
		}
		standardTile("indicator", "device.indicatorStatus", inactiveLabel: false, decoration: "flat") {
			state "when off", action:"indicator.indicatorWhenOn", icon:"st.indicators.lit-when-off"
			state "when on", action:"indicator.indicatorNever", icon:"st.indicators.lit-when-on"
			state "never", action:"indicator.indicatorWhenOff", icon:"st.indicators.never-lit"
		}
		standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
			state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
		}

		main "switch"
		details(["switch","refresh","indicator"])
	}
}

def parse(String description) {
	def result = null
	def cmd = zwave.parse(description, [0x20: 1, 0x70: 1])
    log.debug "my cmd was $cmd"
	if (cmd) {
		result = createEvent(zwaveEvent(cmd))
	}
	if (result?.name == 'hail' && hubFirmwareLessThan("000.011.00602")) {
		result = [result, response(zwave.basicV1.basicGet())]
		log.debug "Was hailed: requesting state update"
	} else {
		log.debug "My Parse returned ${result?.descriptionText}"
	}
	return result
}

// NEWLY ADDED METHOD BELOW
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
	log.debug "we got into BasicSet"
	[name: "switch", value: cmd.value > 200 ? "on" : "off", type: "physical"]
}
//THAT'S IT


def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
	[name: "switch", value: cmd.value ? "on" : "off", type: "physical"]
	log.debug "we got into BasicReport"
}

def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
	[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
	log.debug "we got into SwitchBinaryReport"
}

def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
	log.debug "we got into ConfigurationReport"
	def value = "when off"
    log.debug cmd.configurationValue
	if (cmd.configurationValue[0] == 1) {value = "when on"}
	if (cmd.configurationValue[0] == 2) {value = "never"}
	[name: "indicatorStatus", value: value, display: false]
}

def zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {
	log.debug "we got into Hail"
	[name: "hail", value: "hail", descriptionText: "Switch button was pressed", displayed: false]
}

def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
	log.debug "we got into ManufacturerSpecificReport"
	if (state.manufacturer != cmd.manufacturerName) {
	updateDataValue("manufacturer", cmd.manufacturerName)
	}
}

def zwaveEvent(physicalgraph.zwave.Command cmd) {
	log.debug "we got into Command"
	// Handles all Z-Wave commands we aren't interested in
	[:]
}

def on() {
	sendEvent(name: "switch", value: "on")
	delayBetween([
		zwave.basicV1.basicSet(value: 0xFF).format(),
		zwave.switchBinaryV1.switchBinaryGet().format()
	])
}

def off() {
	sendEvent(name: "switch", value: "off")
	delayBetween([
		zwave.basicV1.basicSet(value: 0x00).format(),
		zwave.switchBinaryV1.switchBinaryGet().format()
	])
}

def poll() {
	delayBetween([
		zwave.switchBinaryV1.switchBinaryGet().format(),
		zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
	])
}

def refresh() {
	delayBetween([
		zwave.switchBinaryV1.switchBinaryGet().format(),
		zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
	])
}

def indicatorWhenOn() {
			log.debug "we got into indicatorWhenOn"

	sendEvent(name: "indicatorStatus", value: "when on", display: false)
	zwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 3, size: 1).format()
}

def indicatorWhenOff() {
	sendEvent(name: "indicatorStatus", value: "when off", display: false)
	zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 3, size: 1).format()
}

def indicatorNever() {
	sendEvent(name: "indicatorStatus", value: "never", display: false)
	zwave.configurationV1.configurationSet(configurationValue: [2], parameterNumber: 3, size: 1).format()
}

def invertSwitch(invert=true) {
	if (invert) {
		zwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 4, size: 1).format()
	}
	else {
		zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 4, size: 1).format()
	}
}

If you wrote this for ST then you can probably port it to HE which is also... grovey .

OK even typing that (misspelled) is odd since I am not a dev. If you have dev type questions I would recommend making a separate post and putting them in the dev section. Some devs may have no interest in the OP title, and not look at this.