Skip to content

Instantly share code, notes, and snippets.

@teshi04
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teshi04/0cc9560d972ed440883e to your computer and use it in GitHub Desktop.
Save teshi04/0cc9560d972ed440883e to your computer and use it in GitHub Desktop.
# 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