One app for all motion?

I recently discovered Appdaemon and it looks really promising. Since it’s python code, we can write more complex automations. Does this mean that I in one app can trigger light for all motion sensors? Even if the action is different for each motion?

Is this prefersble or should one use an app per automation in HA?

1 Like

Theoretically, yes. I only say theoretically as you can probably do this but I can’t - I don’t know Python well enough yet to program from scratch. But from my involvement in it from use and my beta testing for HA Dashboard v2, I can’t see why you couldn’t accomplish it easily.

There’s no rule here except your level of programming. Most folks who do Python prefer to use AD for all their automations. I use a few apps that were written by others and still do my automations and scripts in HA. My guess is that once you start using AD, you will probably use it for everything. And then find new stuff you can add to HA from AD - like creating sensors.

1 Like

Yep, if you know Python (or are willing to learn, it’s not too tough), you can do virtually anything with AD. I don’t even use modules properly, as I prefer more granular control. I just use AD to keep my different apps running, and specify all my sensors and switches within the apps, rather than parameterizing.

2 Likes

This is pretty much the standard reply from people who use it. My guess is that you’ll see Rene (ReneTode) in here in a few, extolling it’s virtues. He got into early and has done amazing things with it. Another user is Chip (turboc) who has a real knack for creating useful stuff; in fact I’m running two of his apps now and will be deploying a third when he gets it ready for testing.

Andrew (aimc) built an incredible thing and when he first told me about it, I still don’t think I realized the scope of it but I knew it was important.

Now, just for fun, I’m not going to tag any one of them; let’s see who finds this thread first!

2 Likes

You can easily do it two ways

You can either in 1 app subscribe to all motion sensor events and then just write logic around triggers from each sensor.

OR

You can write a small app that takes 1 sensor and what lights to control and then use the configuration file.

Andrew and Rene has already written one solution to this: AppDaemon motion detectionlights version 1.1

2 Likes

Exactly, that was what I asked initially. I assumed that it could be done in to ways.

Is there any advantage to split them in smaller apps? I’m thinking of maximum 1 app to control motion sensor, 1 to control light switch and use logic to do the automation I want.

Most importantly will the lights etc react slower depending on solution between those two?

I would say that you try one way out and see how you like it. It’s all about personal preference.

But no, performance wouldn’t differ much between solutions I’d reckon. Unless you need more advanced intelligence between sensors and rooms I think to have a small app that with a configuration with the mapping sensor and lights.

In my case I’m looking into doing something more intelligent for the whole house, but I’m still only thinking about how that would work.

I agree with others; you should arrange your apps the way that makes sense to you. There isn’t any consensus on the best way of doing anything yet.

Here is what I have found. I have one app that controls just about everything from a light perspective. It is not long, but it has a rather complicated data structure in the form of a python dictionary. The problem here is that it does general things really well, but since it has to conform to a specific data structure, making it handle on-off things is difficult to do without breaking something else. I also have a few apps, that control one specific type of thing. I have an app that monitors my printers ink levels, one that monitors the battery levels on all of my non-wired devices. The beauty here is that one type of device usually has a limited number of different things that can be done, so the coding is simple and the maintenance is isolated.
What i am finding is that it’s easier to think about automations from the perspective of the light or the thing being controlled. What things impact this particular light or ceiling fan. I am starting to approach this on a room by room basis. What things impact the light in my office? Well there is the wall switch, the door to my office, the TV and the motion detector. Depending on the state of each, I either want the light on/off/dim. It’s easy to put together an app that watches for those events and adjusts the light accordingly. Trying to have an app that controls the light from the perspective of the motion detector became difficult because it had to consider other devices and it got confusing.
So in short, I am finding that multiple apps, built around rooms seem to be the best way for me to go. But like everyone else is also saying, it’s up to you. Everyone is different and what works for you and your automations may or not work for me. Anyway you go, there are plenty of people here that will offer their opinion and help out however they can.

2 Likes

I win … What’s unclear about I win. It has a subject “I” and a verb “win”. Yes it is a complete sentence.

1 Like

Honestly, I figured it would be you! Congrats!

And thanks for your input, Chip.

Thanks for your answer. Your suggestion and experience is appricieted, will try this approach.

Let us know if we can help. We are all learning. I’ve started over my method about 3 times I think. And make sure you backup your source :slight_smile: (experience speaking here). LOL

2 Likes

Oh GOD yes. :wink: And get into the habit of backups. Mine are automated nightly using Webmin and a cron job. Then once a week or so I pull a copy from the Pi to my backup drive.

1 Like

I store my automations in a private repo on gitlab

a bit late, but my remarks:

i try to keep my apps as small and simple as possible with clear names.
i try (but mostly forget) to comment what the app is all about and which args it uses.
the more you put in 1 app the more you can lose track off things.
a list from all apps is easy to find with winscp, a list from classes you did put into apps isnt.
so if the list of automations grows (and it will more, and more, and more, …) you will end up with 1 app which is unmanagable or you end up forgetting in which module you have put classes.

if you put in more classes in 1 app, then make sure they all have to do with the same subject. (lights with lights, motion with motion, etc.)

1 Like

The funny thing about Rene and me is that we both respect each other and enjoy talking and working on things. But we each come at issues from almost completely opposite frames of reference. The beautiful thing is that both ways work. Rene’s way works for him. My way which tends to make larger apps, works for me. It is really up to the developer and what they are comfortable with.

2 Likes

To be fair, Rene approaches all of life from a different direction.

But that’s what makes him one of my favorite people!!

1 Like

i was born strange, and have been all my life. :wink:
as a baby i never cried and slept most of the time and as a toddler i was already one of the adults when there was a birthday. talking with adults about adult stuff.
noone has told me how to read or count because i could do that before anyone noticed.

so yeah i must have been strange from the day i came into this world, and i probly will die strange also :wink:

1 Like

Don’t feel too strange; you’ve essentially described my childhood! So apparently there are more of ‘us’ out there than we may have thought.

I understand better now why we felt a kinship right away. I really hope that I will get a chance to meet you and Andrew in real life at some point.

1 Like