Groovy-IRKit
IRKit client for Groovy.
Features
- Find IRKit device from within the same LAN.
- Read/Write IR-Data from within the same LAN.
- Acquire the client token from IRKit.
- Read/Write IR-Data from the Internet.
Requirement
- Java 8+
Usage
girkit CLI
$ girkit --help
$ girkit --get tv_on
$ girkit --post tv_on
$ girkit --post tv_on --address 192.168.0.123
$ girkit --list
$ girkit --delete tv_on
use Internet API
$ girkit --device:add myhouse
$ girkit --post tv_on --device myhouse
$ girkit --device:delete myhouse
IRKit client for Groovy
See samples
Read/Write IR-Data
IRKit has a HTTP API that can be used from within the same LAN.
import org.yukung.girkit.Device
// find IRKit with Bonjour
irkit = Device.find().first()
// or, specify with IP address.
//irkit = new Device(address: InetAddress.getByName('192.168.0.10'))
if (!irkit) {
System.err.println "irkit not found."
System.exit 1
}
println irkit.dump()
irData = irkit.getMessages()
if (!irData) {
System.err.println "IR data not found."
System.exit 1
}
println irData.dump()
println 'rewrite IR data'
irkit.postMessages irData
println irData.dump()
Internet API
To access IRKit from outside of the LAN, use Internet API. it uses api.getirkit.com
as a proxy.
Get clientkey
and deviceid
.
import org.yukung.girkit.Device
irkit = Device.find().first()
if (!irkit) {
System.err.println "irkit not found"
System.exit 1
}
token = irkit.getToken()
println "token:\t${token}"
res = irkit.getClientKeyAndDeviceId token
println "clientkey:\t${res.clientkey}"
println "deviceid:\t${res.deviceid}"
Read/Write with Internet API
CLIENT_KEY = System.getenv('CLIENT_KEY') ?: 'your_client_key'
DEVICE_ID = System.getenv('DEVICE_ID') ?: 'your_device_id'
irkit = new InternetAPI(clientKey: CLIENT_KEY, deviceId: DEVICE_ID)
if (!irkit) {
System.err.println("device not found.")
System.exit 1
}
println irkit.dump()
irData = irkit.getMessages()
if (!irData) {
System.err.println("IR data not found")
System.exit 1
}
println irData.dump()
println 'rewrite IR data'
irkit.postMessages irData.message
irData.dump()
Installation
girkit CLI
Download archive file from release page. and unzip the archive file.
Or, for local install
$ git clone https://github.com/yukung/girkit.git
$ ./gradlew installDist
will be installed under the (project root)/build/install
directory.
girkit API
Available from jCenter repository.
Grape
@Grab(group='org.yukung', module='girkit', version='0.4.1')
Gradle
repositories {
jcenter()
}
dependencies {
compile group: 'org.yukung', name: 'girkit', version: '0.4.1'
}
Author
License
Licensed under the terms of the Apache License, Version 2.0