Also, the way you are starting it is with a relative path for the config file which assumes you are in the actual AppDaemon directory which probably wasn’t the case after that reboot - just use the full path or cd to the AppDir directory again.
Thanks! For completness it was indeed adding the full path (in my case: /home/pi/appdaemon/conf/apps) and HA_Key = [HASS API PASSWORD]
So this generates the correct output when executing: appdaemon -c conf/appdaemon.cfg (within the appdeamon dir, in my case /home/pi/appdaemon
Now I’m stuck with adding it to auto start. I’m following the below instructions:
#!/bin/bash
# APPDAEMON Service
# Add this file to /etc/init.d/
# $ sudo cp appdaemon /etc/init.d/
# Update variables PATH to suit your installation
# $ sudo nano /etc/init.d/appdaemon
# Make executable
# $ sudo chmod 755 /etc/init.d/appdaemon
# Update rc.d
# $ sudo update-rc.d appdaemon defaults
# APPDAEMON will start at boot. Check out the boot log for trouble shooting "/var/log/boot.log"
# USAGE: start|stop|status|logs
What I did:
I copied the appdeamon file (the one without the .service extension) to /etc/init.d/ with winSCP
sudo cp appdaemon /etc/init.d/ then generates an error (I guess this command copies the file to the correct directory but as it already exists due to step 1 it generates and error)
sudo nano /etc/init.d/appdaemon : this opens an editor. Not sure what to do here
$ sudo chmod 755 /etc/init.d/appdaemon
$ sudo update-rc.d appdaemon defaults
Then I do a sudo reboot.
I want to check what boot.log mentioned but the file does not exist.
So it could be that it’s now running but not sure how to check
Hi,
I want to test temperature sensor form a temperature sensor and to compare it with with the setpoint set using an input_slider. How can I address the temperature sensor and input_slider? I see only references to binary sensors in all the examples. thanks.
Will show you if it is running or not. When running with the init script you will want to set up logfiles for the log and error log or you won;t see what it is doing - this will also help you see if it is running or not.
The step you skipped with the editor: you need to edit the file to reflect your environment or it will almost certainly not work,
just use the appropriate entity ids they should all work. For instance, your temperature sensor should be something like sensor.temperature or some other name, When you know that you can use get_state() or listen_state() as with the other examples.
For the input slider, the same applies - you just need to know the full entity id.
It doesn’t matter where the files are as long as the directory exists.
In the init (appdaemon) file, since I can’t forsee where you will install it you need, at a minimum to set the APPDAEMON_DIR to point to where you did the clone to so that it can find the executable.
Below is output of ps -ef | grep appdaemon after a full reboot. Can you pls confirm that this confirms its running? The log file only mentions “2016-09-17 20:40:15.331272 INFO AppDaemon Version 1.3.3 starting” but nothing else.
Yes its running - buit I am guessing you still haven’t filled in the “app_dir” path in the appdaemon.cfg file. Add it in, then you should be able to restart AppDaemon with:
Yes hello.py is in the Apps directory. It’s also on the log. The only thing I don’t understand that it does not show the ‘hello’ part at the bottom of the log. See below (I only removed a few " 2016-09-17 21:25:13.460325 WARNING Not connected to Home Assistant, retrying in 5 seconds" messages (guess they get there when I restarts HASS)
2016-09-17 20:38:18.425304 INFO AppDaemon Version 1.3.3 starting
2016-09-17 20:38:18.563654 INFO Got initial state
2016-09-17 20:38:18.564742 INFO Loading Module: /home/pi/appdaemon/conf/apps/hello.py
2016-09-17 20:38:18.567802 INFO Loading Object hello_world using class HelloWorld from module hello
2016-09-17 20:38:18.568927 INFO hello_world: Hello from AppDaemon
2016-09-17 20:38:18.569321 INFO Loading Module: /home/pi/appdaemon/conf/apps/occusim.py
2016-09-17 20:38:18.569642 INFO hello_world: You are now ready to run Apps!
2016-09-17 20:39:54.514429 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 20:40:15.331272 INFO AppDaemon Version 1.3.3 starting
2016-09-17 21:01:59.754202 INFO AppDaemon Version 1.3.3 starting
2016-09-17 21:02:00.757243 INFO Got initial state
2016-09-17 21:02:00.758770 INFO Loading Module: /home/pi/appdaemon/conf/apps/hello.py
2016-09-17 21:02:00.762961 INFO Loading Object hello_world using class HelloWorld from module hello
2016-09-17 21:02:00.765798 INFO hello_world: Hello from AppDaemon
2016-09-17 21:02:00.766340 INFO Loading Module: /home/pi/appdaemon/conf/apps/occusim.py
2016-09-17 21:02:00.766851 INFO hello_world: You are now ready to run Apps!
2016-09-17 21:19:42.150937 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:19:47.163978 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:20:12.235121 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:20:17.565805 INFO Got initial state
2016-09-17 21:20:17.567137 INFO Reloading Module: /home/pi/appdaemon/conf/apps/hello.py
2016-09-17 21:20:17.569402 INFO Loading Object hello_world using class HelloWorld from module hello
2016-09-17 21:20:17.571210 INFO Reloading Module: /home/pi/appdaemon/conf/apps/occusim.py
2016-09-17 21:20:17.580413 INFO hello_world: Hello from AppDaemon
2016-09-17 21:20:17.581129 INFO hello_world: You are now ready to run Apps!
2016-09-17 21:25:18.473213 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:25:23.485527 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:25:28.506359 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:25:33.525116 WARNING Not connected to Home Assistant, retrying in 5 seconds
2016-09-17 21:28:08.121257 INFO AppDaemon Version 1.3.3 starting
You are pretty much there - occasionally AppDaemon gets stuck when Hass restarts althoug most times it handles it fine. You got the hello world message the previous time before you restarted hass. Restart AppDaemon one more time and you should be good to go.
I think there is still something not ok. Just rebooted again and the only entry added to the log is: 2016-09-17 22:46:20.220475 INFO AppDaemon Version 1.3.3 starting
Nothing after that (eg not starting the hello messages after the starting point.
If I then do a sudo /etc/init.d/appdaemon restart then all goes fine (eg the hello app starts).
So it seems something is starting at startup but still not as it should… Any ideas?
p.s. could it be something with permissions? The files in /etc/init.d all have ‘root’ permissions while the ones in AppDaemon and subfolder have ‘pi’ as owner & group.
Nope, nothing in the error log. Also if I restart HASS (just hass, not a reboot) the daemon also picks up again without any specific action from em (eg I get reloading module & the Hello message). Can’t it be the order of how things are started?
The order shouldn’t matter - if AppDaemon starts before HA it will just keep retrying until HA is up.
What isn’t clear from the discussion so far is whether or not the init script is firing on startup, it seems to be working from the command line. Can you do the following:
Remove both of the existing logs.
2, Run the reboot
Post the contents of both logfiles
Can you also post the modified version of your init script.