Skip to content

Instantly share code, notes, and snippets.

class HomeduinoPlugin extends env.plugins.Plugin
init: (app, @framework, @config) =>
@framework.deviceManager.on('discover', (eventData) =>
@framework.deviceManager.discoverMessage(
'pimatic-homeduino', 'Press a button on your remote'
)
setTimeout( ( =>
config = {
@sweetpi
sweetpi / predicate-handler.coffee
Last active August 29, 2015 14:01
predicate-handler
class AnswerPredicateHandler extends PredicateHandler
constructor: (@framework, @leftTokens) ->
setup: ->
@lastState = null
@variables = @framework.variableManager.extractVariables(@leftTokens)
@changeListener = () =>
@_evaluate().then( (state) =>
if state isnt @lastState
@sweetpi
sweetpi / action-handler.coffee
Last active August 29, 2015 14:01
providing actions
class AnswerActionHandler extends env.actions.ActionHandler
constructor: (@framework) ->
executeAction: (simulate) =>
if simulate
return Promise.resolve(__("would log 42"))
else
env.logger.info "42"
return Promise.resolve(__("logged 42"))
@sweetpi
sweetpi / adding-files.coffee
Last active August 29, 2015 14:01
extending-mobile-frontend
# in your plugins init-function:
init: (@app, @framework, @config) =>
# [...]
# wait till all plugins are loaded
@framework.on "after init", =>
# Check if the mobile-frontent was loaded and get a instance
mobileFrontend = @framework.pluginManager.getPlugin 'mobile-frontend'
if mobileFrontend?
mobileFrontend.registerAssetFile 'js', "pimatic-your-plugin/app/some-js.coffee"
mobileFrontend.registerAssetFile 'css', "pimatic-your-plugin/app/css/some-css.css"
@sweetpi
sweetpi / actions.coffee
Last active December 18, 2015 18:45
pimatic: providing devices in a plugin
class MyDevice extends env.devices.Device
actions:
turnOn:
description: "turns the switch on"
turnOff:
description: "turns the switch off"
changeStateTo:
description: "changes the switch to on or off"
params: