Hubitat Development Scenario Question

I am,as yet, not a Hubitat user. I posted the question below to the Hubitat team. They simply said Yes to my scenario but suggested I would get some meat on this bone from the forum. Any comments on whether this is straight forward in Hubitat, or not?

My question is, does the Hubitat and it's scripting environment support the following scenario :

  1. Ability to create a virtual switch device

  2. For the on and off commands of a virtual switch to initiate scripts where those scripts can be long running.

  3. For the scripts to be able to send commands to other devices

Without specific info as to what you are trying to do, yes to all three. How difficult depends on what you are trying to do. Some things may be handled better by an app instead of a script.


I agree with @lewis.heidrick's response.

Could you elaborate on what you mean by "long running"?

Edit - do you mean survive a hub restart/reboot?

On another Zwave system I have some Python code that is activated by a virtual switch. This code simulates occupancy, driven by an xml file which dictates which devices are actioned over time. The script continues to run until the virtual switch is set to off which might be a number of days.

There's an app that does that already without much effort.
At Home Simulator


I am not a coder, but why do you even need an app for this?

In Hubitat, you can make a very simple rule for Home or Away, and set modes which can be used globally. There are multiple ways to take occupancy from sensors, phone gps, phone wifi, and so on and use those to determine presence.

Once the presence is set, it just "is". You don't have to continue to tell it you are home. It only needs to be told when there is a change.

Edit: here is the documentation for Mode Manager. Mode Manager - Hubitat Documentation

1 Like

Do you mean turning things on/off (like lights or switches) to simulate human activity as might be inferred by someone outside viewing your home? If so, that is certainly possible, and you actually might be making it more complex with a custom app that you really need it to be. You could create something in Rule Machine (a built-in app that allows arbitrary custom automation creation). However, if sufficiently complex, an app may indeed be easier. At Home Simulator was written for this purpose, though I haven't personally used it and can't say any more about it. There is also at least another similar option or two, though I'm not sure if they are still maintained.

But yes, something similar to what you describe should indeed be possible. It's again hard to say without knowing specifics, unless the above is what you mean. (I also tend to recommend against anyone trying to write a custom app on day 1; there's a lot to get used to, like Hubitat's app, device, and event model, that may be different from other platforms you are used to--though quite similar to ST--to say nothing of the capabilities already present in the stock apps. People don't always take this advice well. I'll say it here again anyway. :slight_smile: )

1 Like

Can you point me to any tutorials on app / script development in Hubitat.

A bunch of good examples here:

It's all written in Groovy which is very javascripty.


Besides the above, the Hubitat development environment is very similar to that of the "classic" (not the "new" model they will soon abandon this in favor of) SmartThings environment, which on the app side you can see here:

However, there are some differences, with this being an old (but it appear still relevant) thread describing most of them:

However, to be sure you're writing for the correct method signatures and other behavior, I'd also recommend looking at Hubitat's actual developer docs:

The reason I'm linking to those last is that, unlike the ST docs, they don't really tell you how or when to use things; they mostly just document what some methods do, (ideally) the signatures of all, and leave it to you to know the rest.

That being said, this is a good a time as any to repeat my recommendation from above;

So try the stock apps first, consider Rule Machine (also takes some learning but isn't really custom code; there is lots of written documentation and examples, plus a couple videos), and try development if you want to--but I don't think you'll need to start at either of those last two places to get most of your automations.

Good luck!


Thanks guys. You have been very helpful

Anytime. I use to write a lot of custom code but here with Hubitat I can do pretty much anything I can dream of with what's already available. If you need anything everyone here is super helpful and quick to respond.