Need help getting ench to work

Hi everybody,

I installed ad-ench (github), hoping to finally manage my battery devices, or rather, be notified when batteries are running low.

However, when I change something in apps.yaml (to trigger reloading ench), I get this

2020-05-19 15:55:00.319878 INFO AppDaemon: Initializing app ench using class EnCh from module ench
2020-05-19 15:55:00.322201 WARNING AppDaemon: ------------------------------------------------------------
2020-05-19 15:55:00.322325 WARNING AppDaemon: Unexpected error initializing app: ench:
2020-05-19 15:55:00.322416 WARNING AppDaemon: ------------------------------------------------------------
2020-05-19 15:55:00.322669 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/", line 2051, in check_app_updates
  File "/usr/local/lib/python3.6/site-packages/appdaemon/", line 1567, in init_object
    modname = __import__(app_args["module"])
  File "<fstring>", line 1
    (await self._name(entity))
SyntaxError: invalid syntax

I am using the official appdaemon docker container; since I couldn’t figure out what did this, I already tried the following

  1. looked through; in line 37, there is APP_REQUIREMENTS = {"adutils~=0.4.9"}; if I understand correctly, the other file in the folder is supposed to install this package for us, but I still created requirements.txt in the appdaemon root folder and inserted the line adutils~=0.4.9. Then I restarted the docker container and immediately started log output, where I could see that adutils was installed (so it had probably not been installed by this file.

  2. line 57 states LEVEL_ATTRIBUTES = ["battery_level", "Battery Level"], however, some of my devices have the attribute battery only, so I modified the line to LEVEL_ATTRIBUTES = ["battery_level, Battery Level", "battery"]; I did this because the particular sensor that I manually change to trigger ench does not have a battery_level attribute but a battery attribute.

It still does not work.

The part about ench in apps.yaml

  module: ench
  class: EnCh
  show_friendly_name: false
   - sensor.arbeitszimmer_tuer_battery
    interval_min: 1
    min_level: 20
    interval_min: 30
    max_stale_min: 15
      - sensor.arbeitszimmer_tuer_battery

I realized that when I change to "", there will not be an error in the appdaemon logs; however, there will not be any notification, either. I don’t have any low batteries at the moment as far as I can tell, but manually changing the value in developer settings ought to trigger this as well, right?

What do you suggest I try/change to make this work? Low/dead batteries are one of the few problems I haven’t found a decent solution for yet, and I was really hoping that this appdaemon script would change that.

Thank you for your ideas :slight_smile:

Hi @prankousky,

Although I would highly recommend reporting this issue to the GitHub repository, so the owner is aware of this, I will explain in here what the problem is:

In line 189 from here is f"{await self._name(entity)} has low " and although f-strings was introduced in Python 3.6 (version you are using), you could not use await inside an f-string until Python 3.7 (see here). In fact, this is used through the code quite a lot, so either the owner changes this to be compatible with Python 3.6 or you will need to upgrade to Python 3.7 or higher.

You mentioned you use the official appdaemon container, but as far as I know, the official Docker image uses Python 3.8 (

I will be raising an issue to the repository so the owner is aware of this and act accordingly.

1 Like

Thank you. I deleted the docker container, ran docker pull acockburn/appdaemon:latest (now running python3.8), and modified my requirements.txt:


Now I get this error, which I had been getting before in a test container (which I ran on my local machine instead of my home server)

2020-05-20 07:05:36.624509 WARNING ench: ------------------------------------------------------------
2020-05-20 07:05:36.624998 INFO AppDaemon: Initializing app group_returner using class group_all_x from module bbgax
2020-05-20 07:05:36.626561 WARNING group_returner: ------------------------------------------------------------
2020-05-20 07:05:36.626836 WARNING group_returner: Unexpected error initializing app: group_returner:
2020-05-20 07:05:36.627029 WARNING group_returner: ------------------------------------------------------------
2020-05-20 07:05:36.627457 WARNING group_returner: Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/appdaemon/", line 820, incheck_app_updates
    await self.init_object(app)
  File "/usr/local/lib/python3.8/site-packages/appdaemon/", line 279, ininit_object
    "object": app_class(
  File "/usr/local/lib/python3.8/site-packages/appdaemon/plugins/hass/", line 46, in __init__
    adbase.ADBase.__init__(self, ad, name, logging, args, config, app_config, global_vars)
  File "/usr/local/lib/python3.8/site-packages/appdaemon/", line 75, in __init__
    self.dashboard_dir = self.AD.http.dashboard_dir
AttributeError: 'NoneType' object has no attribute 'dashboard_dir'

My appdaemon.conf contains dashboard_dir for hadashboard; what else could this be?

   21 appdaemon:
+  20   time_zone: Europe/Berlin
+  19   latitude: !secret latitude
+  18   longitude: !secret longitude
+  17   elevation: !secret elevation
   16   threads: 10
   15   plugins:
   14     HASS:
   13       type: hass
   12       ha_url: ""
   11       token: ""
   10 admin:
    8 api:
!   6 # logs:
!   5 #   logfile: STDOUT
!>  4 #   errorfile: STDERR
    3 hadashboard:
    2   dash_url: ""
!   1   dashboard_dir: "/conf/dashboards"
+ 22    full_path: "/conf/dashboards" # not sure about this part

Hi, I am using ench so maybe I can help.

Here is my appdeamon.yaml (using App Deamon 4):

secrets: /config/secrets.yaml

  latitude: 00.000000
  longitude: 00.0000000
  elevation: 43
  time_zone: Europe/Warsaw
      type: hass
  #dash_dir: /config/appdaemon/dashboards

Thank you @pniewiadowski .

I tried rebuilding AppDaemon from scratch, and now nothing works any longer:


  time_zone: "Europe/Berlin"
  latitude: !secret latitude
  longitude: !secret longitude
  elevation: !secret elevation
  threads: 10
      type: hass
      ha_url: ""
      token: "

  url: ""

  # dash_url: ""




Now whenever I start AppDaemon, I get an error about Pillow not being installed correctly; I assume this is due to zlib missing, if I understand the docs correctly.

So instead of just pulling the image, I used this Dockerfile

FROM python:3.8

MAINTAINER mezz64 <[email protected]>

RUN apt-get update && \
    # apt-get install musl make g++ python3-dev build-base jpeg-dev zlib-dev && \
    apt-get install -y apt-utils musl make g++ python3-dev python3-pip zlib1g-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
VOLUME /conf

# Grab source
RUN git clone .

RUN pip3 install .
RUN pip install .
RUN pip install --upgrade pip
RUN pip3 install --upgrade pip
RUN pip install Pillow colorthief colour colormap easydev adutils
RUN pip3 install Pillow colorthief colour colormap easydev adutils

CMD [ "appdaemon", "-c", "/conf" ]

FROM acockburn/appdaemon:latest

I use both pip and pip3 install, merely because I am not sure which one should work. The really weird thing: when I start AD, I get the error about Pillow, but also that colorthief could not be found. When I docker exec -it appdaemon_custom /bin/sh and then pip install colorthief, it looks like it does install it; when I then restart, I get an error about colorthief not being found again. Unfrotunately I cannot use AD in this state at all. None of my scripts work (since the update they won’t work neither in the regular docker image, nor in the custom one I built from the Dockerfile).

I think AD install all packages at every restart/start so this might explain a bit the issue after restart.

Have you tried to remove the add on, reboot HA and install it again, but first AD start with defual config any without any extra packages?

I did a completely new install of AD as you suggested. It seems like everything works now (including ench); I did receive a successful battery alert, but there are errors about ench (cannot paste from here at the moment), so I can’t say for sure if everything is alright.

Just a short update: ench works now. I do get updates within the set periods of time. Yay!

@pniewiadowski since you are using ench as well: do you have a tip how to only watch my actual battery entities? I just got a warning about 66 stale entities, none of which are battery related (for example sensor.dwdpollen62tomorrowavg, which is a seldomly updated sensor that will report pollen values).

I know believe that I could do

  module: ench
  class: EnCh
  notify: ""
  show_friendly_name: False
  exclude: * # This should work..? Just exclude all of them first
  include:   # THEN manually include the ones I want...
    - entity_1.battery
    - entity_2.battery
    # (etc.)
    - entity_342.battery

I am not aware of the actual number here, so there is no entity_342.battery, but I do know for sure that I have many, many entities that display their battery status… and whenever I need a new device (usually via zigbee2mqtt, I’d have to add it to the apps.yaml file manually.

Glad it it working now.

This is my apps.yaml witch ench:

  module: ench
  class: EnCh
  notify: notify.przemek_hangouts
  initial_delay_secs: 240
  show_friendly_name: True
   - sensor.some_sensor_1
   - sensor.some_sensor_2
   - sensor.some_sensor_3
    interval_min: 120
    min_level: 15
    interval_min: 60  

And as far as I get notification for battery and unavailable entities I don’t get notification about stale entities.

Try to add stale and exclude all with the start (don’t now if that work).

sorry for the stupid question but where is the apps.yaml file is located ?

1 Like

I do not have apps.yaml file there .
should i create one ?
if so it should be created in:

or in:


any idea where ?