Latest 1.0.0-Beta-1-Swift5
Homepage https://github.com/itthisakp/LightStyle
License Light Style
Platforms ios 9.0
Dependencies LightStyleSupportingSDK

LightStyle

Usage

// Import SDK
import LightStyleSDK

// Set host url, username and password
LightStyleSDK.shared.initialize(host: "#host url#", username: "#username#", password: "#password#")

// Update configuration
LightStyleSDK.shared.updateConfiguration(projectId: "#project_id#", unitId: "#unit_id#") { (success, error) in

    // Get the first room
    if success, let room = LightStyleSDK.shared.rooms.first {
        // Get the first switch and the first command
        if let sw = room.switches.first, let cmd = sw.commands.first {
            LightStyleSDK.shared.sendCommand(to: sw, with: cmd, completion: { (success, error) in
                if success {
                    print("Send command successfully.")
                }
            })
        }
        // Get the first curtain and the first command
        if let ct = room.curtains.first, let cmd = ct.commands.first {
            LightStyleSDK.shared.sendCommand(to: ct, with: cmd, completion: { (success, error) in
                if success {
                    print("Send command successfully.")
                }
            })
        }
        // Get the first air conditioner
        if let ac = room.airConditioners.first {
            let cmd = LSAirConditionerOptionCommands(power: LSAirConditionerPowerOption.open,
                                                        mode: LSAirConditionerModeOption.auto,
                                                        operation: LSAirConditionerOperationOption.auto,
                                                        fan: LSAirConditionerFanOption.medium,
                                                        setTemperature: 24)
            LightStyleSDK.shared.sendCommand(to: ac, with: cmd, completion: { (success, error) in
                print("Send command successfully.")
            })
        }

        // Observe air conditioners status
        guard let airConditioners = LightStyleSDK.shared.rooms.first?.airConditioners else {
            return
        }

        LightStyleSDK.shared.observeStatus(of: airConditioners, completion: { (status, error) in
            if let err = error {
                print(err)
            } else {
                // handle status an object.
            }

        })

        // Get the first remote control and the first command
        if let ir = room.remoteControls.first, let cmd = ir.commands.first {
            LightStyleSDK.shared.sendCommand(to: ir, with: cmd, completion: { (success, error) in
                print("Send command successfully.")
            })
        }
    }
}

Latest podspec

{
    "name": "LightStyleSDK",
    "version": "1.0.0-Beta-1-Swift5",
    "summary": "Light Style SDK",
    "homepage": "https://github.com/itthisakp/LightStyle",
    "license": "Light Style",
    "authors": "LightStyle",
    "platforms": {
        "ios": "9.0"
    },
    "swift_version": "5.0",
    "source": {
        "git": "https://github.com/itthisakp/LightStyle.git",
        "tag": "1.0.0-Beta-1-Swift5"
    },
    "ios": {
        "vendored_frameworks": "LightStyleSDK.framework"
    },
    "dependencies": {
        "LightStyleSupportingSDK": []
    },
    "user_target_xcconfig": {
        "ENABLE_BITCODE": "NO"
    },
    "pod_target_xcconfig": {
        "ENABLE_BITCODE": "NO"
    }
}

Pin It on Pinterest

Share This