This file contains 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
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 = { |
This file contains 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
class AnswerPredicateHandler extends PredicateHandler | |
constructor: (@framework, @leftTokens) -> | |
setup: -> | |
@lastState = null | |
@variables = @framework.variableManager.extractVariables(@leftTokens) | |
@changeListener = () => | |
@_evaluate().then( (state) => | |
if state isnt @lastState |
This file contains 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
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")) |
This file contains 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
# 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" |
This file contains 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
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: |