Which one should I use? Apps Code or Drivers Code or just the rule machine

Hi everyone, a bit of my background first. I am a programmer myself and I am keen on programming. But, I am new to Hubitat coding. I have used Hubitat for few months now and I have setup Homebridge with Raspberry pi with Apps Code and install Xiaomi Motion sensor with Drivers Code.

I bought a good amount of motion sensors. And I gave myself a challenge. I have an idea to use an array of sensors to predict where I am trying to go/moving direction. So lights that is ahead of me will turn on and lights that behind would turn off once I reach a checkpoint and checkpoints could be overlapping by different sensors.

I know that might not be practical but that is a goal for me to learn Hubitat coding. Assuming I will be the only one that in my home, I think that is possible. So, I started with the rule machine 4.0 but I think it is not convenient to cut/copy code and play around.
Could anyone share some insights for me to achieve that or stop me early as that is impossible.

Welcome to Hubitat and the community. I will let others speak to your coding question, but I did want to point out that @bangali has made a great application called Rooms Manager. It does basically everything you are asking about. He might be a good person to talk with about your project.

[Rooms Manager: Smarter Rooms: Personalized home automation with Occupancy]

3 Likes

Wow, this is my ultimate goal.
I can have a look on his code.
Thanks very much.

There are really two parts to your question: a development-oriented question couched in a more general question, which is the difference between apps and drivers. As you use Hubitat more, you should begin to see the difference between these two, but in general, the difference is that:

  • drivers tell Hubitat how to communicate with devices; whereas
  • apps help you create automations using devices.

There are some minor additional considerations you could make to this list (some apps are "service apps" that just help you connect to existing things, like the Hue Bridge Integration, which may assist in making these devices work by "helping" their drivers; and not all apps necessarily work with devices, e.g., Mode Manager can work based on time and other hub events like sunrise/sunset with no devices directly involved at all), but this is the general idea.

Therefore, to do what you want, you would almost certainly want to write an app. However, this is a bit of an undertaking, and Hubitat's developer documentation is not fully fleshed-out. Lots of people, including developers, came here from SmartThings, which has a similar development environment (their "classic" docs are the ones you want--the Groovy-based ones, not the new AWS-oriented ones). This is probably how many such developers learned--and I confess that I still consult the ST developer docs when some things are unclear. :slight_smile:

That being said, I second the suggestion above to just check out the Rooms Manager app above, since it may already do what you want. Otherwise, hopefully this gives you something to think about regardless. Good luck!

The room manager app should do what you want, but I still really encourage you to learn to code. Its not really that hard. Just have to get your mind around the structure of the code and the objects and your automation world will open up to endless possibilities.

At first I started to just tweak other code to to make it work like how I wanted. Added options here and there. Then I started to remove a lot of stuff I don't use to make it leaner. I then just started rewriting all my own apps to make it tighter and easier to support myself. Takes a lot of time, but when something breaks I can dig into the code and figure out quickly.

Its not that difficult, especially with your programming background.