[英]Hue SDK Groups ios App Integration - Swift 4 Xcode 9
So I am developing an app integrating Philips Hue smart lights. 因此,我正在开发一个集成飞利浦Hue智能灯的应用程序。 I am using Hue SDK in swift 4. I want to show available groups in a Table View just like the bridge, and then allow the selection of a group to apply light state changes to.
我正在Swift 4中使用Hue SDK。我想像桥梁一样在表视图中显示可用的组,然后允许选择组以应用灯光状态更改。 I cant find any documentation anywhere on groups, so any sample code or resources would be soooo appreciated!
我在组中的任何位置都找不到任何文档,因此,任何示例代码或资源都将受到赞赏!
The Philips Hue Swift documentation shines again by its absence 💡 飞利浦Hue Swift文档因缺少它而再次闪耀💡
This is how you get all the groups from the selected bridge: 这是从选定网桥获取所有组的方式:
let groups = bridgeController?.bridge.bridgeState.getBridgeResources(of: .group)
And this is how you send a lightstate to a group, ie group '0', which is all lights: 这就是您向一个组(即组“ 0”)发送一个灯光状态的方式,该组是所有灯光:
let lightState: PHSLightState = PHSLightState()
lightState.on = true
lightState.brightness = 254
let group: PHSGroup = bridgeController?.bridge.bridgeState.getBridgeResource(of: PHSDomainType.group, withIdentifier: "0") as! PHSGroup
group.apply(lightState, allowedConnectionTypes: .local, completionHandler: { (responses, errors, returnCode) in
// do something
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.