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.