StateReader

struct StateReader
extension StateReader : Equatable, Hashable, Identifiable, Node, NodeWithOutput, Sendable

A class that accesses a trait’s state, used for conditions.

  • id

    The stable identity of the entity associated with this instance.

    Declaration

    Swift

    let id: String
  • The Trait associated with the StateReader.

    Declaration

    Swift

    let trait: any Trait.Type
  • The string-based identifier for the Trait. If the trait is UnknownTrait it will refer to the original Trait ID provided.

    Declaration

    Swift

    let traitID: String
  • The unique ID for the StateReader node output. Must be unique per Automation

    Declaration

    Swift

    let output: String
  • An expression that selects an entity or a list of entities associated with the StateReader at runtime.

    When entityExpression represents a single explicit entity, entityExpression will be Constant(value: AnyAutomationEntity). Otherwise, entityExpression is an expression, capable of resolving to any number of entities.

    Declaration

    Swift

    let entityExpression: any Expression
  • The unique entity for the HomeDevice or Structure entity associated with the StateReader.

    entity will be nil if the init(entityExpression: …) was used and the entityExpression is not a Constant to an AnyAutomationEntity.

    Declaration

    Swift

    var entity: (any HomeObject)? { get }
  • The identifier of the DeviceType associated with the StateReader, if the entity is a device.

    deviceType will be nil if entity is nil or not a device, such as a Structure or Room.

    Declaration

    Swift

    var deviceType: (any DeviceType.Type)? { get }
  • The string-based identifier for the DeviceType. If the deviceType is UnknownDeviceType it will refer to the original DeviceType ID provided.

    deviceTypeID will be nil if entity is nil or not a device, such as a Structure or Room.

    Declaration

    Swift

    var deviceTypeID: String? { get }
  • Returns a Boolean value indicating whether two values are equal.

    Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

    Declaration

    Swift

    static func == (lhs: StateReader, rhs: StateReader) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

  • Returns true if the nodes are equal, false otherwise.

    Declaration

    Swift

    func isEqual(to other: any Node) -> Bool