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
  • Return a Publisher that emits a collection of all the device types for the given device.

    Declaration

    Swift

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