AppDaemon Q&A

@aimc if i have read it correctly is bash not easy available, just like a normal program.

if i could just download, install and work with it, i would consider it.
allthough that i am not really a Linux fan. if i could easyly install a microsoft enviroment on my PI i would also do that :wink:

i have almost 25 years of experience in microsoft enviroment and fast zero in Linux, and with all the new things im learning that makes it easier :wink:

i think that for future users (and me) it would be nice if you would make an check in the pycode.
check at start if it is a Linux or microsoft enviroment, and if it is microsoft then blend out the part that dont work.

i have no idea what those part do, but that is something you could document to give a choice for bash.

it would bring something for you to. right now im satisfied as it is and i dont update because off the extra things to do.
that makes that im not a tester from your latest version anymore. if you make app so that i wont have to do things after update i will be testing your latest version as soon as it is there :wink:

It’s very easy to install the Bash shell, and it seems to be 100% compatible with other Linuxes, however, it shouldn’t be too hard to come up with a windows version - you only lose 2 things:

  • The ability to use signals to dump diagnostic information
  • The ability to run as a Daemon

Neither are essential. I’ll take a look at a new version at the weekend.

1 Like

in python i can use lots off ways to retrieve diagnostics info, so i dont think i will miss that.
and i’m ashamed to say but i have absolutily no idea what a deamon is in this case. :wink:
so maybe i would like that in the future, but i cant miss what i dont know :wink:

i look forward to it.

@ReneTode in Windows-land terms, a daemon is essentially a service. It’s a program that runs in the background while you do other things. Usually without having a control window or interface. You set it to run (manually or at startup), it executes, and does what it does. My guess is you are already familiar with programs like these, and it is just the term that is unfamiliar.

If you are interested in learning more, here is the (english) Daemon entry on Wikipedia: https://en.wikipedia.org/wiki/Daemon_(computing)

1 Like

And I would add that when running a service in windows you won’t need the -d flag in all likelihood so no loss there.

The diagnostics from the signals are internal information about the scheduler and callbacks that could be useful to me in some situations but again, not essential - I’ll see if I can come up with another way to gather it if needed.

One question @ReneTode - what python are you using for WIndows so I can test in an identical environment?

@Zen thx. i couldnt let it go this afternoon, so a started searching, and found those things out.
i already started to try some options to deamonize in windows enviroment. :wink:
probably that needs a third party program, but it should be quite simple.
i must say i dont see a lot off advantage from it, i dont like things to run, when i dont see it. if it would make it a lot faster, but even that advantage is not really there.
but ill search for a easy deamonize windows option.
@aimc if im not mistaken i have chosen 3.4
3.5 had some disadvantages mentioned when i started with python, and i hadnt started anything before so i didnt see the advantage from 2.7 at that time (although i am not a fan from installing anything then the latest version)

but you dont have to make a testenviroment especially for me andrew. i have no problem running into something once in a while, if i know that that can happen. i even would like to test things before you release them, because i like the way you think.

"Before running AppDaemon you will need to install the package:
$ sudo pip3 install . "
What package I need to install?
When I run this command:
$ appdaemon -c conf/appdaemon.cfg
get this error: appdaemon: command not found.
Please give me some advise.

The command “sudo pip3 install .” Is the command that installs the AppDaemon package. After you run that command appdaemon is installed and you can run it with the command you were using.

From the terminal, change into the appdaemon directory that you cloned the git repository to, and once you are in there, simply type that command:

sudo pip3 install .

Don’t forget the space and period at the end. What the line is doing is telling the python installer “pip3” to install the python application that is in the current directory. The period means “here” as in “this directory”

This command will install appdaemon into /usr/local/bin/ which is a path in your environment variables so that when you type appdaemon anywhere on the system it will look inside the known paths and find the application without you having to type /usr/local/bin/appdaemon

Obviously it does more than just create the application in that path, but for your purposes, thats all you need to know to get this to work.

2 Likes

