Hi everyone! I’m quite new to home assistant and I’m struggeling with getting further into appdaemon.
My current system is: HA and Appdaemon both the lastest version, under seperate users in virtual environments on a rasperryPi 3B+. Python version is 3.7
The basic appdaemon apps are working so far - the hello.py, also some interaction with HA.
I am now trying to run a python script with imports when an event is triggered inside HA. The script is supposed to show a rainbow on the MATRIX Creator module mounted on the Pi. When running by itself it works. So far I’ve tried two ways.
- I copied the code into the working example of reacting to an event
from matrix_lite import led
from time import sleep
from math import pi, sin
import appdaemon.plugins.hass.hassapi as hass
class Rainbow(hass.Hass):
def initialize(self):
event="rhasspy_Party"
self.listen_event(self.fewSecEverloop, event)
def fewSecEverloop(self, event_id, payload_event, *args):
everloop = ['black'] * led.length
ledAdjust = 0.51 # MATRIX Creator
frequency = 0.375
counter = 0.0
tick = len(everloop) - 1
while True:
# Create rainbow
.......
this gives me the error
No module named 'matrix_lite'
However, when i run the .py (without hass part) by itself there is no such issue. I’ve already tried adding the module to the requirements.txt, which did’nt make a differnce.
- My second attempt was calling the python script as a subsystem:
import os
import appdaemon.plugins.hass.hassapi as hass
import subprocess
class Rainbow(hass.Hass):
def initialize(self):
event="rhasspy_Party"
self.listen_event(self.fewSecEverloop, event)
def fewSecEverloop(self, event_id, payload_event, *args):
#execfile('rainbow.py')
subprocess.call(['python3', 'rainbow.py'])
#os.system("python3 rainbow.py")
This does nothing, when the event is triggered, not even gives an error.
I’ve added the everloopapp.py to the apps.yaml like this:
party:
module: everloopapp
class: Rainbow
Please let me know, if there is anything missing in order to figure out what might be wrong.
I’m grateful for any advice, hints, ect.