How are people handling routines?

In smart things we had a number of routines (i.e. Good Night, Leaving Town, Going to Work, etc.)

I have been struggling with the best way to implement these w/ in Hubitat.

These routines are triggered by: Rule Machine, Alexa, Button Presses, Dashboards, Etc. Often the same routine is called using multiple methods.

These routines typically trigger Rules or simple lighting rules.

I had been utilizing virtual switches for each routine; however, this has become a bit of a pain since you need to always go back and have the virtual switch turned off. For some routines this is not so bad; however, others this can be a pain since it might spawn multiple actions and timers. Additionally, you may want to re-run a routine before it is complete to restart it. For example "Going to Work" opens garage door, turns off certain lights, turns off coffee, etc. You might activate it w/ dashboard on in wall touch screen then turn a few things back on when you forgot your keys. Then tell alexa to "turn on going to work"

I considered buttons, but they do not work with alexa. I am curious what others are doing. I have not found anything I cannot accomplish, but it gets a bit untidy and tedious.

Iā€™m still using Smartthings as a trigger for routines because of the voice control I have through Google and the routine buttons in the app, but smartthings does not handle any of the device logic. Itā€™s only there for the trigger.

I modified OtherHub to listen for routines in Smartthings and it sends those along to hubitat and creates a location event exactly like it did in smartthings just now on hubitatā€™s side. Then I use webcore to subscribe to this location event and trigger pistonā€™s based on the id that came in. I have different pistons for waking up, going to work, arrived home, etc. Itā€™s also nice because I can use other triggers for routines other than the the location event such as a button or a switch.

If you donā€™t want to go that route, could you change your virtual switch to turn back off after the rule has activated?

Or even better if you could create a virtual momentary switch that automatically turns back off after activation so you donā€™t have to do it in each rule.

Hereā€™s a simple switch that will turn back off after 5 seconds

metadata {
	definition (name: "Virtual Momentary Switch", namespace: "jp0550", author: "jp0550") {
        capability "Actuator"
		capability "Switch"
        capability "Momentary"
	}
}

def installed(){
    log.debug "Installed with settings: ${settings}"
 	initialize()   
}

def updated(){
    log.debug "Updated with settings: ${settings}"
    initialize()
}

def initialize(){
}

def parse(String description) {
    
}

def push(){
	sendEvent(name : "switch", value: "on")
    runIn(5, "off")
}

def on(){
    push()
}

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

I use virtual momentary switches to set routines because they work with everything (homebridge, Alexa, etc.). As @jp0550 suggests, using a simple custom device will ensure the switches automatically toggle off after theyā€™re turned on.

I use a virtual switch with a variable auto switch off.
I created a dth for the switch where the off delay is configurable from the dth settings.

Andy

Thanks Guys. I like the virtual momentary switch. I am going to start using that.

Can you share the code?

Is there a reason to not use the Virtual Button that is built-in to HE? Or maybe I am missing something... Will voice commands to that Virtual Button type not work for handling routines?

You can find the code for this driver here:

I originally created this way back befor you had any ā€˜auto offā€™ facilities in the in-built driver.
I still use this one because some of my uses require the switch to automatically switch off after a number or minutes or hours.

Alexa can turn a switch but not press a button (one of my uses for this device driver)

Andy

1 Like

Well that makes perfect sense now why not to use the virtual button. Thanks!

I realized the same problem at @rugby148 when I came over to HE. I needed Routines! So, I setup rules in RM and use some virtual switches as well. Seems to work fine but took some thinking.

1 Like

For some reason my virtual switches are not triggering the RM routine I set up.

I have a dual condition so either a minimote button press OR the virtual switch is supposed to trigger the actions. The minimote works perfectly but for some reason, the virtual switch isn't registering? I tried using built in the virtual switch as well as @Cobra timed switch because I know I want it to reset again since I am using it for things like "Going to Bed". What is the trick that I am missing for getting a virtual momentary switch to register in RM? I even manually trigger it from the device driver and nothing is happening to show in the event logs that it is being switched (which is why I am sure RM isn't doing a thing)

I must be setting up the virtual switch incorrectly?

I am confused to say the least. It is working now?

When I first set up the rules they never triggered with just the virtual switch. So I then modified one of the Rules so that I could trigger it with the minimote and that worked so I assumed the virtual switch was still nonoperational. I just tried the virtual switch and NOW it is working as well as the minimote button for triggering the actions.

FYI - I tried this on three separate rule machine events and they all did not trigger using only virtual switches. So the question now is maybe I am not understanding how to setup RM correctly. Here is my simply rule setup - What am I setting up wrong? The device "Going To Bed VST5" is my virtual switch timer #5 using @cobra adjustable timer for the momentary action. I used this because I thought I needed to make for a longer switch ON time to allow the Rule to trigger fully but not so.

What you have should work but for such a simple rule I think you would be better served creating a Trigger. The standard Rule or Triggered Rule would be better if you wanted to test a condition before executing something. Since you simply want to execute when the switch is on, then a simple Trigger would be best IMO.

Also, the built in Virtual Switch can also work as a momentary switch. You just need to set the AutoOff preference.

1 Like

Thanks! I setup a Trigger as well but the virtual switch wasn't working there either. I'll try and swap the driver to the built-in virtual switch and set the auto-off. My problem sure looks like it has to be that driver I'm using.

Wow, this has been an exciting troubleshooting issue. It turns out I think I have been chasing the wrong issues that were all just symptoms.

The real culprit showed up in the Logs. I should have started there to look for anything unusual. The problem is showing up in the logs here. I soon as I take the Kitchen Cabinet lighting switch out of the actions list the errors goes away and the actions take place. I don't understand exactly how to find what the error is coming from. I am using Simple Lighting to watch the Kitchen Cabinet Light Switch to turn off some virtual dimmer switches that are connected to a WiFi H801 RGBW controller. How do I tell what needs fixing,.. is it the virtual dimmer devices causing this? Again it looks very suspicious like this may be all due to my new router setup.

Sorry for getting this involved here. Hindsight says I should have started a new topic.

What are devices 425, 427 and 428? If you click on them from the logs(far left where it says "dev:425"...,it should highlight which device it is at the top of the page.

I went to bed and starting looking again this morning over a cup of coffee. I didn't know about clicking on that far left dev and app hot links to filter out what it was coming from in the logs! Cool tip.

Looks like I have a pattern of the same error with drivers I just put in yesterday :flushed:

dev 425 - Virtual Dimmer Switch from for the R Channel of the H801 RGBWW Controller; East Cabinet. It is used in conjunction with Virtual Device Sync app

dev427 - Virtual Dimmer Switch from for the B Channel of the H801 RGBWW Controller; East Cabinets It is used in conjunction with Virtual Device Sync app

dev 428 - Virtual Dimmer Switch from for the W1 Channel of the H801 RGBWW Controller; East Cabinets It is used in conjunction with Virtual Device Sync app

app:353 Virtual Device Sync - H801 RGBWW Controller; East Cabinets

Yeah..lesson learned from my own troubleshooting adventures in the early goings.

It seems like something is getting hosed between the light controller, the virtual driver and the sync app. Probably a simple command that needs to be properly ported for HE. You should probably reach out to @ericm and the controller driver author (if it wasn't a built in one).

1 Like

I haven't tested the Virtual Device Sync app when used with the H801s separate channels in Hubitat so it may need some work. Since Rule Machine can control the channels by itself using custom commands have you thought about using that instead of creating virtual devices for all the channels?

Edit: I'll move this over to the Device Sync thread. I see you mentioned it there too.

1 Like

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