Gateway Script Not Triggering

Good Afternoon,

I have a script where I would like it to generate a random number then pass it into a variable. However I am find that the tag is not updating.

I would like this to run under a timer (every 1 second) but I am not having any luck with this.

I do have other scripts running with tigger from timers and triggered from a tag change, and this works correctly when I put it in the script console.

import random

# Function to generate random consumption values for power meters
def generate_consumption():
    print("Generating random consumption value...")
    return random.randint(100, 500)  # Random value between 100 and 500 kWh

# Generate random consumption values for power meters
print("Generating consumption values for power meters...")
meter1_consumption = generate_consumption()
print("Meter 1 consumption:", meter1_consumption)


# Write the generated values to corresponding tags
print("Writing generated values to tags...")
system.tag.write("[default]tagpath", meter1_consumption)

# Call the function to update power meters once
# update_power_meters()

Any suggestionswould be great.

Is system.tag.write depreciated?

Also, you should get in the habit of supplying the tag paths and values as lists (in [ ]).

2 Likes

I'm sure it's still appreciated, especially by upgraders. :laughing:

Can you share a screenshot of how you've got the timer script set up? Any errors in the gateway console? If you add logging statements with system.util.getLogger, are you seeing those output to confirm your script is actually running? Have you saved the project (gotta ask :smile:)?

Thanks for the resposne peter!

haha fair question, yes I have saved it... multiple times. And I cant see any errors in the consol output.


The errors won't be in the console. They will be in the gateway logs. Gateway events run in the gateway.

2 Likes