After the Trassir reboot, a situation can often arise when some objects take longer to load than the script. If the script works with objects, for example, schedules via the host.object('My Schedule') method, then the script may cause an error after restarting: ERROR: EnvironmentError: object 'My Schedule' not found
This error can be prevented by using theScheduleObject class
Class arguments
name_or_guid (str): Object name or guid.
color_change_handler (callable, optional): A function that is being called when the state of the object changes.self argument is passed to the function.
tries (int, optional): Number of attempts to load an object, 5 by default.
If a name is used to initialize an object, it must be unique for all objects in Trassir, includingobjects on other servers connected over the network to the main server.
For example, if server B is connected via the network to server A and both have a schedule named "Schedule" then the script on server A will select one of the objects randomly.
Also, if on the same server, for example, IP Device and Channel are named the same, then the script will also randomly select an object.
The number of attempts ~ the number of seconds of the object loading time, i.e.every next attempt occurs ~ in 1 second
Public attributes
name (str): Object name.
guid (str): Object guid.
color ('Red' | 'Green' | 'Blue' | None): Returns the current schedule color. Returns None if an object isn't loaded.
prev_color ('Red' | 'Green' | 'Blue' | None): Returns the previous color of the schedule. ReturnsNone if there hasn't been a color change yet.If color_change_handler is not set, then prev_color will always return None.
Script examples
Showing current color of the schedule by pressing F1 button