AppDaemon Q&A

What am I confused about, just so I know :wink:

you told him to use internal address after he got the response from a right config.
as i see it when i read back, he got everything right and appdaemon did what it should and you told him to change something and now he has a problem again.

i guess you didnt rcognize it as a right response from appdaemon or your both postings did go about the same time, and you did respond to an earlier post from him, but completed it after he had posted his right config.

Weird - I don;t see the post you are referencing so something is confiused, but it looks like you saved the day again :slight_smile: Thanks!

EDIT: I did see it but I was reading on my phone trying to give end-user support while taking my wife to dinner - serves me right!

@anon35356645 - as Rene says, when you had the duck dns URL, everything was working as expected - now you need to write some Apps!

1 Like

you cant do everything right in the same time.
you were multitasting all day long :wink:
is to be expected that 1 of your threads could give a failure without noticing :wink:

as long as im here i am always at your back :wink:

1 Like

Final update on weatherAlerts for the day. I added some more configuration options to the appDaemon.cfg file. There are multiple ways to specify your location now, including Longitude/Latitude from HA config. You can also control how often it checks in case you have other weatherunderground apps running and are chewing up your daily allotment of requests. Give it a try and let me know what I can do next.

https://github.com/turboc1208/AppDaemonApps/blob/master/weatherAlert.py

1 Like

Thanks a lot for your help, so now is fine? I would expect to have CONNECTED TO HA message, rather the CONNECTING TO HA message

pi@raspberrypi:~/appdaemon $ appdaemon -c conf/appdaemon.cfg
2017-01-22 13:55:21.328739 WARNING 'latitude' directive is deprecated, please remove
2017-01-22 13:55:21.347201 WARNING 'longitude' directive is deprecated, please remove
2017-01-22 13:55:21.347618 WARNING 'timezone' directive is deprecated, please remove
2017-01-22 13:55:21.459427 INFO AppDaemon Version 1.4.2 starting
2017-01-22 13:55:26.694616 INFO Got initial state
2017-01-22 13:55:26.696229 INFO Loading Module: /home/pi/appdaemon/conf/apps/hello.py
2017-01-22 13:55:26.702345 INFO Loading Object hello_world using class HelloWorld from module hello
2017-01-22 13:55:26.703256 INFO hello_world: Hello from AppDaemon
2017-01-22 13:55:26.703617 INFO hello_world: You are now ready to run Apps!
2017-01-22 13:55:26.703956 INFO App initialization complete
2017-01-22 13:55:26.704873 INFO Connecting to HA

Now its [quote=“aimc, post:709, topic:3028”]

  • as Rene says, when you had the duck dns URL, everything was working as expected - now you need to write some Apps!
    [/quote]

Yes!!

Now where I can find some apps?

Bare in mind that I am very good in doing COPY/PASTE, not much else in regards to coding ahah

There are a number of sample Apps in the conf/examples directory.

I have rewritten the connection code in the next version and it does indeed say Connected rather than Connecting.

1 Like

thanks! That will certainly help other newbs like me :slight_smile:

With the latest version of AD, when I get errors in my code while developing, I start getting the following error and the only way to get out of it is to restart AD.

2017-01-22 11:26:34.040170 WARNING ------------------------------------------------------------
2017-01-22 11:26:34.040718 WARNING Unexpected error during loading of test.py:
2017-01-22 11:26:34.041226 WARNING ------------------------------------------------------------
2017-01-22 11:26:34.042252 WARNING Traceback (most recent call last):
File “/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py”, line 701, in readApp
term_file(file)
File “/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py”, line 475, in term_file
term_object(key)
File “/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py”, line 496, in term_object
if hasattr(conf.objects[name][“object”], “terminate”):
KeyError: ‘test’

2017-01-22 11:26:34.042900 WARNING ------------------------------------------------------------

Any ideas?

Presumably test is an app you are working on?

Did it actually compile successfully?

Yes, it’s the one I was using to test out the run_minutely issue I was having. But it gives it to me on everything once that happens. Last night when it started I was working on the weatherAlert program. Over the period of an hour I commented out everything trying to figure out the error. When I finally got it town to 3 lines of un-commented code, I restarted AD and everything started working fine again. LOL

Just as an example, I was trying something else to see if I could duplicate something that I think I saw the other day when this happened.

2017-01-22 12:30:36.063310 WARNING ------------------------------------------------------------
2017-01-22 12:30:36.065544 WARNING Unexpected error during loading of test.py:
2017-01-22 12:30:36.066420 WARNING ------------------------------------------------------------
2017-01-22 12:30:36.075630 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 707, in readApp
    importlib.reload(conf.modules[module_name])
  File "/usr/lib/python3.4/importlib/__init__.py", line 149, in reload
    methods.exec(module)
  File "<frozen importlib._bootstrap>", line 1153, in exec
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1467, in exec_module
  File "<frozen importlib._bootstrap>", line 1572, in get_code
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/hass/code/appdaemon/test.py", line 8
    for a in args
                ^
SyntaxError: invalid syntax

I forgot the : at the end of a for loop. I fixed it, exited the editor and …

2017-01-22 12:30:36.076201 WARNING ------------------------------------------------------------
2017-01-22 12:30:49.041587 WARNING ------------------------------------------------------------
2017-01-22 12:30:49.042117 WARNING Unexpected error during loading of test.py:
2017-01-22 12:30:49.043170 WARNING ------------------------------------------------------------
2017-01-22 12:30:49.044392 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 701, in readApp
    term_file(file)
  File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 475, in term_file
    term_object(key)
  File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 496, in term_object
    if hasattr(conf.objects[name]["object"], "terminate"):
KeyError: 'test'

2017-01-22 12:30:49.044893 WARNING ------------------------------------------------------------

Boom…

AH, OK, I see what is happening - I’ll fix that in the next version.

Cool,
I hate continually bringing these things up. But honestly, I hope I’m just helping you make it better. If there is ever anything I can do from the coding side to help out, let me know. I’m happy to help.

1 Like

No, you are helping immensely to make AppDaemon more solid - keep it up!

1 Like

Could the following change to get_app make it into the next release ?

def get_app(self, name):
return conf.objects[name][“object”] if name in conf.objects else None

It was blowing when the app wasn’t there. This will let it return None if it’s not there allowing it to be used to check if an app is being used by that person or not.

1 Like

Sure. - can you raise an issue on GutHub to remind me please?

How do state changes work in AD? If an input_boolean is switched on in HA, can multiple apps listen for that state change and respond to it or is it consumed as soon as someone picks up the state change off the buss?

You can listen for it with as many callbacks as you like.