GithubHelp home page GithubHelp logo

swiftyhue's People

Contributors

choas avatar cliffspencer avatar j3y-s avatar nilslattek avatar samuelclay avatar spriter avatar zorro2b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftyhue's Issues

Swift 5

Are there plans to upgrade SwiftyHue to be Swift 5 compatible? Thanks!

Change light name, add new light

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.

BridgeFinder: scanner classes are reversed then popLast()'d

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()

Proposed Refactor for Heartbeat Resources

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

Transition time

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)?

Build Fails "code object is not signed at all In subcomponent: CocoaAsyncSocket.framework"

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!

Xcode 10.2 compilation error

HeartbeatManager.swift - line 163
print("Hearbeat received Error Result", (json: jsonError))

"Cannot create a single element tuple with an element label"

LightState is missing transitiontime

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?

Build Fails

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

an question about using this library in practice

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.

Can't use Hue motion sensor

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
        }

No such Module - Gloss

There is a missing module i guess. Can't compile the product and podfile guide is not working too..
master and swift3 branch. :-(

No way to stop a BridgeFinder scan

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.

Swift 4

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

Accessing light state from background fetch call

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!

Pod Install

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

Need more documentation

Thank you for a nice project 👍

I sure could use just a bit more documentation. Especially around the resourceCache and the bridgeSendAPI.

  • How do I save anything in the cache?
  • How do I change the color of a light?

You did a big job on this, it would really be nice to be able to use it better..

TIC SSL Trust Error

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

Code testing for searching bridges

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)
    }
}

Support macOS

I was just about to use this in my project, then I noticed there was no macOS version =(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.