Last active
August 29, 2015 14:01
-
-
Save teshi04/0cc9560d972ed440883e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# Operate the air conditioning of office. | |
# | |
# Commands: | |
# irkit aircon on - Switch on the air conditioning in the office | |
# irkit aircon off - Switch off the air conditioning in the office | |
module.exports = (robot) -> | |
IRKIT_API_MESSAGES = "https://api.getirkit.com/1/messages" | |
CLIENT_KEY = "client_key" | |
DEVICE_ID = "device_id" | |
AIRCON_ON = JSON.stringify({"format":"raw","freq":38,"data":[904,815,9045,873,873.....,873,2537,873,2537,873]}) | |
AIRCON_OFF = JSON.stringify({"format":"raw","freq":38,"data":[904,815,904,787.....,2626,787,2626,787,2626,787]}) | |
robot.respond /aircon on/i, (msg) -> | |
msg.http(IRKIT_API_MESSAGES) | |
.query({ | |
clientkey: CLIENT_KEY | |
deviceid: DEVICE_ID | |
message: AIRCON_ON}) | |
.post() (err, res, body) -> | |
msg.send "エアコン入れたかも" | |
robot.respond /aircon off/i, (msg) -> | |
msg.http(IRKIT_API_MESSAGES) | |
.query({ | |
clientkey: CLIENT_KEY | |
deviceid: DEVICE_ID | |
message: AIRCON_OFF}) | |
.post() (err, res, body) -> | |
msg.send "エアコン切ったかも" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment