Unexpected error in worker for App alarm_system

I have this error…

2019-01-15 08:59:48.013608 WARNING AppDaemon: ------------------------------------------------------------
2019-01-15 08:59:48.014674 WARNING AppDaemon: Unexpected error in worker for App alarm_system:
2019-01-15 08:59:48.018148 WARNING AppDaemon: Worker Ags: {'name': 'alarm_system', 'id': UUID('6e3f017f-ca8e-4c09-ab67-9439630cfaa3'), 'type': 'timer', 'function': <bound method AlarmSystem.camera_snapshot of <alarm.AlarmSystem object at 0x748e5090>>, 'kwargs': {}}
2019-01-15 08:59:48.020375 WARNING AppDaemon: ------------------------------------------------------------
2019-01-15 08:59:48.024364 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 586, in worker
    funcref(self.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/alarm.py", line 287, in camera_snapshot
    self.log("Camera snapshot {} stored as {}".format(self._snap_count, filename))
UnboundLocalError: local variable 'filename' referenced before assignment
2019-01-15 08:59:48.026008 WARNING AppDaemon: ------------------------------------------------------------

Hassio v. 0.85.1

HI @ReneTode can you help me?

the error is actually saying what is wrong.

in line 287 you got

self.log("Camera snapshot {} stored as {}".format(self._snap_count, filename))

and the var filename doesnt exist at that point.
thats why you get

local variable 'filename' referenced before assignment

Thank you @ReneTode
Restarting again Hassio Appdaemon seem to starts without errors…

From some days I suffer from many errors in HA
It start very slowly (about 4 minutes)
sometimes it show me errors like…

[homeassistant.components.recorder] Ended unfinished session
[homeassistant.setup] Setup of hassio is taking over 10 seconds.
[homeassistant.components.hassio.handler] Timeout on /supervisor/options request

not all automations are started… becouse some automations works and some other do not works.

What’s happening?

you got hassio, probably on an RPI?
and you got recorder and history on.
that gives a heavy load on the SD card.
and SD cards go bad over time when you do a lot of writing to it.
so its very well possible that your SD card is going bad.

when HA takes long to startup, you need to make sure that apps are written well and that they check if all needed components in HA are already started.

Yes I have Hassio installed on Rpi3
I use recorder function
I can try to disable the recorder function but it was useful when something was not working or working badly
I replaced SD card less than a month ago with a new Samsung EVO Plus 32 GB, UHS-I 95 mb / sec

thats only 1 of the possible options.
i dont know what you have installed in HA, which components might bug you.

if you only recently got this kind of problems it might be worth to disable things (temperarely) you added recently to see if that helps.

you should have a backup SD card anyway, so it might be worth a try to copy the SD card and see if it makes a difference.

i mounted a external HD to move all stuff to that gets regularly rewritten when i had my RPI, but i think that wont be easy with hassio.

@ReneTode
I have installed these addons:

  • Appdaemon 3
  • Bluetooth BCM43xx
  • Duck DNS
  • Mosquitto broker
  • NGINX Proxy
  • SSH Server
  • Samba share

If I decide to use a better hardware for Hassio what do you suggest me?
I saw many people installed it on a mini pc with Ubuntu Server 16.4
If I will buy a mini PC …with Intel N3450 and I install Ubuntu it will be more performant?

i also moved to a mini pc (a beebox) over a year ago. and indeed i also installed ubuntu (18 at the moment)

i think i got my beebox restarted 3 times in the last year.
with 4x AD, 2x HA, mosquito and nginx running i got up to 15% cpu, still lots of space (with 4 cams connected to FTP server on the beebox) but i bought a 240 Gb SSD
even with 4 GB ram i got plenty.

thats absolutely not a bad investment, and i am sure this will hold for years.

My appdaemon show these errors… what could be?

2019-01-16 19:01:58.098631 WARNING AppDaemon: Excessive time spent in utility loop: 1074.0ms
2019-01-16 19:11:59.454899 WARNING AppDaemon: Excessive time spent in utility loop: 936.0ms`

I followed your sugestion and setted ha_url with the local IP
Now seem it do not show Excessive time spent messages

so it did show excessive time with external url, but not without?
in that case your internet connection was slowing things down.

AD has a timeloop from 1 second. if actions take up longer then that it leads to those warnings.
when its rare and not high, you dont need to worry about it.

I have a fiber FTTC 40 mb/sec download… it is strange

nope isnt strange.
its not how fast your connection is.
but all connections between your router and your DNS server.
including the DNS server itself.

so if only 1 off those connectionpoints or the DNS server is more busy as usual, then the connection from your AD to your HA will get a holdup.
thats why you dont want AD to connect to HA through outside DNS

From Yesterday nigth it show me this error again…

2019-01-17 09:14:52.260314 INFO alarm_system: Stopping camera snapshot timer
2019-01-17 09:14:52.283436 INFO alarm_system: Starting camera snapshot timer
2019-01-17 09:14:53.019855 WARNING AppDaemon: ------------------------------------------------------------
2019-01-17 09:14:53.020961 WARNING AppDaemon: Unexpected error in worker for App alarm_system:
2019-01-17 09:14:53.022261 WARNING AppDaemon: Worker Ags: {'name': 'alarm_system', 'id': UUID('e5c16be7-6835-4022-abe2-478e52a09324'), 'type': 'timer', 'function': <bound method AlarmSystem.camera_snapshot of <alarm.AlarmSystem object at 0x7485f030>>, 'kwargs': {}}
2019-01-17 09:14:53.023373 WARNING AppDaemon: ------------------------------------------------------------
2019-01-17 09:14:53.029082 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 586, in worker
    funcref(self.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/alarm.py", line 287, in camera_snapshot
    self.log("Camera snapshot {} stored as {}".format(self._snap_count, filename))
UnboundLocalError: local variable 'filename' referenced before assignment
2019-01-17 09:14:53.030404 WARNING AppDaemon: ------------------------------------------------------------

in practice it happens just after activating alarm system … it makes the light flash for 40 seconds in pending time and then executes this command about camera_snapshot
I never received this error before this week…

The project is this: AlarmSystem with appdaemon

It not define a camera_snapshot name.

if you dont know how to changes codes yourselve, you need to contact the person who created it (best way is on github, where you probably found it)

i explained what the error means.

I did it yesterday… I hope it will answer me soon… or I will change alarm system becouse this isn’t managed from january 2018

ill think you find that problem with a lot of apps.
people write them mostly for themselves, and if it works for them they just use it and dont look at github. and if they stop using it they dont remove it, for obvious reasons.

I might have some time this weekend to look into the code.