Please reformat your post to have properly formatted code, whitespace is important in python. There is an edit icon you can click to edit your post.
Second, you are pulling data from the DB, this is absolutely not something to run in a tag change event. Configure this as a Gateway Tag Change Event.
Third, consolidate your tag reads into a single system.tag.readBlocking
call. Pull values from the response as needed later in the script.
1 Like