Skip to content

Instantly share code, notes, and snippets.

@mwittig
Created April 15, 2016 08:15
Show Gist options
  • Save mwittig/489dade58a8fa673e253f9c65a869618 to your computer and use it in GitHub Desktop.
Save mwittig/489dade58a8fa673e253f9c65a869618 to your computer and use it in GitHub Desktop.
pimatic callAction
action: (deviceId, actionName, params) ->
id = '' + @_getActionId()
p = if params? then params else {}
p.deviceId = deviceId
p.actionName = actionName
new Promise (resolve, reject) =>
@socket.emit 'call', {
id: id,
action: 'callDeviceAction',
params: p
}
@socket.on 'callResult', (result) =>
console.log "###################", result
if result.id is id
if result.success
resolve()
else
reject result.error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment