Announcement - AppDaemon 3.0 beta 1!

lol i had already typed the question “is the arg an int?” when i saw you replying :wink:

1 Like

Nope, I’ve tried without using self.args, setting duration = 180 manually, but same result

So to be clear, the light goes off as soon as the sensor stops registering motion, but you want it to stay on for a period after that?

Correct. The motion sensor sends “off” motion after 2-3 secs, and after that it sends “on” again if motion detected, but I want light turn off after the period of inactivity (usually 3 minutes).

hmm then I think docs need to be updated.

http://appdaemon.readthedocs.io/en/latest/APIREFERENCE.html#examples

fwiw, I’ve been using the same way as as docs example to get attribute in v2 and it was working fine for me but not v3

Hmm, so something I am not crazy about is the ‘load every yaml file everywhere’. I was actually using yaml to hold a list of varied speech responses and was planning to move some other things into a yaml file for config in order to generalize my app a bit. Not a huge deal and don;t expect you to change it really, but it does seem a little overkill in that there is only so much you configure in there (at least me) and it precludes using a subdirectory under apps to hold any data. Easy solution for me is to move everything out and just symlink my specific.py file so I guess I am just griping.

Actually the more I think on it, I think it would be helpful to only read either apps.yaml or app.yaml so we can use relative path references if we want to load yaml files.

@aimc is there anyway to get the last updated time of an entity?

I’ve tried

self.get_state('my_entity_id', attribute='all' )

But I don’t see anything related to last updated time.

Thanks!

You can always record the last state update time yourself in a callback.

last_update = self.time()

isnt that just what the configuration files are used for?
an example from my alexa.yaml (used for my alexa app)

alexa_api: # appdaemon skill
  module: alexa_api
  class: alexa_api
  logfile: /mnt/usbdrive/pi/HAlogs/alexaAD.log
  logging: "True"
  launchRequest:
    - gutentag, bist du wieder da? wie kann ich dir helfen?
    - Hallo, wie gehts es dir? kann ich etwas fuer dich tun?
    - Hi, da bist du wieder. was kan ich machen?
    - Schoen das du wieder da bist, was ist dein wunsch?
  intentEnd:
    - Kan ich noch etwas fuer dich machen?
    - Willst du das ich noch etwas anders mache?
    - Kann ich dir weiter mit noch etwas helfen?
    - Gibt es noch etwas was ich fuer dich tun kann?
  conversationEnd:
    - Ok, bis dann
    - Bis naechste mal
    - tjusch
    - Schoen mit dir gesprochen zu haben
    - Ok, ich sage Lindon schoene grusse
  responseError:
    - Es tuet mir leit aber etwas ist falsch gegangen
    - Leider meldet lindon ein fehler 
  responseHelp:
    - "Ich kann folgendes fuer dich tun: auf youtube suchen, ein video zeigen, ein kamera zeigen, der temperatur sagen, sagen oder ein lampe an oder aus ist, sagen wo jemand ist oder was er macht oder nochmal hilfe geben"
    - "Ich kann helfen mit: auf youtube suchen, ein video zeigen, ein kamera zeigen, der temperatur sagen, sagen oder ein lampe an oder aus ist, sagen wo jemand ist oder was er macht oder nochmal hilfe geben"
    - "Du kannst mir fragen um: auf youtube suchen, ein video zeigen, ein kamera zeigen, der temperatur sagen, sagen oder ein lampe an oder aus ist, sagen wo jemand ist oder was er macht oder nochmal hilfe geben"
  household:
    - rene
    - olinde
    - farah
    - marjolijn
    - fara
  WhatDoesSomeone:
    frank:
      - "lindon fragt, ist er nicht am schlafen?"
      - "lindon sagt, ist er nicht da? vielleicht schlafft er jetzt zu hause."
      - "lindon fragt, hast du bei der toilette geguckt?"
    vati:
      - "lindon sagt, der kommt bestimmt gleich"
      - "lindon sagt, huh, wass?"
    rene:
      - "lindon sagt, der ist vielleicht bier holen"
      - "lindon sagt, er ist auf seine eigene planete"
    olinde:
      - "lindon sagt, das sie ihr geburtstag am feiern ist"
      - "lindon sagt, das sie im keller ist"
    marjolijn:
      - "lindon sagt, das sie in ihre eigene welt ist"
      - "lindon sagt, das sie auf ihre feste platze sitzt"
    sven:
      - "lindon fragt, ist er vielleicht am arbeiten?"
      - "lindon fragt, hast du in der ecke geschaut?"
    markus:
      - "lindon fragt, was, wer? gibts die auch noch?"
      - "lindon fragt, lebt die noch?"
      - "lindon sagt, ich habe gehoert bei ricoh"

  VideoShowTime: 180
  YoutubeVideoList:
    - dash_youtube_single1
    - dash_youtube_single2
    - dash_youtube_single3
    - dash_youtube_single4
    - dash_youtube_single5
    - dash_youtube_single6
  VideoWidgetsOverviewDash:
    - "vid1"
    - "vid2"
    - "vid3"
    - "vid4"
    - "vid5"
    - "vid6"
    - "vid7"
  VideoWidgetsSingleVideoDash:
    - "vida1"
    - "vida2"
    - "vida3"
    - "vida4"
    - "vida5"
    - "vida6"
    - "vida7"

  CamShowTime: 30
  CameraList:
    garten: dash_terrascam
    terrasse: dash_hoofdterrascam
    keller: dash_kellercam

  temperatureSensors:
    wohnzimmer: sensor.huiskamer_box_4_1
    schlaffzimmer: sensor.slaapkamer_1_30_0
    terrasse: sensor.vijver_repeater_7_0
    keller: sensor.arduino_kelder_1_0
    teig: sensor.vijver_repeater_7_1
    aquarium: sensor.arduino_kelder_1_0
    kueche: sensor.keuken_10_0

its a great thing that apps now have their own yaml files.
naming them all app.yaml would be difficult and would create the need to put everything in sub dirs.
i think you still can use yaml for other things as long as you dont use an appstructure in it.
and if there real need for it i think its possible to create an exclusions list in the future. (but if its decent yaml, i dont see why)

and there is no need to use paths to yaml files in the apps directory at all.
all yaml in there is already read and available as variables.

1 Like

I had to check the code to answer this - currently, although the info is available from HASS, AD discards it and maintains a copy of just the latest state info, not any of the supporting info, so no, there is currently no way to get this.

I might look into adding this at some point because it seems like a reasonable thing to ask :slight_smile:

My bad, I hadn’t reallythought of that, but it still has issues for me. One of my issues is that part of my yaml is a list of tv shows to netflix and amazon content ids that is auto generated by another script and is over 3000 lines.

It will be a fair bit less clean since I will have to include everything in one file. Like for your example you might move your responses in a de.yaml and have an en.yaml and just specify the lang in the app file.

I don’t think moving things into subdirs would be that bad of a solution if you wanted to break up your app.yaml, pretty similar to what the HA configuration does to break up the config. That would allow someone to just dump a subdirectory containing an app.yaml file into a apps and not have any conflicts.

I just don’t like think the idea of every yaml everywhere is an app so if you want to use yaml you have to include it in this monolithic app file or do some hacky work around like specifying paths outside the app dir, renaming your yaml files to some other extensions (this_file_is_actually_yaml.hack) or just not use yaml. It just makes appdaemon less flexible in my opinion rather than more.

Should these utlity loop errors be an issue?

Jan 23 10:05:07 home appdaemon[13447]: 2018-01-23 10:05:07.139858 INFO AppDaemon: Loading Object jarvis using class jarvis from module jarvis
Jan 23 10:05:07 home appdaemon[13447]: 2018-01-23 10:05:07.144222 INFO jarvis: Jarvis is alive
Jan 23 10:05:08 home appdaemon[13447]: 2018-01-23 10:05:08.534733 WARNING AppDaemon: Excessive time spent in utility loop: 1420.0ms

@aimc one last thing, I have some helper scripts in my apps/jarvis subdirectory that trigger this error

