DeviceTypeController

final class DeviceTypeController
extension DeviceTypeController : Sendable

Controller to access concrete DeviceTypes for a HomeDevice.

  • Checks if the device supports the given type.

    Declaration

    Swift

    func contains<T>(_ type: T.Type = T.self) -> Bool where T : DeviceType
  • Returns an instance of the given type if the device supports it, otherwise returns nil.

    This is a convenience method that returns the first value published by the subscribe publisher.

    Declaration

    Swift

    func get<T>(_ type: T.Type = T.self) async -> T? where T : DeviceType
  • Returns a publisher of the given DeviceType.

    If the device type is not supported, the publisher will not emit any values.

    Declaration

    Swift

    func subscribe<T>(_ type: T.Type = T.self) -> AnyPublisher<T, HomeError> where T : DeviceType
  • Returns any array of the top level DeviceTypes satisfying the given criteria.

    Declaration

    Swift

    func getAll<T>(of type: T.Type) async throws -> [T] where T : DeviceType

    Return Value

    An array of matching types.

  • Returns a publisher of arrays of the top level DeviceTypes satisfying the given criteria.

    Declaration

    Swift

    func subscribeAll<T>(of type: T.Type) -> AnyPublisher<[T], HomeError> where T : DeviceType

    Return Value

    An array of matching types.

  • Returns the number of parts of the given type.

    Declaration

    Swift

    func count<T>(_ type: T.Type) -> Int where T : DeviceType
  • Return a Publisher that emits a collection of all the device types for the given device.

    Declaration

    Swift

    func subscribeAll() -> AnyPublisher<DeviceTypeCollection, HomeError>