Thanks for your information. Great app for automation in hass.

1 Like

Thanks for your explanation!

the first step I run this command:

$ cd appdaemon

after that I run command:

$ sudo pip3 install .

I get a information from terminal:

The directory ‘/home/trungbn/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/home/trungbn/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Processing /home/trungbn/appdaemon
Requirement already satisfied (use --upgrade to upgrade): appdaemon==1.2.0 from file:///home/trungbn/appdaemon in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied (use --upgrade to upgrade): daemonize in /usr/local/lib/python3.4/dist-packages (from appdaemon==1.2.0)
Requirement already satisfied (use --upgrade to upgrade): sseclient in /usr/local/lib/python3.4/dist-packages (from appdaemon==1.2.0)
Requirement already satisfied (use --upgrade to upgrade): configparser in /usr/local/lib/python3.4/dist-packages (from appdaemon==1.2.0)
Requirement already satisfied (use --upgrade to upgrade): astral in /usr/local/lib/python3.4/dist-packages (from appdaemon==1.2.0)
Requirement already satisfied (use --upgrade to upgrade): requests>=2.6.0 in /usr/local/lib/python3.4/dist-packages (from appdaemon==1.2.0)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python3/dist-packages (from sseclient->appdaemon==1.2.0)
Requirement already satisfied (use --upgrade to upgrade): pytz in /usr/local/lib/python3.4/dist-packages (from astral->appdaemon==1.2.0)

but when I run command:

trungbn@TrungPC:~/appdaemon$ sudo appdaemon -c conf/appdaemon.cfg
[sudo] password for trungbn:

input the pass then nothing happen. No information display. I already successful in running appdaemon v1.0.

If you have already uses PIP to install appdaemon try uninstalling it first:

$ sudo pip uninstall appdaemon

Then re run the install command.

EDIT: I just added this to the instructions.

One of the things I miss most after converting to HA is the ability to trigger events randomly +/- a set amount of time around sunrise or sunset. I have imported random and can make the app trigger a set amount of time after sunrise or sunset but cannot for the life of me figure out how to make it trigger before. I suppose that if I wanted +/- 30 minutes I could set it to -60 minutes in the init section of the class and then set a random number between 1 and 60 in the callback. Just not sure this is the wisest way to accomplish this. Any suggestions?

A negative number will trigger before sunrise or sunset, so just generate a random number from 1 to 60 then subtract 30 for example to get plus or minus 30 seconds (obviously multiply by 60 to get minutes) - will that do what you need?

Edit: to get it to fire at a different time each day I would set a callback to run at say 60 mins before sunset, then use run_in() with a random number of seconds (e.g. 0 - 120*60) to call a second callback that actually turns the light on or whatever.

I might look into adding randomized times to some of the scheduler calls. I think that would be useful.

1 Like

Yes but will generating a random number and replacing the -30 with that number in the below statement from the init section of the class generate a different number on a daily basis?

self.run_at_sunset(self.sunSet, datetime.timedelta(hours = 0, minutes = -30).total_seconds())

I didn’t think it would. I assumed that it instantiated the callbacks into the scheduler and only got run by that mechanism.

See my edited comment above - you are right, my initial thought wouldn’t work.

Yep, that would work too. Thanks for the suggestion and you have my thumbs up vote for adding the randomization stuff to the scheduler! :slight_smile:

Taking an initial look now :slight_smile:

Just started using this yesterday…all I can say is… WOW and Thank You. :grinning:

This is saving me so much time & frustration. I can finally do all the things I had to settle with because the limitations of the YAML based automatons.

I did notice that the example for get_app() in the API.doc is for split_entity() so you may want to fix that. :wink:

Also any chance for using multiple Callback Constraints of the same type in the config?:pray:
I would love to be able to use multiple input_boolean or input_select Callback Constraints.

Huge Props to all the Home-Assistant Devs & Community for all their hard work & making Home Automation fun & enjoyable. This is a fantastic community. :slight_smile: