spriter / swiftyhue Goto Github PK
View Code? Open in Web Editor NEWPhilips Hue SDK
License: MIT License
Philips Hue SDK
License: MIT License
Are there plans to upgrade SwiftyHue to be Swift 5 compatible? Thanks!
Hello,
i wanted to ask, if it's possible to change the name of a light? I only found the option to change a room/group name.
And another question is, if it's possible to add a new light? If it's not configured with the original Hue App.
Thanks.
Just curious if it's coming to this project. Thanks!
Trying to understand why this is vs just setting the array to the desired order.
AKA why not:
NUPNPScanner first
self.init(validator: BridgeValidator(), scannerClasses: [NUPNPScanner.self, SSDPScanner.self])
... later ....
allScannerClasses.pop()
OR SSDPScanner first
self.init(validator: BridgeValidator(), scannerClasses: [SSDPScanner.self, NUPNPScanner.self])
... later ....
allScannerClasses.pop()
Why the need for the reversed
self.allScannerClasses = scannerClasses.reversed()
is it possible to update just the status of schedule?
What do you think about making the Heartbeat stuff USE another SwiftyHue API as opposed to right now it's all locked together.
For example, Heartbeat should could call a function to give it it's requested resources, in that way other clients could call the same thing if they didn't want to use the heartbeat.
Example implementation:
public func fetch<Error: Swift.Error, Resource: BridgeResource & BridgeResourceDictGenerator where Resource.AssociatedBridgeResourceType == Resource>(resource: HeartbeatBridgeResourceType, callback:(Result<[String: Resource], Error>) -> ()){
guard let authorization = _authorization else {
log.error("No 'Authorization' set'")
return
}
let url = "http://\(authorization.ipAddress)/api/\(authorization.username)/\(resource.rawValue.lowercased())"
Alamofire.request(.GET, url)
.responseJSON { response in
switch response.result {
case .success(let data):
let resources = Resource.dictionaryFromResourcesJSON(data as! JSON)
let result = Result<[String: Resource], Error>.success(resources)
callback(result)
case .failure(let error):
let result = Result<[String: Resource], Error>.failure(error as! Error)
callback(result)
}
}
}
public func fetchLights(_ callback: (Result<[String: Light], NSError>) -> ()){
fetch(resource: .lights, callback: callback)
}
call site example:
something.fetchLights{
(result) in
switch result {
case .success(let lights):
print(lights)
case .failure(let error):
print(error)
}
}
Now heartbeat could call it on an interval, or anything else could just call it once.
Keeping with what is there, since a SendAPI
exists, it would be introducing a ResourceAPI
Hi, your LightState struct does not include the transitiontime element. I'm happy to submit a pull request though it appears that I don't have permission to push a branch. Could you please give me access (perhaps add me as a collaborator)?
I've imported the library into my project, however when I click "build" on Xcode it fails, the error is:
CodeSign /Users/MyName/Library/Developer/Xcode/DerivedData/App_Hue-dilrdxszovgssvcqobfbekteobjr/Build/Products/Debug/App\ Hue.app
cd "/Volumes/Macintosh HD/Users/MyName2/HDDDocuments/PersonalGithub/AppHue"
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "Mac Developer: [email protected] (TXXXNXXZXX)"
/usr/bin/codesign --force --sign 1F45D22C9009847DE3351794C18F6D703CA4AFB2 --entitlements /Users/MyName/Library/Developer/Xcode/DerivedData/App_Hue-appdilrdxszovgssvcqobfbekteobjr/Build/Intermediates.noindex/App\ Hue.build/Debug/App\ Hue.build/App\ Hue.app.xcent --timestamp=none /Users/MyName/Library/Developer/Xcode/DerivedData/App_Hue-dilrdxszovgssvcqobfbekteobjr/Build/Products/Debug/App\ Hue.app
/Users/MyName/Library/Developer/Xcode/DerivedData/App_Hue-dilrdxszovgssvcqobfbekteobjr/Build/Products/Debug/App Hue.app: code object is not signed at all
In subcomponent: /Users/MyName/Library/Developer/Xcode/DerivedData/App_Hue-dilrdxszovgssvcqobfbekteobjr/Build/Products/Debug/App Hue.app/Contents/Frameworks/CocoaAsyncSocket.framework
Command /usr/bin/codesign failed with exit code 1
This is happening with SwiftyHue 0.4.1 and downloaded using Carthage.
I tried to Clean Build Folder, but sadly that didn't work.
Any ideas?
Thanks!
Depedencies that have swift 3 versions:
Alamofire
https://github.com/Alamofire/Alamofire/tree/swift3
Gloss
https://github.com/hkellaway/Gloss/tree/swift_3.0
Log
https://github.com/delba/Log/tree/swift-3.0
CocoaAsyncSocket
doesn't matter, it's obj-c
Your Cartfile will look like this (as of today, obvs those sha's will move):
github "Alamofire/Alamofire" "a94323c"
github "hkellaway/Gloss" "bfb1380"
github "delba/Log" "331075d"
github "robbiehanson/CocoaAsyncSocket" ~> 7.4.3
Cannot find a way to fix this error and receive the XY values of the lights. When iterating through the resource cache, the XY of the LightState returns nil
HeartbeatManager.swift - line 163
print("Hearbeat received Error Result", (json: jsonError))
"Cannot create a single element tuple with an element label"
On this line guards for an id
key in the JSON but no id
key comes from the bridge response.
Per the documentation under section 1.6
http://www.developers.meethue.com/documentation/lights-api
Setting the light state supports transitiontime
in the body arguments:
The duration of the transition from the light’s current state to the new state. This is given as a multiple of 100ms and defaults to 4 (400ms). For example, setting transitiontime:10 will make the transition last 1 second.
Now given the current shape of the LightState model, I could see how "transitiontime" doesn't necessarily fit, especially if a LightState represents the current state of a light; transitiontime is a bit awkward perhaps with its temporal quality.
If LightState
is the wrong place, the case could also be made that the signature for
public func updateLightStateForId(_ identifier: String, withLightState lightState: LightState, completionHandler: BridgeSendErrorArrayCompletionHandler)
should then be updated to support transitionTime: Int? = nil
similar to createSceneWithName
Do you have a preference?
Hi,
I did installed via Cocoapods, but I get 110 issues on the Gloss Framework.
Use Xcode8 and iOS10 for their project.
How can I fix it or is there a newer version?
Thank You very much!!!!!
Dag
Hello,
Thanks for your great library!
I have a question about using it in an iOS app.
Do you know if my app will get rejected if I will use your library? Apple doesn't allow trivial use of controlling an external hardware of companies through a third party apps.
Do you know anything about this?
Thanks again,
Oz.
Hey guys,
Any chance of an update to the quickstart app?
SwiftyHue.resourceCache?.sensors
is unfortunately missing my "hue motion sensor". I want to react on it's state.lastUpdated
It's mostly because it's missing the "type" for creating a sensor class:
Can't create Sensor, missing required attribute "type"
I tried to change the type from missing to CLIPPresence if its the hue motion sensor, and it works. Here is my updated code. It's super dirty, but I'm not a native swift developer.
Inside Sensor.swift init?(json: JSON)
guard let type: SensorType = "type" <~~ json else {
print("Can't create Sensor, missing required attribute \"type\" in JSON:\n \(json)");
//returns nil for Hue motion sensor
return nil
}
To:
var type : SensorType?
if let tt: SensorType = "type" <~~ json {
type = tt
} else if json["productname"] as? String == "Hue motion sensor" {
type = SensorType.CLIPPresence
} else {
return nil
}
There is a missing module i guess. Can't compile the product and podfile guide is not working too..
master and swift3 branch. :-(
I can't seem to find a way to actually stop the scanner during the BridgeFinder flow. For example if you wanted to stop the scan with some timeout etc... I don't see any public API on the BridgeFinder class.
Do you have any plans to release in swift 4?
Also are there any resources on implanting groups in swift?
Thanks for your work here
Hello!
I understand this project is in progress, but I'm wondering if there is a way to read the state of some lights when in a background fetch state? (func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
)
Currently I'm trying to access the state through the resource cache, but it is coming back nil. I'm wondering if maybe there is a method you could expose in the BridgeSendAPI class? Or am I going about this all the wrong way?
Thanks!
I installed the pod, but the SwiftyHue framework file doesn't exist. I can't use 'import SwiftyHue'
here is what my pod file looks like:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'MYPROJECT NAME' do
use_frameworks!
pod 'SwiftyHue', '~> 0.1.6'
end
I cant compile anymore my project with Xcode 9.
Pods:
Using Alamofire (4.4.0)
Using CocoaAsyncSocket (7.4.3)
Using Gloss (1.2.4)
Using Log (1.0)
Using Moscapsule (0.5.2)
Using OpenSSL-Universal (1.0.1.20)
Using SwiftyHue (0.2.6)
Using SwiftyUserDefaults (3.0.0)
Thanks for helping :)
warning: 'AsyncUdpSocket' is deprecated: The RunLoop versions of CocoaAsyncSocket are deprecated and will be removed in a future release. Please migrate to GCDAsyncUdpSocket
Thank you for a nice project
I sure could use just a bit more documentation. Especially around the resourceCache and the bridgeSendAPI.
You did a big job on this, it would really be nice to be able to use it better..
Nice project, Testing it on very first step to create bridge. Before adding Allow Arbitrary Load
plist i got "ATS failed system trust" after insert plist then have TIC SSL Trust Error as below
Any hints? Attached code to see if anything i mess up. Thanks.
Environment: Swift 4
Plist: Added - "Allow Arbitrary Loads - Yes"
Cocoapods:
use_frameworks!
pod 'SwiftyHue', '~> 0.4'
end
Error as below:
18:02:48.043555+0800 Huetest[8125:257947] TIC SSL Trust Error [1:0x60c00016a8c0]: 3:0
2018-03-26 18:02:48.044128+0800 Huetest[8125:257947] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2018-03-26 18:02:48.044363+0800 Huetest[8125:257947] Task .<1> HTTP load failed (error code: -1202 [3:-9813])
2018-03-26 18:02:48.044559+0800 Huetest[8125:257945] Task .<1> finished with error - code: -1202
import UIKit
import SwiftyHue
class ViewController: UIViewController {
var bridgeFinder = BridgeFinder()
var bridges: [HueBridge]?;
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
bridgeFinder.delegate = self;
bridgeFinder.start()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension ViewController: BridgeFinderDelegate {
func bridgeFinder(_ finder: BridgeFinder, didFinishWithResult bridges: [HueBridge]) {
self.bridges = bridges;
print(bridges)
}
}
I was just about to use this in my project, then I noticed there was no macOS version =(
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.