Closed pixlwave closed 4 years ago
Ok, I figured it out in the end. For reference in case anyone who finds this, the input source characteristic is an activeIdentifier
so distinguishing between that and the power is done like this:
class MyTV: Accessory.Television {
override func characteristic<T>(_ characteristic: GenericCharacteristic<T>, ofService service: Service, didChangeValue newValue: T?) where T : CharacteristicValueType {
if characteristic.type == .active, let state = newValue as? Enums.Active {
print("**** Power: \(state) ****")
} else if characteristic.type == .activeIdentifier, let inputNumber = newValue as? UInt32 {
print("**** Input: \(inputNumber) ****")
}
}
}
Hi
Happy HAP user here currently using virtual switches for automation. However I'm now venturing out to using the Television accessory and I'm unsure how to use it. I've made a subclass like so:
and instantiated it like so:
I can see the print statements, but I'm not really sure how to interpret the characteristic as a power change or input change. Sorry if I'm being a bit slow, any help would be much appreciated 😄