keiko is Python and Web API clients for Keiko-chan.
Project description
keiko is Python and Web API clients for Keiko-chan.
Installation
keiko can be installed via pip or easy_install:
$ pip install keiko
Or:
$ easy_install keiko
Usage
Firstly, setup Keiko-chan and assign IP address.
Python
Specify the address of Keiko-chan and instantiate the client:
>>> import keiko
>>> address = '192.168.1.2' # example address of Keiko-chan
>>> client = keiko.Client(address)
Control the lamps:
>>> client.lamps.green.on() # turns on the lamp
>>> client.lamps.green.status
'on'
>>> client.lamps.green.off() # turns off the lamp
>>> client.lamps.green.status
'off'
>>> client.lamps.yellow.blink() # blinks the lamp
>>> client.lamps.yellow.status
'blink'
>>> client.lamps.red.quickblink() # blinks the lamp quickly
>>> client.lamps.red.status
'quickblink'
>>> client.lamps.off() # turns off the all lamps
With delay and duration time:
>>> client.lamps.red.on(wait=2, time=4) # wait 2 second, light 4 seconds
Control the buzzer:
>>> client.buzzer.on() # turns on the buzzer
>>> client.buzzer.status
'continuous'
>>> client.buzzer.off() # turns off the buzzer
>>> client.buzzer.status
'off'
Control the direct inputs and outputs:
>>> client.di.status
{1: 'off', 2: 'off', 3: 'off', 4: 'off'}
>>> client.do.status
{1: 'off', 2: 'off', 3: 'off', 4: 'off'}
>>> client.do(2).on()
>>> client.do(2).status
'on'
>>> client.do.status
{1: 'off', 2: 'on', 3: 'off', 4: 'off'}
Control the voices:
>>> client.voices.status
'stop'
>>> client.voices(1).play() # plays #1 voice
>>> client.voices.stop() # stops the voice
>>> client.voices(5).play(3) # plays #5 voice 3 times
>>> client.voices.stop()
>>> client.voices(10).repeat() # plays #10 voice repeatedly
>>> client.voices.stop()
Web API
Specify the address of Keiko-chan and run Web API server:
$ keiko 192.168.1.2
* Running on http://127.0.0.1:8080/
Pass optional parameters to the server:
$ keiko 192.168.1.2 --server myhost:5000
* Running on http://myhost:5000/
Control the lamps:
$ curl http://127.0.0.1:8080/lamps
{
"lamps": {
"green": "off",
"red": "off",
"yellow": "off"
}
}
$ curl http://127.0.0.1:8080/lamps/green/on
{
"result": "success"
}
$ curl http://127.0.0.1:8080/lamps/green
{
"lamps": {
"green": "on"
}
}
With delay and duration time:
$ curl http://127.0.0.1:8080/lamps/yellow/on?wait=2&time=4
{
"result": "success"
}
Control the buzzer:
$ curl http://127.0.0.1:8080/buzzer
{
"buzzer": "off"
}
$ curl http://127.0.0.1:8080/buzzer/on
{
"result": "success"
}
Control the direct inputs and outputs:
$ curl http://127.0.0.1:8080/di
{
"di": {
"1": "off",
"2": "off",
"3": "off",
"4": "off"
}
}
$ curl http://127.0.0.1:8080/do
{
"do": {
"1": "off",
"2": "off",
"3": "off",
"4": "off"
}
}
$ curl http://127.0.0.1:8080/do/2/on
{
"result": "success"
}
Control the voices:
$ curl http://127.0.0.1:8080/voices
{
"voices": "stop"
}
$ curl http://127.0.0.1:8080/voices/10/play
{
"result": "success"
}
Caveats
This module is unofficial and tested with only Keiko-chan 4G+ (DN-1510GL) yet. For more details, see the official documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
File details
Details for the file keiko-0.2.0.zip
.
File metadata
- Download URL: keiko-0.2.0.zip
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 886f4a1b66a0f6b5f2a364a417d31053f2cae134392345b38433071e9ef9092f |
|
MD5 | 84c0fc9d7bb00b40aa6d8c65f5d0318e |
|
BLAKE2b-256 | b6e0a15538261a6801f88d2c50202270ffc384d06e27edb4a8df919b7d2da637 |
File details
Details for the file keiko-0.2.0.tar.gz
.
File metadata
- Download URL: keiko-0.2.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1dfe93094cc4896dc11e818b7e3aeead2fb3e6c14351525c7dee24b17347b92 |
|
MD5 | d899eda01adc69496d4fdbf9e7158145 |
|
BLAKE2b-256 | 366bd90b5ba3575001649d24ca2883d95886fd26a8eba5b4aeb8ae801399a94f |