Multi position virtual switch

Is this what you mean?

This can be done in a Virtual Switch driver by adding an attribute and the corresponding command to set it (in the example, Select). Or...

Screen Shot 2020-07-02 at 11.28.57 AM

But, you wouldn't have an "elegant" way to put that in a Dashboard. We need a custom template maker.

5 Likes

You may also want to try this from @bptworld

[RELEASE] One at a Time

You could also see if Bryan could extend on this app to handle generating a tile for you. I'd be interested in that as well.

1 Like

Any chance someone could show me how to do this or post a simple solution? I can work the front end UI on my dashboard, no problem. But I'm not sure how to build a driver like that (off/on/away).

metadata {
	definition (name: "Virtual Switch Multi", namespace: "hubitat", author: "Bruce Ravenel") {
		capability "Switch"
		command	   "select", [[name: "Switch-3",type:"ENUM", description:"Switch-3", constraints: ["on", "off", "away"]]]
        attribute  "selection", "ENUM"
	}
	preferences {
		input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
	}
}

def installed() {
	log.warn "installed..."
	off()
	select("off")
}

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

def parse(String description) {
}

def on() {
	def descriptionText = "${device.displayName} was turned on"
	if (txtEnable) log.info "${descriptionText}"
	sendEvent(name: "switch", value: "on", descriptionText: descriptionText)
}

def off() {
	def descriptionText = "${device.displayName} was turned off"
	if (txtEnable) log.info "${descriptionText}"
	sendEvent(name: "switch", value: "off", descriptionText: descriptionText)
}

def select(val) {
	def descriptionText = "${device.displayName} was set $val"
	if (txtEnable) log.info "${descriptionText}"
	sendEvent(name: "selection", value: "$val", descriptionText: descriptionText)
}
2 Likes

Thank you. @cobra has also developed an app to do this which he's posted to his site.
Much appreciated assistance from both of you!

Cheers.

2 Likes

It's actually a virtual switch/button driver Angus :slight_smile:

Andy

1 Like

Oh yeah, woops :crazy_face:

1 Like

Just set it up. Works perfectly. I now have a very advanced dog lol. Off, On (always barks) or Away (barks only if everyone is out). Set by Button on a dashboard.

Thank you for your great new device code.
Cheers
:dog:

2 Likes

I installed the custom driver to test this and have the following...

but after creating a tile in a Dashboard and setting it with either a switch or a button template, I only get ON/OFF as a switch and nothing when set as a button.

Sorry guys, am I missing something here?

That's the problem: there is no template for a 3 position switch in the Dashboard.

Using @Cobra's driver (which can be accessed by registering at his site https://cobra-apps.co.uk/), it is very easy to set up a button tile which then drives the switch state (up to 4 are allowed) which can be reported in another tile. This is the one I set up for my dog bark (which has 3 states; off, on, and away). It works perfectly and I think the UI is good enough. It would be better as 3 radio buttons of course.... :dog:

20200705_002948

@chillibenny fyi above, hope it helps. Cheers.

3 Likes

Thank you Bud, much appreciated!!

what code would you add to to this to make it auto go to Away after 2 seconds. ... from on or off.
In my case, I want to control 2 different IFTTT triggers, but system might be On, and the switch here already Off, so I can't command it Off (more like a momentary on/off with a neutral resting possition.

HI Angus I don't know if your rules needed to set the custom attribute. If so perhaps you could look at my other post Setting a custom attribute if you know.

Hiyah. No I don't think I had to do that for my use case, sorry. I see a reply already from someone to your question regarding custom attribute setting. Maybe that will assist you.

Hey All,

These are both great drivers!
Now, comes the seemingly obvious question: how I get them to apply to an actual physical device?
I created a virtual button/switch for them, but that is where I am now stumped.

Use Rule Machine to set up some rules that switch the actually device based on the state of the virtual device. The trigger would be a change to the virtual device. Then a set of conditionals that say if the virtual device is set to X, then set the physical device to Y, or suchlike.

1 Like

Hi,

I'm new to hubitat, but getting the hang of it so far. I am trying to use HSM and get my current Zwave based alarm system migrated over from Indigo. One thing I have is a control panel which is in Node-Red and gets it's values via MQTT. So I am trying to get the states of HSM into MQTT and the only way I can see to do this at the moment is using a Multi-positional switch and rule engine to set the switch when HSM changes. The switch is then exposed to MQTT sunig the MQTT link.

I have signed up to the Cobra Apps site, but my account hasn't been activated, any idea on how long this normally takes?

Any better ways to achieve a link between HSM and MQTT?

Thanks

Stuart

It wasn't your question, but I'll point out that there is a set of Hubitat nodes for node-red.

Could just bring hsm status into node-red directly, and skip using mqtt as the middle man.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.