 
   EventSource = require 'eventsource'
 
-  Particle = require 'spark'
+  ParticleLib = require 'spark'
 
   #############################################################################
   # PiMarticle

        @emit "value", value

    requestData: () =>
      creds = accessToken: @accessToken
      Particle.login(creds).then((token) =>
        #console.log 'Logged in: ', token
        Particle.getVariable @coreid, @variable
      ).then ((data) =>
        #console.log @variable + ' retrieved successfully: ' + data.result
        @_setValue data.result
      ), (err) ->
        console.log 'Particle error:', err

    init: (app, @framework, @config) =>
      deviceConfigDef = require("./device-config-schema")

      esConfig = headers: 'Authorization': 'Bearer ' + config.auth
      es = new EventSource(EVENTS_URL, esConfig)
      es.onerror = ->
        console.log 'ERROR!'
        return

      creds = accessToken: config.auth
      ParticleLib.login creds
      .then (token) =>
        console.log 'Logged in: ', token

      @framework.deviceManager.registerDeviceClass("ParticlePresenceSensor", {
        configDef: deviceConfigDef.ParticlePresenceSensor,
