HAEntity

public struct HAEntity : HADataDecodable, Hashable

An entity in Home Assistant

  • The entity id, e.g. sun.sun or light.office

    Declaration

    Swift

    public var entityId: String
  • The domain of the entity id, e.g. light in light.office

    Declaration

    Swift

    public var domain: String
  • The current state of the entity

    Declaration

    Swift

    public var state: String
  • When the entity was last changed

    Declaration

    Swift

    public var lastChanged: Date
  • When the entity was last updated

    Declaration

    Swift

    public var lastUpdated: Date
  • Attributes of the entity

    Declaration

    Swift

    public var attributes: HAEntityAttributes
  • Context of the entity’s last update

    Declaration

    Swift

    public var context: HAResponseEvent.Context
  • Create an entity from a data response

    Throws

    When the data is missing any required fields

    Declaration

    Swift

    public init(data: HAData) throws

    Parameters

    data

    The data to create from

  • Create an entity from individual items

    Throws

    When the attributes are missing any required fields

    Declaration

    Swift

    public init(
        entityId: String,
        domain: String? = nil,
        state: String,
        lastChanged: Date,
        lastUpdated: Date,
        attributes: [String: Any],
        context: HAResponseEvent.Context
    ) throws

    Parameters

    entityId

    The entity ID

    domain

    The domain of the entity ID (optional), when nil domain will be extracted from entityId

    state

    The state

    lastChanged

    The date last changed

    lastUpdated

    The date last updated

    attributes

    The attributes of the entity

    context

    The context of the entity

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • Declaration

    Swift

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