Serial.write out of Snips-based Relay&Temperature&Humidity app

I am using the SEEED Relay&Temperature&Humidity app in my RPi snips device…



The app works fine when I ask it to perform the various intents, such as “turn relay on”…



I want to add a data packet serial write in the action-code, i.e., when the relay turns on I also want to send a packet to a USB-connected device…I cannot seem to effect this - I cannot get past simply importing the serial library and trying to open the port, without even trying to do the data write…



If I put in the import statement [import serial], that’s OK, but when I add the line to open the port:



ser = serial.Serial(port = ‘/dev/ttyUSB0’, baudrate = 57600, timeout = 1)



it breaks the snips app after recognizing the wake-word and going to implement the activity - see attached screenshot…



If I run a simple python script while I am running the working or broken snips app, such as:

[code]import RPi.GPIO as GPIO
import time
import serial

BUTTON = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)

ser = serial.Serial(port = ‘/dev/ttyUSB0’, baudrate = 57600, timeout=1)

while True:
state = GPIO.input(BUTTON)
if state:
print(“off”)
else:
print(“on”)
ser.write ("\xFF\x55\x21\xDE\x00\xFF")
time.sleep(.5)[/code]

things run fine and the data is sent to the device…



I have tried placing the serial open line at various places within the app (I am not proficient on classes and such) but the result is always essentially the same…



Is there something in the snips code that is in my way? I see in their (snips) Coffee Machine app they write data out to an Arduino…



Confused and could use some advice please…



Thanks, Frank