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/appdaemon.py", line 2051, in check_app_updates
self.init_object(app)
File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", 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
looked through ench.py; in line 37, there is APP_REQUIREMENTS = {"adutils~=0.4.9"}; if I understand correctly, the other file in the folder pkg_helper.py 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 pkg_helper.py file.
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.
I realized that when I change notify.me to "notify.me", 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.
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.
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 https://github.com/home-assistant/appdaemon.git .
# INSTALL
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 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
ench:
module: ench
class: EnCh
notify: "notify.me"
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.