Jan 23 10:07:42 home appdaemon[13447]: 2018-01-23 10:07:42.869603 INFO AppDaemon: Reloading Module: /home/homeassistant/.homeassistant/apps/jarvis/jarvis_core.py
Jan 23 10:07:42 home appdaemon[13447]: 2018-01-23 10:07:42.870126 INFO AppDaemon: Loading Module: jarvis_core
Jan 23 10:07:42 home appdaemon[13447]: 2018-01-23 10:07:42.871322 WARNING AppDaemon: ------------------------------------------------------------
Jan 23 10:07:42 home appdaemon[13447]: 2018-01-23 10:07:42.871613 WARNING AppDaemon: Unexpected error during loading of jarvis_core:
Jan 23 10:07:42 home appdaemon[13447]: 2018-01-23 10:07:42.871832 WARNING AppDaemon: ------------------------------------------------------------
Jan 23 10:07:42 home appdaemon[13447]: 2018-01-23 10:07:42.872673 WARNING AppDaemon: Traceback (most recent call last):
Jan 23 10:07:42 home appdaemon[13447]:   File "/srv/homeassistant/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1449, in read_app
Jan 23 10:07:42 home appdaemon[13447]:     importlib.reload(self.modules[module_name])
Jan 23 10:07:42 home appdaemon[13447]: KeyError: 'jarvis_core'
Jan 23 10:07:42 home appdaemon[13447]: During handling of the above exception, another exception occurred:
Jan 23 10:07:42 home appdaemon[13447]: Traceback (most recent call last):
Jan 23 10:07:42 home appdaemon[13447]:   File "/srv/homeassistant/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1460, in read_app
Jan 23 10:07:42 home appdaemon[13447]:     self.modules[module_name] = importlib.import_module(module_name)
Jan 23 10:07:42 home appdaemon[13447]:   File "/srv/homeassistant/lib/python3.6/importlib/__init__.py", line 126, in import_module
Jan 23 10:07:42 home appdaemon[13447]:     return _bootstrap._gcd_import(name[level:], package, level)
Jan 23 10:07:42 home appdaemon[13447]:   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
Jan 23 10:07:42 home appdaemon[13447]:   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
Jan 23 10:07:42 home appdaemon[13447]:   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
Jan 23 10:07:42 home appdaemon[13447]: ModuleNotFoundError: No module named 'jarvis_core'

It seems like the app.yaml should determine what .py modules are scanned.

Maybe I am trying to do too much with appdaemon and should write this as a standalone but it seems dumb not to take advantage of all the great things appdaemon does.

I’d be happy to submit as a PR if you agree with the approach or have a different suggestion.

you can do that right now but you dont need to.
i dont want to be restricted to make ALL apps need a subdir and i dont like 100 app.yaml files.
that wouldnt be workable at all. i wouldnt know what where anymore.

I just don’t like think the idea of every yaml everywhere is an app
it isnt.
it is only an app if you put a structure like

test:
  module: test
  class: test

in it. (or at least thats what i expected :wink: )
i just added a test.yaml and it says that it added an app, but without an appstructure that cant be true, so its a logging problem.

you talk about flexibility, but you want to make restrictions.
thats not making it more but less flexable :wink:

Your last point is one I thought about as well and also pertinent to the .py issue above.

So maybe rather than extra yaml files causing a ‘module not found’ exception simply try/expect them and log either a warning or debug message about ‘module not found in {filename}, skipping’ and similar for stray python scripts?

stray python script are noticed, but dont run.
it just is monitored and generates a logentry if modified.
so thats like it should be.

‘stray’ yaml files should do the same.
they should be noticed and it should make a log entry if modified, but it should not ‘run’ or say that it runs anything unless it finds an appstructure in it.

The underlying assumptiuon is that the apps directory belongs to appdaemon, and contains either app files, or app yaml files. Anything else is currently unsupported.

Right, but they generate an ‘Unexpected error’ and a traceback in the logs as opposed to a simple log entry. Exceptions to me should be for things you don’t expect to happen (ie, actual errors).

And in the case of .py files, I don’t think it should be trying to load the module if it isn’t specified in app config.

But in any case, I suppose there’s the answer in that I am trying to do more than appdaemon is meant to do which is a shame.

It is an error in my view per my comments above

Not exactly sure what you are trying to do that AppDaemon can’t other than add files to the Apps directory - could you explain a little more what you are trying to achieve that makes that necessary? I’m happy to listen but at the moment things are working as designed.