Requesting virtual switch with more than 2 states

How would you like this "switch" to display on a dashboard or be used in a rule?

I still feel like it's on/off only, but depends on the use....

1 Like

Now that I think about it we already have this exact functionality built in with mode manager. I don't think I can have more than 1 mode manager but the developers could open it up to utilize that logic.

I feel like this could be used on our dashboards in so many ways.

A mode is essentially just a string... a variable if you will, just with a special meaning.... hint... hint...

2 Likes

Ohhhhh, that feels so above my pay grade.

1 Like

I would use a variable to display on the dashboard...

If you insist on using a device, a multi state sensor would fit better than a switch...something like a garage door sensor that has open, opening, closing, and closed states. The stock virtual driver automatically transitions from opening to open in a set time period but you could modify to set manually...

3 Likes

Anybody know of a write up so I can learn about variables?

If you want I setup a driver for storing a string... give me a sec.... And I'll try to find my rules for status text I use on dashboards...

1 Like

It's gotta be a "for dummies" version. I feel like the things I want to do require a programmers brain. I sware I'm the only poster on the forums that isn't a programmer.

1 Like

Is it possible to just copy and paste the mode system so it can be used over and over for different things? I feel like those of us that are dummies would find tons of uses for such a things...if it existed and people knew about it.

I just thought of another way to do this. A virtual notification device and set up notifications to roll into it. It won't have pretty icons but could display any info needed.

Here's my driver, though, to be honest I would use variables nowadays, this predated those being included in the HE platform....

The more appropriate version would be to setup a Hub Variable under Settings -> Hub Variables, clicking New Variable

Give the variable a name and then select a type, in this case ideally a String, and provide a starting value, e.g. Off.

Finally... Do what you want in a rule... Here's my dehumidifiers example, but probably bears no resemblance to what you're likely to need, but hopefully you get the idea...

2 Likes

Somehow not mentioned yet is the virtual device known as 'Button' which can possess as many as 26 (I believe) buttons. In a single device, you therefore have the ability to "Press" each numbered button based on what's happening, which can be done by Simple Automation or Rule Machine. In turn, those button presses can act as Triggers on other Rules, etc.

Hope this makes sense. It's compact and easy to maintain, and a tad easier (IMHO) than using Variables. IF ONLY WE COULD NAME THE BUTTONS THEMSELVES, but alas, you'll have to keep track of that some other way. :slight_smile:

You can name them in your dashboard. Unfortunately I don't have think buttons can display states.

1 Like

That's the thing a button doesn't have it state. They are meant to trigger something, not record a state... You would still need something else to record the state. That is where variables or switch devices come in, depending on the use case.

I'll give this a look when I get home.

1 Like

If I read the original request correctly, it could be as simple as:

Simple Extended vSwitch
metadata {
	definition (name: "Virtual Switch Extended", namespace: "thebearmay", author: "Jean P. May, Jr.") {
        capability "Switch"
        
        attribute "load", "enum", ["loaded", "empty"]
        
        command "load"
        command "unload"
	}   
}

def on() {
    sendEvent(name: "switch", value: "on")
    load()
}

def off() {
    sendEvent(name: "switch", value: "off")
}

def load() {
    sendEvent(name: "load", value: "loaded")
}

def unload() {
    sendEvent(name: "load", value: "empty")    
}

def installed() {
    off()
}
2 Likes

Maybe I just loaded up the driver and looked on the dashboard. It might show the status though not sure how to set such status. Was hoping each state could have its own icon on the dashboard, but I his could work.

Brilliant alternative. We had a similar work-around on the Vera controller, using a creation called Switchboard, an excellent plug-in by the renowned HA guru @toggledbits ! He even added auto-off timers and binary addressing, which was cool.

I tested my own solution, while not elegant it looks nice on the dashboard and is rather simple to set up.

  1. Create Mobile Application Device

  2. Add to maker API

  3. Edit device in dashboard and change to custom type.

  4. Create notification in the notification app and direct it to the Mobile Application Device.

  5. Edit that device again in the dashboard, select custom and you will see custom attribute "notification" listed, select that.

  6. At this point you can use individual notifications if you like or better yet is string together a rule in rule machine. I'll put an example of the rule for my dryer below. Ignore the part of the rule that says back door, when I get home I'll install a contact sensor on the dryer door and update the rule.

Icons...interesting enough you can use emojis from your phone as the message with this method. Not sure if it will show up on every device. Not even sure why that works...can anybody enlighten me?

2 Likes