Skip to content
module

pylnlib.Switch

Classes
class

pylnlib.Switch.Switch(id, thrown=None, engage=None)

Represents a switch state.

Parameters
  • id (int) The switch address.
  • thrown (optional) The switch state, one of {None, "CLOSED", "THROWN"}.
  • engage (bool) Whether the switch motor is engaged.
Raises
  • ValueError if the state is an unknown literal and not None.
Methods
  • __eq__(other) (bool) Compares a Switch object to another object.</>
  • __str__() (str) Returns a string representation of a Switch object.</>
  • toJSON() (dict) Returns an object suitable for serialiazing as JSON.</>
method

toJSON()

Returns an object suitable for serialiazing as JSON.

Returns (dict)

A dictionary with the object attributes.

method

__str__()

Returns a string representation of a Switch object.

Note

The address shown is 1 larger than the actual address as is customary. (The address is indeed offset 0, but modellers are not accustomed to that)

Returns (str)

the string representation of a Switch object with its state and address.

method

__eq__(other)

Compares a Switch object to another object.

Parameters
  • other (object) any other object
Returns (bool)

True if switch address, thrown and engage are the same